Changeset 1885 for GTP/trunk/App/Demos/Illum/Ogre/Media
- Timestamp:
- 12/13/06 16:36:29 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapot.hlsl
r1882 r1885 333 333 334 334 float4 Color = float4(0, 0, 0, 0); 335 Color = float4( length(IN.cPos), 0,0,length(IN.cPos));335 Color = float4(1.0/length(IN.cPos), length(IN.cPos),0,0); 336 336 return Color; 337 337 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapotNew.hlsl
r1870 r1885 70 70 71 71 void linearSearch( float3 x, float3 R, float3 N, samplerCUBE mp, 72 float min, 72 73 out float3 p, 73 74 out float dl, … … 87 88 dt = max(dt, MIN_LIN_ITERATIONCOUNT); 88 89 dt = 1.0 / dt; 89 90 90 91 float t = 0.01;//dt; 92 if(min > length(x)) 93 { 94 float a = 1; 95 float b = 2 * dot(R, x); 96 float c = dot(x,x) - min * min; 97 98 float dis = b*b - 4*a*c; 99 float t1 = (-b + sqrt(dis))/ 2 * a; 100 float t2 = (-b - sqrt(dis))/ 2 * a; 101 102 if(t1 > 0 && (t2 < 0 || t1 < t2)) 103 t = t1 / ( a + t1); 104 else if(t2 > 0) 105 t = t2 / ( a + t2); 106 } 107 91 108 float pa; 92 109 … … 156 173 samplerCUBE mp3Color, 157 174 samplerCUBE mp3Dist, 175 float min1, 176 float min2, 158 177 out float4 Il, out float3 Nl) 159 178 { 160 179 float dl1 = 0, dp1, llp1, ppp1; 161 180 float3 p1; 162 linearSearch(x, R, N, mp1, p1, dl1, dp1, llp1, ppp1);181 linearSearch(x, R, N, mp1, min1, p1, dl1, dp1, llp1, ppp1); 163 182 float dl2 = 0, dp2, llp2, ppp2; 164 183 float3 p2; 165 linearSearch(x, R, N, mp2, p2, dl2, dp2, llp2, ppp2);184 linearSearch(x, R, N, mp2, min2, p2, dl2, dp2, llp2, ppp2); 166 185 167 186 bool valid1 = dot(p1,p1) != 0; … … 173 192 if(!valid1 && ! valid2) 174 193 { 175 linearSearch(x, R, N, mp3Dist, p, dl, dp, llp, ppp);194 linearSearch(x, R, N, mp3Dist, 0, p, dl, dp, llp, ppp); 176 195 Il.a = 1; 177 196 secantSearch(x, R, mp3Dist, dl, dp, llp, ppp, p); … … 232 251 uniform samplerCUBE NormDistMap2 : register(s3), 233 252 uniform float3 lastCenter, 234 uniform float refIndex) 253 uniform float refIndex, 254 float min1, 255 float min2 256 ) 235 257 { 236 258 float4 Color = float4(1,1,1,1); … … 254 276 float3 Nl; 255 277 float4 Il; 256 float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, Il, Nl);278 float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min1, min2, Il, Nl); 257 279 if(Il.a == 0) 258 280 Il = readCubeMap(CubeMap, l); … … 261 283 } 262 284 285 #define REFRACTION 0 263 286 264 287 float4 MultipleReflectionPS(VertOut IN, … … 269 292 uniform samplerCUBE NormDistMap2 : register(s3), 270 293 uniform float3 lastCenter, 271 uniform float refIndex) 294 uniform float refIndex, 295 float min1, 296 float min2) 272 297 { 273 298 float4 I = float4(0,0,0,0); … … 282 307 V = normalize(V); 283 308 float3 l; 284 float4 Iref r;309 float4 Irefl; 285 310 int depth = 0; 311 312 286 313 while(depth < MAX_RAY_DEPTH) 287 314 { 288 float3 R; 289 //R = normalize(reflect( V, N)); 290 291 292 float ri = refIndex; 293 294 if(dot(V,N) > 0) 295 { 296 ri = 1.0 / ri; 297 N = -N; 298 } 299 R = refract( V, N, ri); 300 if(dot(R,R) == 0) R = reflect( V, N); 301 302 303 float3 Nl; 304 float4 Il; 305 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, Il, Nl); 306 if(Il.a == 0) 307 { 308 depth += 1; 309 } 310 else 311 { 312 I = Il; 313 depth = MAX_RAY_DEPTH; 314 } 315 x = l; 316 N = normalize(Nl); 317 V = R; 318 } 319 if(I.a == 0) 320 I = readCubeMap(CubeMap, l); 321 Irefr = I; 322 323 float4 Irefl; 324 N = normalize(IN.mNormal); 325 x = IN.wPos - lastCenter; 326 V = (IN.wPos - cameraPos); 327 depth = 0; 328 while(depth < MAX_RAY_DEPTH) 329 { 330 float3 R; 315 float3 R; 331 316 R = normalize(reflect( V, N)); 332 317 333 318 float3 Nl; 334 319 float4 Il; 335 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, Il, Nl);320 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min1, min2, Il, Nl); 336 321 if(Il.a == 0) 337 322 { … … 346 331 N = Nl; 347 332 V = R; 333 348 334 } 335 if(I.a == 0) 336 I = readCubeMap(CubeMap, l); 337 Irefl = I; 349 338 350 if(I.a == 0) 351 I = readCubeMap(CubeMap, l); 352 Irefl = I; 353 354 I = Irefl * F + (1.0 - F) * Irefr; 339 if(REFRACTION) 340 { 341 float4 Irefr; 342 N = normalize(IN.mNormal); 343 x = IN.wPos - lastCenter; 344 V = (IN.wPos - cameraPos); 345 depth = 0; 346 while(depth < MAX_RAY_DEPTH) 347 { 348 float3 R; 349 //R = normalize(reflect( V, N)); 350 351 352 float ri = refIndex; 353 354 if(dot(V,N) > 0) 355 { 356 ri = 1.0 / ri; 357 N = -N; 358 } 359 R = refract( V, N, ri); 360 if(dot(R,R) == 0) R = reflect( V, N); 361 362 363 float3 Nl; 364 float4 Il; 365 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min1, min2, Il, Nl); 366 if(Il.a == 0) 367 { 368 depth += 1; 369 } 370 else 371 { 372 I = Il; 373 depth = MAX_RAY_DEPTH; 374 } 375 x = l; 376 N = normalize(Nl); 377 V = R; 378 } 379 380 if(I.a == 0) 381 I = readCubeMap(CubeMap, l); 382 Irefr = I; 383 384 I = Irefl * F + (1.0 - F) * Irefr; 385 } 355 386 return I; 356 387 } … … 364 395 uniform float3 lastCenter, 365 396 uniform float SingleBounce, 366 uniform float refIndex):COLOR 367 { 397 uniform float refIndex, 398 uniform float4 min1, 399 uniform float4 min2 400 ):COLOR 401 { 402 min1.x = 1.0 / min1.x; 403 min2.x = 1.0 / min2.x; 368 404 float4 Color = 1.0; 369 405 if(SingleBounce == 1) 370 Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex );406 Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, min1.x, min2.x); 371 407 else 372 Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex );408 Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, min1.x, min2.x); 373 409 374 410 return Color; -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material
r1882 r1885 131 131 { 132 132 cull_hardware clockwise 133 scene_blend m in134 scene_blend_alpha max133 scene_blend max 134 depth_test off 135 135 136 136 vertex_program_ref DefaultVS … … 155 155 { 156 156 cull_hardware anticlockwise 157 scene_blend m in158 scene_blend_alpha max157 scene_blend max 158 depth_test off 159 159 160 160 vertex_program_ref DefaultVS … … 213 213 layer 1 214 214 texture_unit_id 2 215 get_minmax true 216 min_var_name min1 215 217 update_interval 0 216 218 distance_calc false … … 226 228 layer 2 227 229 texture_unit_id 3 230 get_minmax true 231 min_var_name min2 228 232 update_interval 0 229 233 distance_calc false … … 233 237 render_self true 234 238 self_material NormalDistanceCW 235 } 236 RenderTechnique ColorCubeMap 237 { 238 resolution 1 239 layer 3 240 texture_unit_id 4 241 update_interval 0 242 distance_calc false 243 face_angle_calc false 244 update_all_face true 245 render_env false 246 render_self true 247 self_material DistanceMinMaxCCW 248 } 249 RenderTechnique ColorCubeMap 250 { 251 resolution 1 252 layer 4 253 texture_unit_id 5 254 update_interval 0 255 distance_calc false 256 face_angle_calc false 257 update_all_face true 258 render_env false 259 render_self true 260 self_material DistanceMinMaxCW 261 } 262 239 } 263 240 } 264 241 vertex_program_ref DefaultVS
Note: See TracChangeset
for help on using the changeset viewer.