- Timestamp:
- 10/30/06 13:34:08 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Localized_EnvMap.hlsl
r1691 r1699 47 47 }*/ 48 48 49 #define LIN_ITERATIONCOUNT 850 #define SECANT_ITERATIONCOUNT 349 #define LIN_ITERATIONCOUNT 5 50 #define SECANT_ITERATIONCOUNT 0 51 51 52 52 float3 Hit(float3 x, float3 R, samplerCUBE mp) … … 55 55 float3 xNorm = normalize(x); 56 56 float3 dt = (R - xNorm) / (float) LIN_ITERATIONCOUNT; 57 //float3 pN = normalize(cross(R, xNorm)); 58 //float3 N = normalize(cross(pN,R)); 59 //float d = dot(x, N); 60 61 float3 under = x; 62 float3 over = R; 63 float dUnder = readDistanceCubeMap( mp, x); 64 float dOver = readDistanceCubeMap( mp, R); 65 66 for(int i = 0; i < LIN_ITERATIONCOUNT; i++) 57 float dx = length(cross(R,x)); 58 59 float3 pN = normalize(cross(R, xNorm)); 60 float3 N = normalize(cross(pN,R)); 61 float d = dot(x, N); 62 63 float3 under = xNorm * readDistanceCubeMap(mp, x); 64 float3 over = R * readDistanceCubeMap(mp, R); 65 66 //linear iteration 67 for(int i = 1; i < LIN_ITERATIONCOUNT; i++) 67 68 { 68 float3 dir = normalize(x + dt * i);69 float3 dir = normalize(xNorm + dt * i); 69 70 float dist = readDistanceCubeMap( mp, dir); 70 71 float3 point = dir * dist; 71 72 float t = length(x) / dot(dir,xNorm); 73 74 if(dist > t) //undershooting 75 { 76 under = normalize(point); 77 dUnder = dist; 72 73 if( dot(N, point) > d)//undershooting 74 { 75 under = point; 78 76 } 79 77 else //overshooting 80 78 { 81 over = normalize(point); 82 dOver = dist; 79 over = point; 83 80 i = LIN_ITERATIONCOUNT; 84 } 85 86 /* 87 88 if( dot(N, point) > d)//undershooting 89 under = normalize(point); 90 else //overshooting 91 { 92 over = normalize(point); 93 i = LIN_ITERATIONCOUNT; 94 } 95 */ 81 } 96 82 } 97 83 98 float r1 = length(x) * ctan(acos(dot(under, xNorm))); 99 float r2 = length(x) * ctan(acos(dot(over, xNorm))); 100 float rl = dUnder; 101 102 float ppp = dOver / readDistanceCubeMap( mp, x); // |p|/|p| 103 float dun = 0, pun = ppp, dov = 0, pov = 0; 104 float dl = rl * ( 1 - ppp ); // eq. 2 105 float3 l = x + R * dl; // ray equation 106 84 float3 dirUn = normalize(under); 85 float3 dirOv = normalize(over); 86 float tun = d / dot(N, dirUn); 87 float pun = tun / length(under); 88 float dun = length(tun * dirUn - x); 89 float tov = d / dot(N, dirOv); 90 float pov = tov / length(over); 91 float dov = length(tov * dirOv - x); 92 float tl = (d - dot(N, over)) / dot(N, under - over); 93 float3 l = over + tl * (under - over); 94 float dl = length(l - x); 95 96 //secant iteration 107 97 for( int i = 0; i < SECANT_ITERATIONCOUNT; i++ ) 108 98 { … … 111 101 { 112 102 dun = dl; pun = llp; // last undershooting 113 dl += ( dov == 0 ) ? rl * ( 1 - llp ) : // eq. 2 114 ( dl - dov ) * ( 1 - llp ) / ( llp - pov ); // eq. 3 103 dl += ( dl - dov ) * ( 1 - llp ) / ( llp - pov ); // eq. 3 115 104 } else if ( llp > 1.001f ) // overshooting 116 105 { 117 106 dov = dl; pov = llp; // last overshooting 118 dl += ( dl - dun ) * ( 1 - llp ) / ( llp - pun );// eq. 3107 dl += ( dl - dun ) * ( 1 - llp ) / ( llp - pun );// eq. 3 119 108 } 120 109 l = x + R * dl; // ray equation 121 110 } 122 111 112 return l; 113 return over; 123 114 return (under + over)/2.0; 124 115 } 116 125 117 126 118 /* -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GlassHead.material
r1691 r1699 144 144 { 145 145 attenuation 0 146 photonmap_resolution 128146 photonmap_resolution 32 147 147 caustic_cubemap_resolution 256 148 148 caustic_map_material GameTools/CauTri
Note: See TracChangeset
for help on using the changeset viewer.