Changeset 3123 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 11/12/08 17:56:47 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3122 r3123 57 57 58 58 59 float BilateralFilter(float2 texCoord,60 float4 ao,61 uniform sampler2D ssaoTex,62 uniform sampler2D normalsTex,63 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES],64 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES],65 float scale)59 float DiscontinuityFilter(float2 texCoord, 60 float4 ao, 61 uniform sampler2D ssaoTex, 62 uniform sampler2D normalsTex, 63 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 64 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES], 65 float scale) 66 66 { 67 67 float average = .0f; … … 76 76 float4 offs; 77 77 float depthFactor; 78 float normalFactor; 78 79 79 80 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) … … 83 84 84 85 sampleNorm = normalize(tex2Dlod(normalsTex, offs).xyz); 85 depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f);86 //sampleNorm = tex2Dlod(normalsTex, offs).xyz;87 86 88 w = filterWeights[i] * max(dot(sampleNorm, norm), 1e-3f) * depthFactor; 87 //depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f); 88 89 depthFactor = max(step(5e-2f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 90 normalFactor = max(step(0.5f, dot(sampleNorm, norm)), 1e-3f); 91 92 w = filterWeights[i] * normalFactor * depthFactor; 93 //w = filterWeights[i] * depthFactor; 89 94 90 95 average += aoSample.x * w; … … 111 116 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 112 117 113 if ((ao.y < 60.0f) && (col.w < 1e10f)) 118 //if ((ao.y < 60.0f) && (col.w < 1e10f)) 119 if (col.w < 1e10f) 114 120 { 115 const static float scaleFactor = 20.0f; 121 //const static float scaleFactor = 10.0f; 122 const static float scaleFactor = 50.0f; 116 123 117 124 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 118 125 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y)); 119 ao.x = BilateralFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y));126 ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y)); 120 127 //ao.x = BilateralFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1.0f); 121 128 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3122 r3123 6 6 7 7 #define USE_EYESPACE_DEPTH 1 8 //#extension GL_EXT_gpu_shader4 : enable9 10 8 11 9 … … 110 108 const float projectedEyeSpaceDepth = invlen * length(translatedPos); 111 109 112 float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 3.0f) ?110 float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 1.0f) ? 113 111 0 : abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 114 112 … … 183 181 184 182 float notValid = 0.5f; 185 //float overallDepth = 0; 183 float overallDepth = 0; 184 186 185 const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z; 187 186 … … 209 208 #endif 210 209 211 //const float clampedOldWeight = clamp(oldPixel.y, .0f, temporalCoherence);212 const float oldWeight = oldPixel.y;210 const float oldWeight = clamp(oldPixel.y, .0f, temporalCoherence); 211 //const float oldWeight = oldPixel.y; 213 212 214 213 float newWeight; … … 225 224 // increase the weight for convergence 226 225 newWeight = oldWeight + 1.0f; 227 //if (notValid > 1.0f) newWeight = 2.0f; 226 //if (notValid > 1.0f) newWeight = 10.0f; 227 //if (notValid > 1.0f) newWeight = max(15.0f - notValid * 2.0f, 1.0f); 228 228 } 229 229 else … … 234 234 //if (oldPixel.y >= 2000) 235 235 // newWeight = min(temporalCoherence + 1, max(oldPixel.y - 70, 50)); 236 if (newWeight >= 2000) newWeight = 1000;236 //if (newWeight >= 2000) newWeight = 1000; 237 237 238 238 return float3(oldPixel.x, newWeight, eyeSpaceDepth); … … 397 397 } 398 398 399 const float clampedWeight = clamp(newWeight, 1, temporalCoherence); 400 401 OUT.illum_col.x = (ao.x + oldSsao * (clampedWeight - 1.0f)) / clampedWeight; 399 OUT.illum_col.x = (ao.x + oldSsao * (newWeight - 1.0f)) / newWeight; 402 400 OUT.illum_col.y = newWeight; 403 401 OUT.illum_col.z = invw;
Note: See TracChangeset
for help on using the changeset viewer.