- Timestamp:
- 12/01/08 18:38:36 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3199 r3203 174 174 float total_ao = .0f; 175 175 float numSamples = .0f; 176 float validSamples = .0f; 176 177 177 178 for (int i = 0; i < NUM_SAMPLES; ++ i) … … 233 234 #endif 234 235 // check if the samples have been valid in the last frame 235 //numSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; 236 validSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; 237 236 238 ++ numSamples; 237 239 } … … 239 241 total_ao /= numSamples; 240 242 241 return float3(max(0.0f, 1.0f - total_ao), .0f, numSamples);243 return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 242 244 } 243 245 … … 287 289 const float2 texcoord = IN.texCoord.xy + offsetTransformed * scaleFactor; 288 290 289 const float4 sampleColor = tex2Dlod(colors, float4(texcoord, 0, 0));291 const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f)); 290 292 const float3 samplePos = ReconstructSamplePos(sampleColor.w, texcoord, bl, br, tl, tr); 291 293 … … 303 305 // angle between current normal and direction to sample controls AO intensity. 304 306 const float cosAngle = max(dot(dirSample, normal), .0f); 305 306 // the distance_scale offset is used to avoid singularity that occurs at global illumination when307 // the distance to a sample approaches zero308 //const float aoContrib = SAMPLE_INTENSITY / (DISTANCE_SCALE + lengthToSample * lengthToSample);309 307 const float aoContrib = SAMPLE_INTENSITY / sqrLen; 310 308 //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; … … 321 319 322 320 // check if the samples have been valid in the last frame 323 validSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; 321 // hack: the distance measure can fail in some cases => choose something different 322 const float tooFarAway = step(1.0f, lengthToSample); 323 validSamples += (1.0f - tooFarAway) * sampleColor.x; 324 324 //validSamples += sampleColor.x; 325 325 326 326 ++ numSamples; 327 //if ((validSamples < 1.0f) && (newWeight > 20) && (numSamples >= 8)) break; 327 328 //if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break; 329 if ((validSamples < 1.0f) && (numSamples >= 8)) break; 328 330 } 329 331 … … 401 403 if (eyeSpaceDepth < 1e10f) 402 404 { 403 //ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight);404 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); 406 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 405 407 } 406 408 else
Note: See TracChangeset
for help on using the changeset viewer.