- Timestamp:
- 12/20/08 09:00:10 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3225 r3226 225 225 total_ao /= numSamples; 226 226 227 #if 1227 #if 0 228 228 // if surface normal perpenticular to view dir, approx. half of the samples will not count 229 229 // => compensate for this (on the other hand, projected sampling area could be larger!) 230 230 const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 231 total_ao += cosAngle * aoContrib *viewCorrection;231 total_ao *= viewCorrection; 232 232 233 233 #endif 234 234 235 return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 235 //return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 236 return float3(total_ao, validSamples, numSamples); 236 237 } 237 238 … … 260 261 float newWeight, 261 262 float sampleIntensity, 262 bool isMovingObject 263 bool isMovingObject, 264 sampler2D normalTex 263 265 ) 264 266 { … … 288 290 289 291 292 // the normal of the current sample 293 //const float3 sampleNormal = tex2Dlod(normalTex, float4(texcoord, 0, 0)).xyz; 294 // angle between current normal and direction to sample controls AO intensity. 295 //float cosAngle2 = .5f + dot(sampleNormal, -normal) * 0.5f; 296 290 297 //////////////// 291 298 //-- compute contribution of sample using the direction and angle … … 303 310 //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 304 311 312 //total_ao += cosAngle2 * cosAngle * aoContrib; 305 313 total_ao += cosAngle * aoContrib; 306 314 … … 318 326 validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid); 319 327 320 #if defUSE_GTX328 #if 1//#ifdef U//USE_GTX 321 329 // we can bail out early and use a minimal #samples) 322 330 // if some conditions are met as long as the hardware supports it … … 343 351 344 352 return float3(total_ao, validSamples, numSamples); 353 //return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 345 354 } 346 355 … … 417 426 if (eyeSpaceDepth < 1e10f) 418 427 { 419 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject );428 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject, normals); 420 429 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 421 430 } … … 446 455 else if (ao.y > partlyResetThres) 447 456 { 448 //oldWeight = min(oldWeight, 4.0f * newWeight);449 oldWeight = .0f;457 oldWeight = min(oldWeight, 4.0f * newWeight); 458 //oldWeight = .0f; 450 459 } 451 460 } … … 458 467 //-- blend ao between old and new samples (and avoid division by zero) 459 468 460 OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight); 469 //OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight); 470 OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / (newWeight + oldWeight); 461 471 462 472 OUT.illum_col.y = combinedWeight;
Note: See TracChangeset
for help on using the changeset viewer.