Changeset 3158 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 11/24/08 18:03:45 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3157 r3158 61 61 } 62 62 63 64 inline float ComputeDifference(float2 offset,65 sampler2D oldTex,66 float4x4 oldModelViewProj,67 sampler2D colors,68 sampler2D noiseTex,69 float scaleFactor,70 float3 bl,71 float3 br,72 float3 tl,73 float3 tr,74 float2 texcoord0,75 float3 oldEyePos,76 float3 oldbl,77 float3 oldbr,78 float3 oldtl,79 float3 oldtr,80 float eyeSpaceDepth81 )82 {83 const float2 mynoise = tex2Dlod(noiseTex, float4(texcoord0, 0, 0)).xy;84 85 const float2 offsetTransformed = myreflect(offset, mynoise);86 float2 texCoord = texcoord0 + offsetTransformed * scaleFactor;87 88 const float sampleEyeSpaceDepth = tex2Dlod(colors, float4(texCoord, 0, 0)).w;89 90 const float3 viewVec = Interpol(texCoord, bl, br, tl, tr);91 const float3 samplePos = -viewVec * sampleEyeSpaceDepth;92 const float3 translatedPos = samplePos - oldEyePos;93 94 // reproject into old frame and calculate projected depth95 float4 projPos = mul(oldModelViewProj, float4(translatedPos, 1.0f));96 projPos /= projPos.w;97 // fit from unit cube into 0 .. 198 const float2 oldTexCoords = projPos.xy * 0.5f + 0.5f;99 // retrieve the sample from the last frame100 const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f));101 // the eye linear depth from the previous frame102 const float oldEyeSpaceDepth = oldPixel.w;103 104 // projected linear depth105 const float3 oldViewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);106 const float invlen = 1.0f / length(oldViewVec);107 const float projectedEyeSpaceDepth = invlen * length(translatedPos);108 109 float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 1.0f) ?110 0 : abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth);111 112 return depthDif;113 }114 63 115 64
Note: See TracChangeset
for help on using the changeset viewer.