/** Computes the temporally smoothed indirect illumination buffer and combines it with the color buffer */ pixel main(fragment IN, uniform sampler2D colors, uniform sampler2D ssao, uniform sampler2D oldssao, uniform sampler2D positions const uniform float4x4 oldModelViewProj, uniform float maxDepth, uniform float expFactor ) { pixel OUT; float4 centerPosition = tex2D(positions, IN.texCoord.xy); float4 col = tex2D(colors, IN.texCoord.xy); float ao = tex2D(ssao, IN.texCoord.xy); float4 attenuated_color = ao * col; //float4 attenuated_color = ao; //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); //float4 attenuated_color = ao * col + new_col; const float x = expFactor; float4 dummy = centerPosition * maxDepth; dummy.w = 1.0f; float4 oldPos = mul(oldModelViewProj, dummy); float newDepth = oldPos.z / oldPos.w; float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; float4 col1 = tex2D(oldTex, tex); float oldDepth = col1.w; float depthDif = 1.0f - newDepth / oldDepth; if ((tex.x >= 0.0f) && (tex.x < 1.0f) && (tex.y >= 0.0f) && (tex.y < 1.0f) && (abs(depthDif) < 1e-4f)) { OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); } else { OUT.color = attenuated_color; } //OUT.color.xyz = viewDir; //OUT.color = attenuated_color; //OUT.color.w = tex2D(colors, IN.texCoord.xy).w; return OUT; }