Changeset 2835 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 07/14/08 17:20:08 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2834 r2835 7 7 //#define SAMPLE_INTENSITY 0.125f 8 8 // rule of thumb: approx 1 / NUM_SAMPLES 9 #define SAMPLE_INTENSITY 0. 2//0.0625f9 #define SAMPLE_INTENSITY 0.16 //0.0625f 10 10 11 11 #define AREA_SIZE 5e-1f … … 76 76 77 77 //sample noisetex; r stores costheta, g stores sintheta 78 float2 noise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f;78 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 79 79 80 80 // rotation 81 81 //float2 offsetTransformed = offset; 82 float2 offsetTransformed = rotate(offset, noise);82 float2 offsetTransformed = rotate(offset, mynoise); 83 83 //float2 offsetTransformed = reflect(offset, noise); 84 84 … … 95 95 float cos_angle = dot(direction_to_sample, currentNormal); 96 96 cos_angle = max(cos_angle, 0.0f); 97 // take quadratic influence to sharpen contrast98 //cos_angle *= cos_angle;99 97 100 98 // distance between current position and sample position controls AO intensity. 101 //const float maxdist = 2e-1f;102 //const float maxdist = 5e-1f;103 99 const float distanceScale = 1e-6f; 104 100 … … 107 103 108 104 // if normal perpenticular to view dir, only half of the samples count 109 float view_correction = (2.0f - dot(currentViewDir, currentNormal)); 110 view_correction *= view_correction; 105 float view_correction = 1.0f + 0.5f * (1.0f - dot(currentViewDir, currentNormal)); 111 106 112 107 total_ao += cos_angle * distance_intensity * view_correction; … … 144 139 145 140 //sample noisetex; r stores costheta, g stores sintheta 146 float2 noise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f;141 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 147 142 148 143 // rotation 149 float2 offsetTransformed = rotate(offset, noise);144 float2 offsetTransformed = rotate(offset, mynoise); 150 145 151 146 // weight with projected coordinate to reach similar kernel size for near and far … … 171 166 // if normal perpenticular to view dir, only half of the samples count 172 167 float view_correction = 1.0f + 0.5f * (1.0f - dot(currentViewDir, currentNormal)); 173 //view_correction *= view_correction;174 168 175 169 total_ao += cos_angle * distance_intensity * view_correction; … … 218 212 uniform float noiseMultiplier, 219 213 uniform sampler2D oldTex, 220 const uniform float4x4 oldModelViewProj 214 const uniform float4x4 oldModelViewProj, 215 uniform float maxDepth 221 216 ) 222 217 { … … 236 231 237 232 //float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 238 float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 233 float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 239 234 float ao = new_col.w; 240 235 … … 244 239 //OUT.color = ao; 245 240 //OUT.color = ao * col; 246 float4 dummy = centerPosition / 0.000487676f;241 float4 dummy = centerPosition * maxDepth; 247 242 dummy.w = 1.0f; 248 243 float4 oldPos = mul(oldModelViewProj, dummy); … … 250 245 float newDepth = oldPos.z / oldPos.w; 251 246 252 const float x = 0. 05f;247 const float x = 0.1f; 253 248 254 249 float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; … … 257 252 float oldDepth = col1.w; 258 253 259 if ((tex.x >= 0 ) && (tex.x <= 1) && (tex.y >= 0) && (tex.y <= 1) && (abs(newDepth - oldDepth) < 5e-4f))254 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && (tex.y >= 0.0f) && (tex.y < 1.0f) && (abs(newDepth - oldDepth) < 9e-4f)) 260 255 OUT.color = attenuated_color * x + col1 * float4(1.0f - x); 261 else OUT.color = attenuated_color;// * x + col1 * float4(1.0f - x); 256 else 257 OUT.color = attenuated_color; 262 258 263 259 //OUT.color = float4(centerPosition.w); … … 292 288 float4 col1 = tex2D(oldTex, IN.texCoord.xy); 293 289 294 const float x = 0. 1f;290 const float x = 0.01f; 295 291 OUT.color = col * x + col1 * float4(1.0f - x); 296 292
Note: See TracChangeset
for help on using the changeset viewer.