Changeset 3134 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 11/18/08 11:28:38 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3133 r3134 16 16 17 17 18 float Filter(float2 texCoord, 19 uniform sampler2D ssaoTex, 20 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 21 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES]) 22 { 23 float average = .0f; 24 float w = .0f; 25 26 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 27 { 28 average += filterWeights[i] * tex2Dlod(ssaoTex, float4(texCoord + filterOffs[i], 0, 0)).x; 29 w += filterWeights[i]; 30 } 31 32 average *= 1.0f / (float)w; 33 34 return average; 18 19 20 inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 21 { 22 float3 x1 = lerp(bl, tl, w.y); 23 float3 x2 = lerp(br, tr, w.y); 24 float3 v = lerp(x1, x2, w.x); 25 26 return v; 27 } 28 29 30 // reconstruct world space position 31 inline float3 ReconstructSamplePos(uniform sampler2D tex, 32 float2 texcoord, 33 float3 bl, float3 br, float3 tl, float3 tr) 34 { 35 const float eyeSpaceDepth = tex2Dlod(tex, float4(texcoord, 0, 0)).w; 36 37 float3 viewVec = Interpol(texcoord, bl, br, tl, tr); 38 float3 samplePos = -viewVec * eyeSpaceDepth; 39 40 return samplePos; 35 41 } 36 42 … … 56 62 } 57 63 64 #define USE_POSITION 58 65 59 66 float DiscontinuityFilter(float2 texCoord, … … 64 71 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES], 65 72 float scale, 66 int index) 73 float3 bl, 74 float3 br, 75 float3 tl, 76 float3 tr) 67 77 { 68 78 float average = .0f; 69 79 float total_w = .0f; 70 80 81 #ifdef USE_POSITION 82 const float3 centerPos = ReconstructSamplePos(ssaoTex, texCoord, bl, br, tl, tr); 83 #else 71 84 const float eyeSpaceDepth = ao.w; 85 #endif 86 72 87 const float3 norm = normalize(tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz); 73 88 74 89 float4 aoSample; 75 90 float3 sampleNorm; 91 float3 samplePos; 76 92 float w; 77 float4 offs;93 float4 sampleTexCoord; 78 94 float depthFactor; 79 95 float normalFactor; 80 float converg anceFactor;96 float convergenceFactor; 81 97 82 98 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 83 99 { 84 offs = float4(texCoord + filterOffs[i] * scale, 0, 0); 85 aoSample = tex2Dlod(ssaoTex, offs); 86 87 sampleNorm = normalize(tex2Dlod(normalsTex, offs).xyz); 88 89 //depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f); 100 sampleTexCoord = float4(texCoord + filterOffs[i] * scale, 0, 0); 101 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 102 sampleNorm = normalize(tex2Dlod(normalsTex, sampleTexCoord).xyz); 103 104 #ifdef USE_POSITION 105 samplePos = ReconstructSamplePos(ssaoTex, sampleTexCoord.xy, bl, br, tl, tr); 106 depthFactor = max(step(1.0f - 5e-1f, 1.0f - length(samplePos - centerPos)), 1e-3f); 107 #else // use depth 90 108 depthFactor = max(step(5e-1f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 109 #endif 91 110 normalFactor = max(step(0.6f, dot(sampleNorm, norm)), 1e-3f); 92 converg anceFactor = max(step(8.5f, aoSample.y), 1e-3f);93 94 //w = filterWeights[i] * normalFactor * depthFactor * converganceFactor;95 w = filterWeights[i];//* normalFactor * converganceFactor;96 //w = filterWeights[i] * depthFactor;97 98 average += aoSample [index]* w;111 convergenceFactor = min(60.0f, aoSample.y) * 0.01f;//max(step(18.5f, aoSample.y), 1e-3f); 112 113 w = filterWeights[i] * normalFactor * depthFactor * convergenceFactor; 114 //w = filterWeights[i] * normalFactor * converganceFactor; 115 //w = filterWeights[i] * normalFactor * depthFactor; 116 117 average += aoSample.x * w; 99 118 total_w += w; 100 119 } … … 112 131 uniform sampler2D offsetTex, 113 132 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 114 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES] 115 ) 133 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES], 134 uniform float3 bl, 135 uniform float3 br, 136 uniform float3 tl, 137 uniform float3 tr) 116 138 { 117 139 pixel OUT; … … 132 154 133 155 float border = step(0.001f, b2 134 135 156 //float3 id = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 136 157 */ … … 155 176 //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, adaptFactor * scaleFactor / (adaptFactor + ao.y), 0); 156 177 157 if (ao.y < 10.5f) ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1, 0);178 if (ao.y < 60.5f) ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor, bl, br, tl, tr); 158 179 //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1, 0); 159 180 } … … 163 184 OUT.illum_col.xyz = col.xyz * ao.x; 164 185 165 // if (ao.y < 1.5f) OUT.illum_col.xyz = float3(10000, 10000, 0);166 // else if (ao.y < 3.5f) OUT.illum_col.xyz = float3(10000, 0, 10000);167 // else186 // if (ao.y < 1.5f) OUT.illum_col.xyz = float3(10000, 10000, 0); 187 // else if (ao.y < 3.5f) OUT.illum_col.xyz = float3(10000, 0, 10000); 188 // else 168 189 // if (ao.y < 10.5f) OUT.illum_col.xyz = float3(0, 10000, 0); 169 190 //OUT.illum_col = float4(dummy3, dummy3, dummy3, col.w); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3104 r3134 291 291 292 292 #endif 293 294 295 float4 Output(fragment IN, uniform sampler2D colors): COLOR 296 { 297 // let bilinear filtering do its work 298 return tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 299 }
Note: See TracChangeset
for help on using the changeset viewer.