- Timestamp:
- 04/13/09 22:01:56 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3348 r3349 20 20 { 21 21 float4 illum_col: COLOR0; 22 //float4 col: COLOR1;22 float4 col: COLOR1; 23 23 }; 24 24 … … 117 117 const float oldEyeSpaceDepth = oldPixel.w; 118 118 119 // vector from eye pos to old sample 119 // vector from eye pos to old sample 120 120 const float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 121 121 const float invLen = 1.0f / length(viewVec); … … 148 148 149 149 //w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f)); 150 //w = floor(oldPixel.y);151 //w = oldPixel.y;152 idx = floor(oldPixel.y); 150 w = oldPixel.y; 151 idx = floor(oldPixel.z); 152 153 153 } 154 154 else 155 155 { 156 w =.0f;156 w = 0.0f; 157 157 idx = .0f; 158 158 } 159 159 160 return float3(ssao, idx, w);160 return float3(ssao, w, idx); 161 161 } 162 162 … … 201 201 tex2Dlod(samples, float4((0.5f + i + idx) / NUM_PRECOMPUTED_SAMPLES, 0.5f, .0f, .0f)).xy; 202 202 203 204 203 //////////////////// 205 204 //-- add random noise: reflect around random normal vector … … 208 207 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 209 208 { 210 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, .0f, .0f)).xy;209 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 211 210 //offset = myreflect(samples[i], mynoise); 212 211 //offset = myrotate(samples[i], mynoise.x); … … 502 501 #ifdef PERFORMANCE_TEST 503 502 504 float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, .0f, .0f)).xyz;503 float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 505 504 506 505 const float sqrMoveSpeed = SqrLen(diffVec); … … 522 521 const float oldSsao = temporalVals.x; 523 522 524 //float oldIdx = temporalCoherence > 1 ? temporalVals.y : .0f; 525 float oldIdx = temporalVals.y; 526 //float oldWeight = temporalVals.y; 527 float oldWeight = clamp(oldIdx, 0, temporalCoherence); 528 523 float oldWeight = temporalVals.y; 524 float oldIdx = temporalCoherence > 1 ? temporalVals.z : 0; 525 529 526 #else 530 527 531 528 const bool isMovingObject = false; 532 const float oldSsao = .0f;533 534 float oldWeight = .0f;535 float oldIdx = .0f;529 const float oldSsao = 0; 530 531 float oldWeight = 0; 532 float oldIdx = 0; 536 533 537 534 #endif … … 585 582 else if (ao.y > partlyResetThres) 586 583 { 587 //if (oldIdx > 4.0f * NUM_SAMPLES) oldIdx = 0;588 oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); oldIdx = oldWeight;589 //old Weight = oldIdx;//.0f; oldIdx = .0f;584 oldWeight = min(oldWeight, 4.0f * newWeight); 585 //oldWeight = .0f; 586 //oldIdx = .0f; 590 587 } 591 588 } … … 599 596 600 597 // the new weight for the next frame 601 const float newIdx = newWeight + oldIdx; 602 //const float combinedWeight = clamp(newIdx, .0f, temporalCoherence); 603 const float combinedWeight = clamp(newIdx, .0f, min(newWeight + oldWeight, temporalCoherence)); 604 605 //OUT.illum_col.y = combinedWeight; 606 OUT.illum_col.y = newIdx; // the new index 598 const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 599 600 OUT.illum_col.y = combinedWeight; 601 OUT.illum_col.z = oldIdx + newWeight; // the new index 607 602 OUT.illum_col.w = eyeSpaceDepth; 608 603 … … 610 605 611 606 // this value can be used to check if this pixel belongs to a moving object 612 //OUT.col.x = SqrLen(diffVec);613 OUT.illum_col.z = SqrLen(diffVec);607 OUT.col.x = SqrLen(diffVec); 608 //OUT.illum_col.z = SqrLen(diffVec); 614 609 615 610 #else
Note: See TracChangeset
for help on using the changeset viewer.