Changeset 2991 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 10/02/08 16:34:58 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2990 r2991 64 64 uniform sampler2D positions, 65 65 uniform sampler2D normals, 66 uniform float3 lightDir ,67 uniform sampler2D oldColors66 uniform float3 lightDir 67 //, uniform sampler2D oldColors 68 68 ) 69 69 { … … 83 83 OUT.color = col; 84 84 85 #if 185 #if 0 86 86 87 87 OUT.color.w = color.w; … … 92 92 //-- write out logaritmic luminance for tone mapping 93 93 94 float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 94 // the old loglum is stored in the hightest mipmap-level 95 float oldLogLum = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)).w; 95 96 96 97 const float3 w = float3(0.299f, 0.587f, 0.114f); … … 102 103 float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 103 104 104 if (old Color.w> 0)105 OUT.color.w = lerp(old Color.w, logLumScaled, 0.1f);105 if (oldLogLum > 0) 106 OUT.color.w = lerp(oldLogLum, logLumScaled, 0.1f); 106 107 else 107 108 OUT.color.w = logLumScaled; … … 164 165 uniform sampler2D noiseTexture, 165 166 uniform float2 samples[NUM_PCF_TABS], 166 uniform float3 lightDir ,167 uniform sampler2D oldColors167 uniform float3 lightDir 168 //, uniform sampler2D oldColors 168 169 ) 169 170 { … … 190 191 //if ((emmisive < 1.5f) // hack: prevent shadowing the sky 191 192 if ( 192 (position.w >1e19f)193 (position.w < 1e19f) 193 194 && (angle > 1e-3f) // shadow only if diffuse color has some minimum intensity 194 195 ) … … 216 217 //-- write out logaritmic luminance for tone mapping 217 218 218 float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 219 #if 0 220 221 OUT.color.w = color.w; 222 223 #else 224 225 float oldLogLum = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)).w; 219 226 220 227 const float3 w = float3(0.299f, 0.587f, 0.114f); … … 226 233 float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 227 234 228 if (old Color.w> 0)229 OUT.color.w = lerp(old Color.w, logLumScaled, 0.1f);235 if (oldLogLum > 0) 236 OUT.color.w = lerp(oldLogLum, logLumScaled, 0.1f); 230 237 else 231 238 OUT.color.w = logLumScaled; 232 239 #endif 233 240 return OUT; 234 241 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r2990 r2991 44 44 45 45 46 float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 47 { 48 //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 49 float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 50 float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 51 52 float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 46 47 inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 48 { 49 float3 x1 = lerp(bl, tl, w.y); 50 float3 x2 = lerp(br, tr, w.y); 51 float3 v = lerp(x1, x2, w.x); 53 52 54 53 return v; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2990 r2991 34 34 inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 35 35 { 36 //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 37 float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 38 float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 39 40 float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 36 float3 x1 = lerp(bl, tl, w.y); 37 float3 x2 = lerp(br, tr, w.y); 38 float3 v = lerp(x1, x2, w.x); 41 39 42 40 return v; … … 44 42 45 43 46 inline float3 ReconstructSamplePosition(uniform sampler2D colors, float2 texcoord, float3 bl, float3 br, float3 tl, float3 tr) 44 inline float3 ReconstructSamplePosition(float3 eyePos, 45 uniform sampler2D colors, 46 float2 texcoord, 47 float3 bl, float3 br, float3 tl, float3 tr) 47 48 { 48 49 /*float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; … … 50 51 // reconstruct world space position 51 52 float3 rotView = normalize(Interpol(texcoord, bl, br, tl, tr)); 52 float3 sample_position = eyePos - rotView * eyeSpaceDepth; 53 */ 53 float3 sample_position = eyePos - rotView * eyeSpaceDepth;*/ 54 54 float3 sample_position = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 55 55 … … 102 102 ++ numSamples; 103 103 104 float3 sample_position = ReconstructSamplePosition( colors, texcoord, bl, br, tl, tr);104 float3 sample_position = ReconstructSamplePosition(eyePos, colors, texcoord, bl, br, tl, tr); 105 105 106 106 float3 vector_to_sample = sample_position - centerPosition.xyz; … … 174 174 175 175 //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 176 const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, /*viewDir, */eyePos, bl, br, tl, tr);176 const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 177 177 178 178 … … 208 208 (tex.y >= 0.0f) && (tex.y < 1.0f) && 209 209 (abs(depthDif) < 1e-4f) 210 // check if visibility changed in the surrounding area: 211 // then we have to recompute 212 && ((newWeight < 10) || (oldNumSamples > 0.9f * newNumSamples)) 210 // if visibility changed in the surrounding area we have to recompute 211 && (oldNumSamples > 0.8f * newNumSamples) 213 212 //&& (oldAvgDepth / newAvgDepth > 0.99) 214 213 ) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
r2975 r2991 105 105 return OUT; 106 106 } 107 108 109 pixel CalcAvgLogLum(frag IN, uniform sampler2D colors) 110 { 111 //////////// 112 //-- write out logaritmic luminance for tone mapping 113 114 pixel OUT; 115 116 // the old loglum is stored in the hightest mipmap-level 117 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 118 float oldLogLum = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)).w; 119 120 // the intensity weights 121 const float3 w = float3(0.299f, 0.587f, 0.114f); 122 123 float lum = dot(color.rgb, w); 124 float logLum = log(1e-5f + lum); 125 126 float logLumOffset = MINLOGLUM * INV_LOGLUM_RANGE; 127 float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 128 129 OUT.color = color; 130 131 if (oldLogLum > 0) 132 OUT.color.w = lerp(oldLogLum, logLumScaled, 0.1f); 133 else 134 OUT.color.w = logLumScaled; 135 }
Note: See TracChangeset
for help on using the changeset viewer.