- Timestamp:
- 02/20/09 19:26:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3322 r3324 77 77 weight of the pixel in the new frame. 78 78 */ 79 inline float 2Reproject(float4 worldPos,80 81 82 83 84 85 86 87 88 89 90 91 92 93 79 inline float3 Reproject(float4 worldPos, 80 float eyeSpaceDepth, 81 float2 texcoord0, 82 float3 oldEyePos, 83 sampler2D oldTex, 84 float4x4 oldModelViewProj, 85 sampler2D colors, 86 float3 projPos, 87 float invW, 88 float3 oldbl, 89 float3 oldbr, 90 float3 oldtl, 91 float3 oldtr, 92 float3 diffVec 93 ) 94 94 { 95 95 // compute position from old frame for dynamic objects + translational portion … … 125 125 // the weight of the accumulated samples from the previous frames 126 126 float w; 127 128 float idx = oldPixel.z; 127 129 128 130 ////////////// … … 151 153 } 152 154 153 return float 2(ssao, w);155 return float3(ssao, w, idx); 154 156 } 155 157 … … 167 169 sampler2D colors, 168 170 sampler2D noiseTex, 169 float2 samples[NUM_SAMPLES],171 sampler2D samples, 170 172 float3 normal, 171 173 float3 centerPosition, … … 179 181 float sampleIntensity, 180 182 bool isMovingObject, 181 sampler2D normalTex 183 sampler2D normalTex, 184 int idx 182 185 ) 183 186 { … … 190 193 float2 offset; 191 194 195 const float2 ssaoOffset = tex2Dlod(samples, float4((0.5f + i + idx) / NUM_PRECOMPUTED_SAMPLES, 0.5f, .0f, .0f)).xy; 196 197 192 198 //////////////////// 193 199 //-- add random noise: reflect around random normal vector 194 200 //-- (affects performance for some reason!) 195 201 196 if ( 1)//convergence < SSAO_CONVERGENCE_THRESHOLD)202 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 197 203 { 198 204 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 199 205 //offset = myreflect(samples[i], mynoise); 200 offset = myrotate(samples[i], mynoise.x); 206 //offset = myrotate(samples[i], mynoise.x); 207 offset = myrotate(ssaoOffset, mynoise.x); 201 208 } 202 209 else 203 210 { 204 offset = s amples[i];211 offset = ssaoOffset; 205 212 } 206 213 … … 441 448 uniform sampler2D normals, 442 449 uniform sampler2D noiseTex, 443 uniform float2 samples[NUM_SAMPLES],450 uniform sampler2D samples, 444 451 uniform sampler2D oldTex, 445 452 uniform float4x4 modelViewProj, … … 488 495 //-- compute temporal reprojection 489 496 490 float 2temporalVals = Reproject(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos,497 float3 temporalVals = Reproject(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 491 498 oldTex, oldModelViewProj, 492 499 colors, … … 499 506 const float oldSsao = temporalVals.x; 500 507 float oldWeight = temporalVals.y; 501 508 float oldIdx = temporalVals.z; 509 502 510 float3 ao; 503 511 … … 506 514 { 507 515 //ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject); 508 ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject, normals );516 ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject, normals, oldIdx); 509 517 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 510 518 } … … 552 560 OUT.illum_col.y = combinedWeight; 553 561 // can be used to check if this pixel belongs to a moving object 554 OUT.illum_col.z = SqrLen(diffVec); 562 //OUT.illum_col.z = SqrLen(diffVec); 563 OUT.illum_col.z = oldIdx + newWeight; 555 564 OUT.illum_col.w = eyeSpaceDepth; 556 565
Note: See TracChangeset
for help on using the changeset viewer.