Changeset 1929 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Timestamp:
- 01/02/07 06:23:48 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Diffuse.hlsl
r1735 r1929 140 140 141 141 } 142 142 /* 143 143 for (float x = 1; x < M; x++) 144 144 for (float y = 1; y < M; y++) … … 239 239 240 240 I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler); 241 } 241 } */ 242 242 float kd = 0.5; 243 243 return kd * I; -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapot.hlsl
r1885 r1929 333 333 334 334 float4 Color = float4(0, 0, 0, 0); 335 Color = float4(1.0/length(IN.cPos), length(IN.cPos),0,0); 335 Color = float4(1.0/length(IN.cPos), length(IN.cPos),0,1); 336 //return 1; 336 337 return Color; 337 338 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapotNew.hlsl
r1897 r1929 13 13 } 14 14 15 #define MAX_LIN_ITERATIONCOUNT 80 //8016 #define MIN_LIN_ITERATIONCOUNT 60 //6015 #define MAX_LIN_ITERATIONCOUNT 20 //80 16 #define MIN_LIN_ITERATIONCOUNT 30 //60 17 17 #define SECANT_ITERATIONCOUNT 2 18 18 #define MAX_RAY_DEPTH 2 … … 70 70 71 71 void linearSearch( float3 x, float3 R, float3 N, samplerCUBE mp, 72 float min,72 float2 minMax, 73 73 out float3 p, 74 74 out float dl, … … 77 77 out float ppp) 78 78 { 79 float3 Ra = abs(R), xa = abs(x);80 float xm = max(max(xa.x,xa.y),xa.z);81 float Rm = max(max(Ra.x,Ra.y),Ra.z);82 float a = xm / Rm;83 79 84 80 int shootL = 0, shootP = 0; 85 81 bool found = false; 86 82 87 float dt = length(x / xm - R / Rm) * MAX_LIN_ITERATIONCOUNT; 88 dt = max(dt, MIN_LIN_ITERATIONCOUNT); 89 dt = 1.0 / dt; 90 91 float t = 0.01; 92 if(min > length(x)) 83 float min = minMax.x; 84 float max = minMax.y; 85 86 float minT = 0; 87 float maxT = 0; 93 88 { 94 95 float a = 1; 89 float a = dot(R,R); 96 90 float b = 2 * dot(R, x); 97 91 float c = dot(x,x) - min * min; 92 float c2 = dot(x,x) - max * max; 98 93 99 94 float dis = b*b - 4*a*c; 95 float dis2 = b*b - 4*a*c2; 96 100 97 float t1 = (-b + sqrt(dis))/ 2.0 * a; 101 98 float t2 = (-b - sqrt(dis))/ 2.0 * a; 102 103 if(t1 > 0 && (t2 < 0 || t1 < t2)) 104 t = 1.0;//t1 / ( a + t1); 105 else if(t2 > 0) 106 t = 1.0;//t2 / ( a + t2); 107 //t = 0.011; 108 } 99 float t3 = (-b + sqrt(dis2))/ 2.0 * a; 100 float t4 = (-b - sqrt(dis2))/ 2.0 * a; 101 102 int numvalids = 0; 103 if(t1 > 0) 104 { 105 numvalids++; 106 if(t1 > maxT)maxT = t1; 107 if(t1 < minT || minT == 0)minT = t1; 108 } 109 if(t2 > 0) 110 { 111 numvalids++; 112 if(t2 > maxT)maxT = t2; 113 if(t2 < minT || minT == 0)minT = t2; 114 } 115 if(t3 > 0) 116 { 117 numvalids++; 118 if(t3 > maxT)maxT = t3; 119 if(t3 < minT || minT == 0)minT = t3; 120 } 121 if(t4 > 0) 122 { 123 numvalids++; 124 if(t4 > maxT)maxT = t4; 125 if(t4 < minT || minT == 0)minT = t4; 126 } 127 128 if(numvalids % 2 == 1) 129 minT = 0.01; 130 if(numvalids == 0) 131 minT = maxT + 1.0; 132 } 109 133 110 134 float pa; 111 135 float dt = (maxT - minT) / MAX_LIN_ITERATIONCOUNT; 136 float t = minT; 112 137 //Linear iteration 113 while(t <= 1.0&& !found)138 while(t <= maxT && !found) 114 139 { 115 dp = a * t / (1 - t);116 p = x + R * dp;140 dp = t; 141 p = x + R * t; 117 142 pa = readDistanceCubeMap(mp, p); 118 143 … … 175 200 samplerCUBE mp3Color, 176 201 samplerCUBE mp3Dist, 177 float min,178 float min1,179 float min2,202 float2 minMax, 203 float2 minMax1, 204 float2 minMax2, 180 205 out float4 Il, out float3 Nl) 181 206 { 182 207 float dl1 = 0, dp1, llp1, ppp1; 183 208 float3 p1; 184 linearSearch(x, R, N, mp1, min 1, p1, dl1, dp1, llp1, ppp1);209 linearSearch(x, R, N, mp1, minMax1, p1, dl1, dp1, llp1, ppp1); 185 210 float dl2 = 0, dp2, llp2, ppp2; 186 211 float3 p2; 187 linearSearch(x, R, N, mp2, min 2, p2, dl2, dp2, llp2, ppp2);212 linearSearch(x, R, N, mp2, minMax2, p2, dl2, dp2, llp2, ppp2); 188 213 189 214 bool valid1 = dot(p1,p1) != 0; … … 195 220 if(!valid1 && ! valid2) 196 221 { 197 linearSearch(x, R, N, mp3Dist, min, p, dl, dp, llp, ppp); 198 Il.a = 1; 199 secantSearch(x, R, mp3Dist, dl, dp, llp, ppp, p); 200 Il.rgb = Nl.rgb = readCubeMap(mp3Color, p).rgb; 222 linearSearch(x, R, N, mp3Dist, minMax, p, dl, dp, llp, ppp); 223 if(dot(p,p) != 0) 224 { 225 Il.a = 1; 226 secantSearch(x, R, mp3Dist, dl, dp, llp, ppp, p); 227 Il.rgb = Nl.rgb = readCubeMap(mp3Color, p).rgb; 228 } 229 else 230 Il = float4(0,0,0,1); 201 231 } 202 232 else … … 255 285 uniform float3 lastCenter, 256 286 uniform float refIndex, 257 float min,258 float min1,259 float min2287 float2 minMax, 288 float2 minMax1, 289 float2 minMax2 260 290 ) 261 291 { … … 270 300 271 301 float3 R; 272 //if(refIndex > 100.0) 273 R = normalize(reflect( V, N)); 274 //else 275 //{ 276 // refIndex = 1.0 / refIndex; 277 // R = normalize(refract( V, N, refIndex)); 278 //} 302 303 R = normalize(reflect( V, N)); 279 304 280 305 float3 Nl; 281 306 float4 Il; 282 float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min , min1, min2, Il, Nl);307 float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, minMax, minMax1, minMax2, Il, Nl); 283 308 if(Il.a == 0) 284 309 Il = readCubeMap(CubeMap, l); … … 297 322 uniform float3 lastCenter, 298 323 uniform float refIndex, 299 float min,300 float min1,301 float min2)324 float2 minMax, 325 float2 minMax1, 326 float2 minMax2) 302 327 { 303 328 float4 I = float4(0,0,0,0); … … 323 348 float3 Nl; 324 349 float4 Il; 325 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min , min1, min2, Il, Nl);350 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, minMax, minMax1, minMax2, Il, Nl); 326 351 if(Il.a == 0) 327 352 { … … 368 393 float3 Nl; 369 394 float4 Il; 370 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min , min1, min2, Il, Nl);395 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, minMax, minMax1, minMax2, Il, Nl); 371 396 if(Il.a == 0) 372 397 { … … 401 426 uniform float SingleBounce, 402 427 uniform float refIndex, 403 uniform float4 min ,404 uniform float4 min 1,405 uniform float4 min 2428 uniform float4 minmax, 429 uniform float4 minmax1, 430 uniform float4 minmax2 406 431 ):COLOR 407 432 { 408 // min1.x = 1.0 / min1.x; 409 // min2.x = 1.0 / min2.x; 433 float2 miniMaxi1; 434 miniMaxi1.x = 1.0 / minmax.x / sqrt(2.0); 435 miniMaxi1.y = minmax.y; 436 437 float2 miniMaxi2; 438 miniMaxi2.x = 1.0 / minmax1.x / sqrt(2.0); 439 miniMaxi2.y = minmax1.y; 440 441 float2 miniMaxi3; 442 miniMaxi3.x = 1.0 / minmax2.x / sqrt(2.0); 443 miniMaxi3.y = minmax2.y; 444 410 445 float4 Color = 1.0; 411 446 if(SingleBounce == 1) 412 Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, min .w, min1.w, min2.w);447 Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, miniMaxi1, miniMaxi2, miniMaxi3); 413 448 else 414 Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, min .w, min1.w, min2.w);449 Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, miniMaxi1, miniMaxi2, miniMaxi3); 415 450 416 451 return Color;
Note: See TracChangeset
for help on using the changeset viewer.