Changeset 3212 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 12/07/08 23:26:00 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3209 r3212 125 125 126 126 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 127 //sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 128 127 129 128 // check spatial discontinuity 130 129 // note: using the depth from the color texture is not 100% correct as depth was … … 136 135 spatialFactor = 1.0f / max(len, 1e-3f); 137 136 137 convergenceFactor = aoSample.y + 1.0f; 138 139 //sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 138 140 //normalFactor = max(step(.2f, dot(sampleNorm, centerNormal)), 1e-2f); 139 convergenceFactor = aoSample.y + 1.0f; 140 141 141 142 // combine the weights 142 143 w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor; … … 232 233 return OUT; 233 234 } 234 235 236 /** Function combining image and indirect illumination buffer using a237 depth and normal aware discontinuity filter.238 */239 pixel SmoothSsao(fragment IN,240 uniform sampler2D ssaoTex)241 {242 pixel OUT;243 244 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0));245 246 float4 dummy;247 const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f;248 249 // get positions exactly between old texel centers250 dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).y;251 dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).y;252 dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).y;253 dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).y;254 255 const float m1 = min(dummy.x, dummy.y);256 const float m2 = min(dummy.z, dummy.w);257 258 ao.y = min(ao.y, min(m1, m2));259 260 return OUT;261 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3210 r3212 261 261 const bool oldDynamic = (squaredLen > DYNAMIC_OBJECTS_THRESHOLD); 262 262 const bool newDynamic = (oldPixel.z > DYNAMIC_OBJECTS_THRESHOLD); 263 264 //const float xOffs = 1.0f / 1024.0f; const float yOffs = 1.0f / 768.0f;265 //const float eps = 1e-6f;266 263 267 264 // actually 0 means pixel is valid … … 334 331 pix.color = color; 335 332 pix.color.xy = pValid.xy; 333 pix.color.z = color.w; 334 336 335 pix.normal = normal; 337 336 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r3168 r3212 65 65 uniform float3 br, 66 66 uniform float3 tl, 67 uniform float3 tr 68 , uniform float3 viewDir 67 uniform float3 tr, 68 float3 viewDir, 69 float sampleIntensity 69 70 ) 70 71 { … … 125 126 const float denom = (DISTANCE_SCALE + magSample * magSample); 126 127 127 float2 intensity = float2( SAMPLE_INTENSITY, ILLUM_INTENSITY);128 float2 intensity = float2(sampleIntensity, ILLUM_INTENSITY); 128 129 intensity /= denom; 129 130 … … 161 162 uniform float3 br, 162 163 uniform float3 tl, 163 uniform float3 tr 164 uniform float3 tr, 165 uniform float kernelRadius, 166 uniform float sampleIntensity 164 167 ) 165 168 { 166 169 pixel2 OUT; 167 170 168 const float3 normal = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)) ;171 const float3 normal = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)).xyz; 169 172 170 173 … … 180 183 float4 currentPos = mul(modelViewProj, eyeSpacePos); 181 184 182 const float w = SAMPLE_RADIUS/ currentPos.w;185 const float w = kernelRadius / currentPos.w; 183 186 currentPos /= currentPos.w; 184 187 … … 188 191 //-- compute color bleeding + ao 189 192 190 GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(IN.view) );193 GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(IN.view), sampleIntensity); 191 194 192 195 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3209 r3212 108 108 const float ssao = oldPixel.x; 109 109 110 #if USE_EYESPACE_DEPTH111 112 110 // calculate eye space position of sample in old frame 113 111 const float oldEyeSpaceDepth = oldPixel.w; … … 120 118 121 119 const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 122 123 #else124 125 // calculate eye space position of sample in old frame126 const float oldDepth = oldPixel.w;127 // the depth projected into the old frame128 const float projectedDepth = projPos.z;129 // calculate depth difference130 const float depthDif = abs(projectedDepth - oldDepth);131 132 #endif133 120 134 121 const float xOffs = 1.0f / 1024.0f; … … 176 163 float3 tr, 177 164 float3 viewDir, 178 sampler2D normalTex 165 sampler2D normalTex, 166 float sampleIntensity 179 167 ) 180 168 { … … 224 212 cosAngle *= step(0.0f, dot(dirSample, normal)); 225 213 226 const float aoContrib = SAMPLE_INTENSITY/ sqrLen;214 const float aoContrib = sampleIntensity / sqrLen; 227 215 //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 228 216 … … 270 258 float3 viewDir, 271 259 float newWeight, 272 bool isMovingObject260 float sampleIntensity 273 261 ) 274 262 { … … 310 298 // angle between current normal and direction to sample controls AO intensity. 311 299 const float cosAngle = max(dot(dirSample, normal), .0f); 312 const float aoContrib = SAMPLE_INTENSITY/ sqrLen;300 const float aoContrib = sampleIntensity / sqrLen; 313 301 //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 314 302 … … 338 326 339 327 //if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break; 340 if ((validSamples < 1.0f) && (numSamples >= 8) && !isMovingObject 341 || (newWeight > NUM_SAMPLES * 5) && (numSamples >= 8) && isMovingObject 342 ) 343 { 344 break; 345 } 328 //if ((validSamples < 1.0f) && (numSamples >= 8)) break; 346 329 } 347 330 348 331 total_ao /= numSamples; 349 332 350 //return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 351 return float3(total_ao, validSamples, numSamples); 333 return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 352 334 } 353 335 … … 374 356 uniform float3 oldtl, 375 357 uniform float3 oldtr, 376 uniform sampler2D attribsTex 358 uniform sampler2D attribsTex, 359 uniform float kernelRadius, 360 uniform float sampleIntensity 377 361 ) 378 362 { … … 396 380 const float invw = 1.0f / projPos.w; 397 381 projPos *= invw; 398 float scaleFactor = SAMPLE_RADIUS * invw; 399 400 const float sqrMoveSpeed = SqrLen(diffVec); 401 const bool isMovingObject = (sqrMoveSpeed > DYNAMIC_OBJECTS_THRESHOLD); 382 float scaleFactor = kernelRadius * invw; 402 383 403 384 … … 422 403 if (eyeSpaceDepth < 1e10f) 423 404 { 424 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, isMovingObject);425 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals );405 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity); 406 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 426 407 } 427 408 else … … 430 411 } 431 412 432 // equals the number of sampled shot in this pass 433 const float newWeight = ao.z; 413 const float squaredLen = SqrLen(diffVec); 434 414 435 415 // check if we have to reset pixel because one of the sample points was invalid 436 if (!isMovingObject) 437 //if (sqrMoveSpeed <= DYNAMIC_OBJECTS_THRESHOLD) 416 if (squaredLen < DYNAMIC_OBJECTS_THRESHOLD) 438 417 { 439 418 if (ao.y > 4.0f) 440 419 oldWeight = 0; 441 420 else if (ao.y > 1.0f) 442 oldWeight = min(oldWeight, 4.0f * newWeight); 443 } 444 421 oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); 422 } 423 424 const float newWeight = ao.z; 445 425 const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 446 426
Note: See TracChangeset
for help on using the changeset viewer.