Changeset 1735 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Timestamp:
- 11/09/06 17:04:55 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Diffuse.hlsl
r1683 r1735 3 3 float4 readCubeMap(samplerCUBE cm, float3 coord) 4 4 { 5 float4 color = texCUBE ( cm, float3(coord.xy, -coord.z) );5 float4 color = texCUBElod( cm, float4(coord.xy, -coord.z, 1) ); 6 6 color.a = 1; 7 7 return color; … … 10 10 float readDistanceCubeMap(samplerCUBE dcm, float3 coord) 11 11 { 12 float dist = texCUBE (dcm, float3(coord.xy, - coord.z)).r;12 float dist = texCUBElod(dcm, float4(coord.xy, - coord.z, 1)).r; 13 13 if(dist == 0) dist = 1000000; ///sky 14 14 return dist; 15 15 } 16 16 17 // This function is called several times.18 float3 Hit( float3 x, float3 R, samplerCUBE mp )19 {20 float rl = readDistanceCubeMap( mp, R); // |r|21 22 float ppp = length( x ) / readDistanceCubeMap( mp, x); // |p|/|p|23 float dun = 0, pun = ppp, dov = 0, pov = 0;24 float dl = rl * ( 1 - ppp ); // eq. 225 float3 l = x + R * dl; // ray equation26 27 // iteration28 for( int i = 0; i < 2; i++ ) // 2 !!!!!!!!!!!!!!!!!!!!!!!29 {30 float llp = length( l ) / readDistanceCubeMap( mp, l); // |l|/|l|31 if ( llp < 0.999f ) // undershooting32 {33 dun = dl; pun = llp; // last undershooting34 dl += ( dov == 0 ) ? rl * ( 1 - llp ) : // eq. 235 ( dl - dov ) * ( 1 - llp ) / ( llp - pov ); // eq. 336 } else if ( llp > 1.001f ) // overshooting37 {38 dov = dl; pov = llp; // last overshooting39 dl += ( dl -dun ) * ( 1 - llp ) / ( llp - pun );// eq. 340 }41 l = x + R * dl; // ray equation42 }43 return l; // computed hit point44 }45 17 46 18 ///////////////////// -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapot.hlsl
r1730 r1735 3 3 float4 readCubeMap(samplerCUBE cm, float3 coord) 4 4 { 5 float4 color = texCUBE ( cm, float3(coord.xy, - coord.z) );5 float4 color = texCUBElod( cm, float4(coord.xy, - coord.z,0) ); 6 6 return color; 7 7 } … … 9 9 float readDistanceCubeMap(samplerCUBE dcm, float3 coord) 10 10 { 11 float dist = texCUBE (dcm, float3(coord.xy, - coord.z)).a;11 float dist = texCUBElod(dcm, float4(coord.xy, - coord.z,0)).a; 12 12 return dist; 13 13 } … … 15 15 16 16 17 #define LIN_ITERATIONCOUNT 2 17 #define LIN_ITERATIONCOUNT 20 18 18 #define SECANT_ITERATIONCOUNT 2 19 19 … … 24 24 float3 Ra = abs(R); 25 25 float3 xa = abs(x); 26 float a = max(max(xa.x,xa.y),xa.z) / 27 max(max(Ra.x,Ra.y),Ra.z); 28 29 bool overshoot = false, undershoot = false; 26 27 float xm = max(max(xa.x,xa.y),xa.z); 28 float Rm = max(max(Ra.x,Ra.y),Ra.z); 29 30 float a = xm / Rm; 31 32 33 float dt = length(x / xm - R / Rm) * 256.0 / 2.0; 34 dt = max(dt, 4); 35 dt = 1.0 / dt; 36 37 38 bool overshoot = false, undershoot = true; 30 39 float dp, dl = 0, ppp, llp; 31 40 float lR = readDistanceCubeMap(mp, R); 32 41 //float3 p = R; 33 42 float3 p = 0; 34 35 float dt = 1.0 / LIN_ITERATIONCOUNT; 43 44 45 //float dt = 1.0 / LIN_ITERATIONCOUNT; 36 46 37 47 //linear iteration 38 float t = 0; 48 49 float t = 0.9999999999999; 50 dp = a * t / (1 - t); 51 p = x + R * dp; 52 float dist = readDistanceCubeMap(mp, p); 53 ppp = length(p) / dist; 54 55 t = 0; 56 39 57 while(t < 1.0 && !overshoot) 40 58 { … … 63 81 } 64 82 65 if(t >= 1 && undershoot) 66 { 67 t = 0.9999999999999; 68 dp = a * t / (1 - t); 69 p = x + R * dp; 70 float dist = readDistanceCubeMap(mp, p); 71 ppp = length(p) / dist; 72 overshoot = true; 73 } 83 if(t >= 1.0 && undershoot && dist) 84 overshoot = true; 74 85 75 86 if(overshoot) … … 102 113 103 114 /* 104 float 3 Hit( float3 x, float3 R, samplerCUBE mp)115 float Hit( float3 x, float3 R, samplerCUBE mp, out float3 newDir ) 105 116 { 106 117 //return R + 0.00000000001 * x; … … 128 139 l = x + R * dl; // ray equation 129 140 } 130 return l; // computed hit point 141 newDir = l; // computed hit point 142 143 return dl; 131 144 } 132 145 */ -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Diffuse.material
r1671 r1735 101 101 source GameTools_Diffuse.hlsl 102 102 entry_point DiffuseVS 103 target vs_3_0 103 target vs_3_0 104 104 } 105 105 … … 109 109 entry_point DiffusePS 110 110 target ps_3_0 111 flow_control prefer 111 112 } 112 113 … … 122 123 IllumTechniques 123 124 { 125 124 126 RenderTechnique DistanceCubeMap 125 127 { -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material
r1730 r1735 122 122 entry_point MetalMultipleBouncePS 123 123 target ps_3_0 124 flow_control avoid124 flow_control prefer 125 125 } 126 126 … … 135 135 RenderTechnique ColorCubeMap 136 136 { 137 update_interval 1 137 resolution 1024 138 update_interval 0 138 139 distance_calc false 139 140 face_angle_calc false … … 142 143 RenderTechnique DistanceCubeMap 143 144 { 144 update_interval 1 145 distance_calc true false 146 face_angle_calc true false 145 resolution 1024 146 update_interval 0 147 distance_calc false 148 face_angle_calc false 147 149 update_all_face true 148 150 } 149 151 RenderTechnique ColorCubeMap 150 152 { 153 resolution 1024 151 154 layer 1 152 155 texture_unit_id 2 153 update_interval 1154 distance_calc truefalse155 face_angle_calc truefalse156 update_interval 0 157 distance_calc false 158 face_angle_calc false 156 159 update_all_face true 157 160 render_env false … … 161 164 RenderTechnique ColorCubeMap 162 165 { 166 resolution 1024 163 167 layer 2 164 168 texture_unit_id 3 165 update_interval 1166 distance_calc truefalse167 face_angle_calc truefalse169 update_interval 0 170 distance_calc false 171 face_angle_calc false 168 172 update_all_face true 169 173 render_env false … … 192 196 texture_unit 193 197 { 194 198 //filtering none 195 199 } 196 200 //Cube map of environment distances 197 201 texture_unit 198 202 { 199 203 filtering none 200 204 } 201 205 … … 203 207 texture_unit 204 208 { 205 209 filtering none 206 210 } 207 211 … … 209 213 texture_unit 210 214 { 211 215 filtering none 212 216 } 213 217 }
Note: See TracChangeset
for help on using the changeset viewer.