- Timestamp:
- 11/25/08 18:14:48 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3164 r3167 30 30 uniform sampler2D normalsTex, 31 31 uniform sampler2D colorsTex, 32 uniform float2 filterOffs[NUM_SSAO_FILTER SAMPLES],33 uniform float filterWeights[NUM_SSAO_FILTER SAMPLES],32 uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 33 uniform float filterWeights[NUM_SSAO_FILTER_SAMPLES], 34 34 float scale 35 35 ) … … 40 40 const float eyeSpaceDepth = color.w; 41 41 42 const float3 centerNormal = normalize(tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz); 43 //const float3 centerNormal = tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz; 42 const float3 centerNormal = tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz; 44 43 45 44 float4 aoSample; … … 53 52 float sampleDepth; 54 53 55 for (int i = 0; i < NUM_SSAO_FILTER SAMPLES; ++ i)54 for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 56 55 { 57 56 sampleTexCoord = float4(texCoord + filterOffs[i] * scale, 0, 0); 58 57 59 58 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 60 sampleNorm = normalize(tex2Dlod(normalsTex, sampleTexCoord).xyz); 61 //sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 59 sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 62 60 63 61 // check depth discontinuity … … 96 94 uniform sampler2D normalsTex, 97 95 uniform sampler2D colorsTex, 98 uniform float2 filterOffs[NUM_SSAO_FILTER SAMPLES],96 uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 99 97 float scale, 100 98 float3 bl, … … 107 105 108 106 const float3 centerPos = ReconstructSamplePos(ssaoTex, texCoord, bl, br, tl, tr); 109 const float3 centerNormal = normalize(tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz); 110 //const float3 centerNormal = tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz; 107 const float3 centerNormal = tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz; 111 108 112 109 float4 aoSample; … … 118 115 float normalFactor; 119 116 float convergenceFactor; 120 float sampleDepth;121 122 for (int i = 0; i < NUM_SSAO_FILTER SAMPLES; ++ i)117 float len; 118 119 for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 123 120 { 124 121 sampleTexCoord = float4(texCoord + filterOffs[i] * scale, 0, 0); 125 122 126 123 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 127 sampleNorm = normalize(tex2Dlod(normalsTex, sampleTexCoord).xyz); 128 //sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 124 sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 129 125 130 126 // check spatial discontinuity 131 127 samplePos = ReconstructSamplePos(ssaoTex, sampleTexCoord.xy, bl, br, tl, tr); 132 float len = SqrLen(centerPos - samplePos);128 len = min(SqrLen(centerPos - samplePos), 1e2f); 133 129 134 130 spatialFactor = 1.0f / max(len, 1e-3f); … … 159 155 uniform sampler2D ssaoTex, 160 156 uniform sampler2D normalsTex, 161 uniform float2 filterOffs[NUM_SSAO_FILTER SAMPLES],162 uniform float filterWeights[NUM_SSAO_FILTER SAMPLES],157 uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 158 uniform float filterWeights[NUM_SSAO_FILTER_SAMPLES], 163 159 uniform float4x4 modelViewProj, 164 160 uniform float3 bl, … … 180 176 */ 181 177 178 // filter up to a certain convergance value and leave out background (sky) by checking depth 182 179 if ((ao.y < 100.0f) && (col.w < 1e10f)) 183 180 //if (col.w < 1e10f) … … 189 186 190 187 const float convergence = ao.y; 191 const float adaptWeight = 5.0f;192 const float convergenceScale = adaptWeight / (convergence + adaptWeight);193 194 const float scale = convergenceScale * distanceScale;195 196 188 const float adaptWeight = 25.0f; 189 const float convergenceScale = SSAO_CONVERGENCE_WEIGHT / (convergence + SSAO_CONVERGENCE_WEIGHT); 190 191 const float scale = NUM_SSAO_FILTER_WIDTH * convergenceScale * distanceScale; 192 193 // the filtered ssao value 197 194 ao.x = DiscontinuityFilter2(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr); 198 195 }
Note: See TracChangeset
for help on using the changeset viewer.