Changeset 1720 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Timestamp:
- 11/07/06 14:28:17 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Localized_EnvMap.hlsl
r1712 r1720 31 31 { 32 32 float dist = texCUBE(dcm, float3(coord.xy, - coord.z)).r; 33 //if(dist == 0) dist = 1000; ///sky33 if(dist == 0) dist = 1000; ///sky 34 34 return dist; 35 35 } … … 37 37 38 38 39 #define LIN_ITERATIONCOUNT_L0 20 39 #define LIN_ITERATIONCOUNT 6 40 #define LIN_ITERATIONCOUNT_L0 5 40 41 #define LIN_ITERATIONCOUNT_L1 5 41 42 #define LIN_ITERATIONCOUNT_L2 3 … … 57 58 float3 p = R; 58 59 59 float LIN_ITERATIONCOUNT = LIN_ITERATIONCOUNT_L0;60 60 /* 61 61 if(cameraDistance < 100) … … 73 73 //linear iteration 74 74 float t = 0; 75 while(t < 1.0 )76 { 77 if(!overshoot)78 {75 while(t < 1.0 && !overshoot) 76 { 77 //if(!overshoot) 78 //{ 79 79 dp = a * t / (1 - t); 80 80 p = x + R * dp; … … 97 97 else 98 98 undershoot = false; 99 }99 //} 100 100 t += dt; 101 101 } … … 127 127 return p; 128 128 } 129 130 /* 131 float3 Hit(float3 x, float3 R, samplerCUBE mp) 132 { 133 R = normalize(R); 134 float3 xNorm = normalize(x); 135 float3 dt = (R - xNorm) / (float) LIN_ITERATIONCOUNT; 136 float dx = length(cross(R,x)); 137 138 float3 pN = normalize(cross(R, xNorm)); 139 float3 N = normalize(cross(pN,R)); 140 float d = dot(x, N); 141 142 float3 under = xNorm * readDistanceCubeMap(mp, x); 143 float3 over = R * readDistanceCubeMap(mp, R); 144 145 //linear iteration 146 for(int i = 1; i < LIN_ITERATIONCOUNT; i++) 147 { 148 float3 dir = normalize(xNorm + dt * i); 149 float dist = readDistanceCubeMap( mp, dir); 150 float3 point = dir * dist; 151 152 if( dot(N, point) > d)//undershooting 153 { 154 under = point; 155 } 156 else //overshooting 157 { 158 over = point; 159 i = LIN_ITERATIONCOUNT; 160 } 161 } 162 return over; 163 } 164 */ 165 166 /* 129 /* 130 167 131 float3 Hit( float3 x, float3 R, samplerCUBE mp ) 168 132 { 133 //return R + 0.00000000001 * x; 169 134 float rl = readDistanceCubeMap( mp, R); // |r| 170 135 … … 175 140 176 141 // iteration 177 for( int i = 0; i < SECANT_ITERATIONCOUNT; i++ )142 for( int i = 0; i < 2; i++ ) // 2 !!!!!!!!!!!!!!!!!!!!!!! 178 143 { 179 144 float llp = length( l ) / readDistanceCubeMap( mp, l); // |l|/|l| … … 194 159 */ 195 160 161 /* 162 float3 Hit( float3 x, float3 R, samplerCUBE mp ) 163 { 164 float rl = readDistanceCubeMap( mp, R); // |r| 165 166 float ppp = length( x ) / readDistanceCubeMap( mp, x); // |p|/|p| 167 float dun = 0, pun = ppp, dov = 0, pov = 0; 168 float dl = rl * ( 1 - ppp ); // eq. 2 169 float3 l = x + R * dl; // ray equation 170 171 // iteration 172 for( int i = 0; i < SECANT_ITERATIONCOUNT; i++ ) 173 { 174 float llp = length( l ) / readDistanceCubeMap( mp, l); // |l|/|l| 175 if ( llp < 0.999f ) // undershooting 176 { 177 dun = dl; pun = llp; // last undershooting 178 dl += ( dov == 0 ) ? rl * ( 1 - llp ) : // eq. 2 179 ( dl - dov ) * ( 1 - llp ) / ( llp - pov ); // eq. 3 180 } else if ( llp > 1.001f ) // overshooting 181 { 182 dov = dl; pov = llp; // last overshooting 183 dl += ( dl -dun ) * ( 1 - llp ) / ( llp - pun );// eq. 3 184 } 185 l = x + R * dl; // ray equation 186 } 187 return l; // computed hit point 188 } 189 */ 190 196 191 void LocalizedVS(float4 position : POSITION, 197 192 out float3 wPos : TEXCOORD1, … … 280 275 newTexCoord = R; 281 276 282 newTexCoord = Hit(mPos, R, DistanceMap , cameraDistace);283 if(dot(newTexCoord,newTexCoord) == 0)277 newTexCoord = Hit(mPos, R, DistanceMap); 278 /*if(dot(newTexCoord,newTexCoord) == 0) 284 279 Color = float4(0.5,0.5,0.5,1); 285 else 286 280 else*/ 281 Color = readCubeMap(CubeMap, newTexCoord ); 287 282 288 283 float ctheta_in = dot(mNormal,R);
Note: See TracChangeset
for help on using the changeset viewer.