Changeset 1854 for GTP/trunk/App/Demos/Illum
- Timestamp:
- 12/05/06 12:01:00 (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/MetalTeapot.hlsl
r1853 r1854 175 175 //Metal 176 176 ////////////// 177 voidMetal1BouncePS( VertOut IN,177 float4 Metal1BouncePS( VertOut IN, 178 178 uniform float3 cameraPos, 179 179 uniform samplerCUBE CubeMap : register(s0), 180 180 uniform samplerCUBE DistanceMap : register(s1), 181 uniform float3 lastCenter, 182 uniform float3 lightPosition, 183 out float4 Color :COLOR0) 184 { 185 186 Color = float4(1,1,1,1); 181 uniform float3 lastCenter):COLOR0 182 { 183 184 float4 Color = float4(1,1,1,1); 187 185 188 186 IN.mNormal = normalize(IN.mNormal); … … 211 209 } 212 210 213 Color = Color * float4(F,1); 211 Color = Color * float4(F,1); 212 213 return Color; 214 214 } 215 215 … … 222 222 uniform samplerCUBE NormDistMap2 : register(s3), 223 223 uniform float3 lastCenter, 224 uniform float SingleBounce, 224 225 out float4 Color :COLOR0) 225 226 { 226 227 Color = float4(1,1,1,1); 228 229 IN.mNormal = normalize(IN.mNormal); 230 float3 newTexCoord; 231 float3 mPos = IN.wPos - lastCenter; 232 float3 V = (IN.wPos - cameraPos); 233 float cameraDistace = length(V); 234 V = normalize(V); 235 float3 R = normalize(reflect( V, IN.mNormal)); 236 //float3 R = normalize(refract( V, IN.mNormal, 0.98)); 237 238 newTexCoord = R; 239 240 //Color = readCubeMap(NormDistMap1, mPos ); 241 //return; 242 243 244 float3 newDir1; 245 float d1 = Hit(mPos, R, NormDistMap1, newDir1); 246 float3 normal1 = readCubeMap(NormDistMap1, newDir1); 247 bool valid1 = dot(normal1, R) < 0 && dot(newDir1,newDir1) != 0; 248 if(valid1) 249 newDir1 = 0; 250 float3 newDir2; 251 float d2 = Hit(mPos, R, NormDistMap2, newDir2); 252 float3 normal2 = readCubeMap(NormDistMap2, newDir2); 253 bool valid2 = dot(normal2, R) < 0 && dot(newDir2,newDir2) != 0; 254 if(valid2) 255 newDir2 = 0; 256 257 if( !valid1 && !valid2) 258 { 259 Hit(mPos, R, DistanceMap, newTexCoord); 260 Color = readCubeMap(CubeMap, newTexCoord ); 261 //Color = 1; 227 if(SingleBounce == 1) 228 Color = Metal1BouncePS(IN,cameraPos,CubeMap,DistanceMap,lastCenter); 229 else 230 { 231 Color = float4(1,1,1,1); 232 233 IN.mNormal = normalize(IN.mNormal); 234 float3 newTexCoord; 235 float3 mPos = IN.wPos - lastCenter; 236 float3 V = (IN.wPos - cameraPos); 237 float cameraDistace = length(V); 238 V = normalize(V); 239 float3 R = normalize(reflect( V, IN.mNormal)); 240 //float3 R = normalize(refract( V, IN.mNormal, 0.98)); 241 242 newTexCoord = R; 243 244 //Color = readCubeMap(NormDistMap1, mPos ); 245 //return; 246 247 248 float3 newDir1; 249 float d1 = Hit(mPos, R, NormDistMap1, newDir1); 250 float3 normal1 = readCubeMap(NormDistMap1, newDir1); 251 bool valid1 = dot(normal1, R) < 0 && dot(newDir1,newDir1) != 0; 252 if(valid1) 253 newDir1 = 0; 254 float3 newDir2; 255 float d2 = Hit(mPos, R, NormDistMap2, newDir2); 256 float3 normal2 = readCubeMap(NormDistMap2, newDir2); 257 bool valid2 = dot(normal2, R) < 0 && dot(newDir2,newDir2) != 0; 258 if(valid2) 259 newDir2 = 0; 260 261 if( !valid1 && !valid2) 262 { 263 Hit(mPos, R, DistanceMap, newTexCoord); 264 Color = readCubeMap(CubeMap, newTexCoord ); 265 //Color = 1; 266 } 267 else 268 { 269 float d; 270 float3 newN; 271 272 d = d2; 273 newN = normal2; 274 275 Color = float4(0,0,1,1); 276 if( !valid2 || (valid1 && d1 < d2) ) 277 { 278 d = d1; 279 newN = normal1; 280 Color = float4(0,1,0,1); 281 } 282 283 float3 newV = R; 284 float3 newX = mPos + R * d; 285 float3 newR = normalize(reflect( newV, newN)); 286 // float3 newR = normalize(refract( newV, newN, 0.98)); 287 288 Hit(newX, newR, DistanceMap, newTexCoord); 289 Color = readCubeMap(CubeMap, newTexCoord ); 290 //Color = float4(newR,1); 291 //Color = float4(1,0,0,1); 292 } 293 294 /* 295 return; 296 297 float ctheta_in = dot(IN.mNormal,R); 298 float ctheta_out = dot(IN.mNormal,-V); 299 300 float3 F = 0; 301 302 // F,P,G számítása 303 if ( ctheta_in > 0 && ctheta_out > 0 ) 304 { 305 float3 H = normalize(R - V); // felezõvektor 306 float cbeta = dot(H,R); 307 F = F0 + (1-F0)*pow(1-cbeta,5); 308 } 309 310 Color = Color * float4(F,1); */ 262 311 } 263 else264 {265 float d;266 float3 newN;267 268 d = d2;269 newN = normal2;270 271 Color = float4(0,0,1,1);272 if( !valid2 || (valid1 && d1 < d2) )273 {274 d = d1;275 newN = normal1;276 Color = float4(0,1,0,1);277 }278 279 float3 newV = R;280 float3 newX = mPos + R * d;281 float3 newR = normalize(reflect( newV, newN));282 // float3 newR = normalize(refract( newV, newN, 0.98));283 284 Hit(newX, newR, DistanceMap, newTexCoord);285 Color = readCubeMap(CubeMap, newTexCoord );286 //Color = float4(newR,1);287 //Color = float4(1,0,0,1);288 }289 290 /*291 float3 newDir2;292 float d2 = Hit(mPos, R, NormDistMap2, newDir2);293 float3 normal2 = readCubeMap(NormDistMap2, newDir2);294 bool valid2 = dot(normal2, R) < 0 && dot(newDir2,newDir2) != 0;295 if(valid2)296 newDir2 = 0;297 if(valid2)298 {299 float d;300 float3 newN;301 d = d2;302 newN = normal2;303 float3 newV = R;304 float3 newX = mPos + R * d;305 float3 newR = normalize(reflect( newV, newN));306 307 Hit(newX, newR, DistanceMap, newTexCoord);308 Color = readCubeMap(CubeMap, newTexCoord );309 }310 else311 {312 Hit(mPos, R, DistanceMap, newTexCoord);313 Color = readCubeMap(CubeMap, newTexCoord );314 }315 */316 return;317 318 float ctheta_in = dot(IN.mNormal,R);319 float ctheta_out = dot(IN.mNormal,-V);320 321 float3 F = 0;322 323 // F,P,G számítása324 if ( ctheta_in > 0 && ctheta_out > 0 )325 {326 float3 H = normalize(R - V); // felezõvektor327 float cbeta = dot(H,R);328 F = F0 + (1-F0)*pow(1-cbeta,5);329 }330 331 Color = Color * float4(F,1);332 312 } 333 313 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material
r1735 r1854 190 190 //param_named n float3 0.21 0.96 1.17 191 191 //param_named k float3 4.16 2.57 2.32 192 param_named F0 float3 0.95 0.95 0.95 192 param_named F0 float3 0.95 0.95 0.95 193 param_named SingleBounce float 0.0 193 194 } 194 195
Note: See TracChangeset
for help on using the changeset viewer.