- Timestamp:
- 11/16/08 03:46:19 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3126 r3128 63 63 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 64 64 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES], 65 float scale) 65 float scale, 66 int index) 66 67 { 67 68 float average = .0f; … … 86 87 87 88 //depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f); 88 89 89 depthFactor = max(step(5e-2f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 90 90 normalFactor = max(step(0.5f, dot(sampleNorm, norm)), 1e-3f); … … 93 93 //w = filterWeights[i] * depthFactor; 94 94 95 average += aoSample .x* w;95 average += aoSample[index] * w; 96 96 total_w += w; 97 97 } … … 119 119 if (col.w < 1e10f) 120 120 { 121 //const static float scaleFactor = 10.0f; 122 const static float scaleFactor = 50.0f; 121 //const static float scaleFactor = 50.0f; 122 const static float scaleFactor = 10.0f; 123 const static float adaptFactor = 10.0f; 123 124 124 125 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 125 126 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y)); 126 127 //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y)); 127 ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1.0f);128 } 129 130 OUT.illum_col = col* ao.x;128 ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, adaptFactor * scaleFactor * ao.z / (adaptFactor + ao.y), 0); 129 } 130 131 OUT.illum_col.xyz = col.xyz * ao.x; 131 132 //OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 132 133 //OUT.illum_col.xyz = float3(1.0f - ao.x, 1.0f - ao.y * 1e-2f, 1); … … 135 136 return OUT; 136 137 } 138 139 float DiscontinuityFilter2(float2 texCoord, 140 float4 ao, 141 uniform sampler2D ssaoTex, 142 uniform sampler2D normalsTex, 143 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 144 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES], 145 float scale, 146 int index) 147 { 148 float average = .0f; 149 float total_w = .0f; 150 151 const float eyeSpaceDepth = ao.w; 152 const float3 norm = normalize(tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz); 153 154 float4 aoSample; 155 float3 sampleNorm; 156 float w; 157 float4 offs; 158 float depthFactor; 159 float normalFactor; 160 161 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 162 { 163 offs = float4(texCoord + filterOffs[i] * scale, 0, 0); 164 aoSample = tex2Dlod(ssaoTex, offs); 165 166 sampleNorm = normalize(tex2Dlod(normalsTex, offs).xyz); 167 168 //depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f); 169 depthFactor = max(step(5e-2f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 170 normalFactor = max(step(0.5f, dot(sampleNorm, norm)), 1e-3f); 171 172 w = filterWeights[i] * normalFactor * depthFactor; 173 //w = filterWeights[i] * depthFactor; 174 175 average += aoSample.y * w; 176 total_w += w; 177 } 178 179 average *= 1.0f / max(total_w, 1e-6f); 180 181 return average; 182 } 183 184 pixel smoothSsao(fragment IN, 185 uniform sampler2D ssaoTex, 186 uniform sampler2D normalsTex, 187 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 188 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES] 189 ) 190 { 191 pixel OUT; 192 193 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 194 195 //const static float scaleFactor = 10.0f; 196 const static float scaleFactor = 10.0f; 197 198 ao.y = DiscontinuityFilter2(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor * ao.z, 1); 199 200 OUT.illum_col = ao; 201 202 return OUT; 203 }
Note: See TracChangeset
for help on using the changeset viewer.