Changeset 3006 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 10/06/08 03:02:23 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r3003 r3006 62 62 uniform float2 samples[NUM_SAMPLES], 63 63 uniform float3 currentNormal, 64 uniform float 4centerPosition,64 uniform float3 centerPosition, 65 65 float w, 66 66 uniform float3 eyePos, … … 103 103 //if ((texcoord.x <= 1.0f) && (texcoord.x >= 0.0f) && (texcoord.y <= 1.0f) && (texcoord.y >= 0.0f)) ++ numSamples; 104 104 105 // reconstruct world space position from sample 105 ////////// 106 //-- reconstruct world space position from sample 107 106 108 float4 sample = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)); 107 109 const float eyeSpaceDepth = sample.w; … … 118 120 float3 direction_to_sample = vector_to_sample / length_to_sample; 119 121 120 // Angle between current normal and direction to sample controls AO intensity.122 // use angle between current normal and direction to sample controls AO intensity. 121 123 float cos_angle = max(dot(direction_to_sample, currentNormal), 0); 122 124 … … 153 155 uniform sampler2D oldIllumTex, 154 156 const uniform float4x4 oldModelViewProj, 157 const uniform float4x4 modelViewProj, 155 158 uniform float maxDepth, 156 159 uniform float temporalCoherence, … … 166 169 float4 norm = tex2D(normals, IN.texCoord.xy); 167 170 float3 normal = normalize(norm.xyz); 168 // something like a constant ambient term169 const float amb = norm.w;170 171 /// the current view direction172 //float3 viewDir = normalize(IN.view);173 171 174 172 // the w coordinate from the persp. projection 175 173 float w = norm.w; 176 // the current world position 177 const float4 centerPosition2 = tex2D(positions, IN.texCoord.xy); 178 179 /// reconstruct position from the eye space depth 180 float3 viewDir = normalize(IN.view); 181 const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 182 183 float4 centerPosition; 174 175 176 ///////////// 177 //-- reconstruct position from the eye space depth 178 179 float3 viewDir = Interpol(IN.texCoord.xy, bl, br, tl, tr);//IN.view; 180 const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)).w; 181 182 float3 centerPosition; 184 183 centerPosition.xyz = eyePos - viewDir * eyeDepth; 185 186 centerPosition.w = centerPosition2.w; 187 188 // the current color 189 const float4 currentCol = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 190 // the current depth is stored in the w component 191 const float currentDepth = centerPosition.w; 192 193 GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition2, w, eyePos, bl, br, tl, tr); 184 185 //const float3 centerPosition = tex2D(positions, IN.texCoord.xy).xyz; 186 187 188 /////////// 189 //-- compute color bleeding + ao 190 191 GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 194 192 195 193 … … 197 195 //-- compute temporally smoothing 198 196 199 float4 realPos = centerPosition * maxDepth; 200 realPos.w = 1.0f; 201 202 float4 oldPos = mul(oldModelViewProj, realPos); 203 204 const float newDepth = oldPos.z / oldPos.w; 205 206 float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; 207 197 float4 realPos = float4(centerPosition * maxDepth, 1.0f); 198 199 200 // calculcate the current projected depth for next frame 201 float4 currentPos = mul(modelViewProj, realPos); 202 currentPos /= currentPos.w; 203 const float currentDepth = currentPos.z; 204 205 206 /////////// 207 //-- reprojection new frame into old one 208 209 // calculate projected depth 210 float4 projPos = mul(oldModelViewProj, realPos); 211 projPos /= projPos.w; 212 213 // the current depth projected into the old frame 214 const float projDepth = projPos.z; 215 216 // fit from unit cube into 0 .. 1 217 float2 tex = (projPos.xy) * 0.5f + 0.5f; 218 219 // retrieve the sample from the last frame 208 220 float4 oldSsao = tex2D(oldSsaoTex, tex); 209 221 float4 oldIllum = tex2D(oldIllumTex, tex); 210 222 211 223 const float oldDepth = oldSsao.w; 212 const float depthDif = 1.0f - newDepth / oldDepth;224 const float depthDif = 1.0f - projDepth / oldDepth; 213 225 214 226 float oldWeight = clamp(oldSsao.z, 0, temporalCoherence); 227 215 228 float newWeight; 216 229 217 const float oldNumSamples = oldSsao.y;218 const float oldAvgDepth = oldSsao.z;230 //const float oldNumSamples = oldSsao.y; 231 //const float oldAvgDepth = oldSsao.z; 219 232 220 233 if (//(temporalCoherence > 0.0f) && -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3005 r3006 6 6 7 7 8 #define USE_EYE_SPACE_DEPTH 08 #define USE_EYE_SPACE_DEPTH 1 9 9 10 10 … … 71 71 uniform float2 samples[NUM_SAMPLES], 72 72 uniform float3 currentNormal, 73 uniform float 4centerPosition,73 uniform float3 centerPosition, 74 74 uniform float scaleFactor, 75 75 uniform float3 eyePos, … … 161 161 pixel OUT; 162 162 163 float4 norm = tex2D (normals, IN.texCoord.xy);163 float4 norm = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)); 164 164 float3 normal = normalize(norm.xyz); 165 165 166 // a constant ambient term167 const float amb = norm.w;168 166 // the w coordinate from the persp. projection 169 167 float w = norm.w; … … 173 171 /// reconstruct position from the eye space depth 174 172 float3 viewDir = IN.view; 175 const float eyeDepth = tex2D (colors, IN.texCoord.xy).w;176 177 float 4centerPosition;173 const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 174 175 float3 centerPosition; 178 176 centerPosition.xyz = eyePos - viewDir * eyeDepth; 179 centerPosition.w = centerPosition.w;180 177 181 178 const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); … … 183 180 184 181 // the current world position 185 const float 4 centerPosition = tex2D(positions, IN.texCoord.xy);182 const float3 centerPosition = tex2Dlod(positions, float4(IN.texCoord, 0, 0)).xyz; 186 183 187 184 const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); … … 192 189 //-- compute temporally smoothing 193 190 194 float4 realPos = centerPosition * maxDepth; 195 realPos.w = 1.0f; 196 197 // calulcate the current depth 198 //const float currentDepth = centerPosition.w; 199 200 // apply modelview matrix 191 float4 realPos = float4(centerPosition * maxDepth, 1.0f); 192 193 194 // calculcate the current projected depth for next frame 201 195 float4 currentPos = mul(modelViewProj, realPos); 202 196 currentPos /= currentPos.w; … … 217 211 float2 tex = (projPos.xy) * 0.5f + 0.5f; 218 212 219 // optainthe sample from the last frame213 // retrieve the sample from the last frame 220 214 float4 oldCol = tex2D(oldTex, tex); 221 215 222 216 const float oldDepth = oldCol.w; 217 const float depthDif = 1.0f - projDepth / oldDepth; 218 219 223 220 //const float oldNumSamples = oldCol.y; 224 221 const float oldWeight = clamp(oldCol.z, 0, temporalCoherence); 225 226 const float depthDif = 1.0f - projDepth / oldDepth;227 222 228 223 float newWeight; … … 264 259 pixel OUT; 265 260 266 float4 col = tex2Dlod(colors, float4(IN.texCoord .xy, 0, 0));267 float4 ao = tex2D (ssaoTex, IN.texCoord.xy);261 float4 col = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 262 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 268 263 269 264 OUT.illum_col = col * ao.x; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
r3005 r3006 28 28 for(int i = 0; i < 4; ++ i) 29 29 { 30 average += tex2D (colors, IN.texCoord + downSampleOffs[i]);30 average += tex2Dlod(colors, float4(IN.texCoord + downSampleOffs[i],0,0)); 31 31 } 32 32 33 33 average *= 1.0f / 4.0f; 34 34 35 return tex2D(colors, IN.texCoord);//average;35 return average; 36 36 } 37 37
Note: See TracChangeset
for help on using the changeset viewer.