Changeset 2870
- Timestamp:
- 08/26/08 18:17:06 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2869 r2870 181 181 return float4(total_color, 1.0f - total_ao); 182 182 } 183 184 185 float ComputeSmoothedColor(float4 centerPosition,186 uniform sampler2D oldTex,187 uniform float maxDepth,188 uniform float expFactor,189 const uniform float4x4 oldModelViewProj,190 float4 currentCol191 )192 {193 float4 realPos = centerPosition * maxDepth;194 realPos.w = 1.0f;195 196 float4 oldPos = mul(oldModelViewProj, realPos);197 198 float newDepth = oldPos.z / oldPos.w;199 200 float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f;201 float4 oldCol = tex2D(oldTex, tex);202 203 float oldDepth = oldCol.w;204 float depthDif = 1.0f - newDepth / oldDepth;205 206 float4 col;207 208 if ((tex.x >= 0.0f) && (tex.x < 1.0f) &&209 (tex.y >= 0.0f) && (tex.y < 1.0f) &&210 (abs(depthDif) < 1e-4f))211 {212 col = currentCol * expFactor + oldCol * float4(1.0f - expFactor);213 }214 else215 {216 col = currentCol;217 }218 219 return col;220 }221 183 222 184 … … 251 213 float4 centerPosition = tex2D(positions, IN.texCoord.xy); 252 214 253 float4 col = tex2D(colors, IN.texCoord.xy); 254 float currentDepth = col.w; 215 // the current color 216 float4 currentCol = tex2D(colors, IN.texCoord.xy); 217 float currentDepth = currentCol.w; 255 218 256 219 float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 257 //float4 attenuated_color = ao * col;258 //float4 attenuated_color = ao;259 220 260 221 //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 261 //float4 attenuated_color = ao * col + new_col;262 222 263 223 // compute temporally smoothed color 264 OUT.color = ComputeSmoothedColor(centerPosition, oldTex, maxDepth, expFactor, oldModelViewProj, float4(ao)); 224 float4 realPos = centerPosition * maxDepth; 225 realPos.w = 1.0f; 226 227 float4 oldPos = mul(oldModelViewProj, realPos); 228 229 float newDepth = oldPos.z / oldPos.w; 230 231 float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; 232 float4 oldCol = tex2D(oldTex, tex); 233 234 float oldDepth = oldCol.w; 235 float depthDif = 1.0f - newDepth / oldDepth; 236 237 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 238 (tex.y >= 0.0f) && (tex.y < 1.0f) && 239 (abs(depthDif) < 1e-4f)) 240 { 241 OUT.color = float4(ao * expFactor + oldCol * float4(1.0f - expFactor)); 242 } 243 else 244 { 245 OUT.color = (float4)ao; 246 } 247 265 248 266 249 //OUT.color.xyz = viewDir;
Note: See TracChangeset
for help on using the changeset viewer.