Changeset 2837 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 07/15/08 11:35:23 (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/deferred.cg
r2836 r2837 5 5 //#define NUM_SAMPLES 8 6 6 #define NUM_SAMPLES 16 7 8 // rule of thumb: approx 1 / NUM_SAMPLES 9 #define SAMPLE_INTENSITY 0.2 7 10 //#define SAMPLE_INTENSITY 0.125f 8 // rule of thumb: approx 1 / NUM_SAMPLES9 #define SAMPLE_INTENSITY 0.22 //0.0625f10 11 11 12 #define AREA_SIZE 5e-1f 12 13 #define VIEW_CORRECTION_SCALE 0.3f 14 #define DISTANCE_SCALE 1e-6f 13 15 14 16 struct fragment … … 23 25 struct pixel 24 26 { 25 27 float4 color: COLOR0; 26 28 }; 27 29 … … 96 98 97 99 // distance between current position and sample position controls AO intensity. 98 const float distanceScale = 1e-6f;99 100 100 float distance_intensity = 101 (SAMPLE_INTENSITY * distanceScale) / (distanceScale+ length_to_sample * length_to_sample);101 (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 102 102 103 103 // if normal perpenticular to view dir, only half of the samples count 104 float view_correction = 1.0f + 0.5f* (1.0f - dot(currentViewDir, currentNormal));104 float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 105 105 106 106 total_ao += cos_angle * distance_intensity * view_correction; … … 119 119 uniform float3 currentViewDir, 120 120 uniform float noiseMultiplier, 121 uniform float4 centerPosition) 121 uniform float4 centerPosition 122 ) 122 123 { 123 124 // the w coordinate from the persp. projection … … 158 159 159 160 // distance between current position and sample position controls AO intensity. 160 const float distanceScale = 1e-6f;161 162 161 float distance_intensity = 163 (SAMPLE_INTENSITY * distanceScale) / (distanceScale + length_to_sample * length_to_sample); 164 165 const float view_correction_scale = 0.5f; 162 (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 163 166 164 // if normal perpenticular to view dir, only half of the samples count 167 float view_correction = 1.0f + view_correction_scale* (1.0f - dot(currentViewDir, currentNormal));165 float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 168 166 169 167 total_ao += cos_angle * distance_intensity * view_correction; … … 213 211 uniform sampler2D oldTex, 214 212 const uniform float4x4 oldModelViewProj, 215 uniform float maxDepth 213 uniform float maxDepth, 214 uniform float expFactor 216 215 ) 217 216 { … … 230 229 float4 col = shade(IN, colors, positions, normal.xyz, amb); 231 230 232 //float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 233 float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 234 float ao = new_col.w; 235 236 float4 attenuated_color = ao * col + new_col; 237 //float4 attenuated_color = ao * col; 238 239 //OUT.color = ao; 240 //OUT.color = ao * col; 241 //float4 col1 = attenuated_color; 242 243 const float x = 0.1f; 231 float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 232 float4 attenuated_color = ao * col; 233 234 //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 235 //float ao = new_col.w; 236 //float4 attenuated_color = ao * col + new_col; 237 238 const float x = expFactor; 244 239 245 240 float4 dummy = centerPosition * maxDepth; … … 254 249 255 250 float oldDepth = col1.w; 256 257 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && (tex.y >= 0.0f) && (tex.y < 1.0f) && (abs(newDepth - oldDepth) < 9e-4f)) 258 OUT.color = attenuated_color * x + col1 * float4(1.0f - x); 251 float depthDif = 1.0f - newDepth / oldDepth; 252 253 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 254 (tex.y >= 0.0f) && (tex.y < 1.0f) && 255 (abs(depthDif) < 9e-4f)) 256 OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); 259 257 else 260 258 OUT.color = attenuated_color; 261 259 262 //OUT.color = float4(centerPosition.w);263 //OUT.color = float4(oldDepth);264 //OUT.color = float4(newDepth);265 //OUT.color = float4(abs(newDepth - oldDepth));266 260 OUT.color.w = tex2D(colors, IN.texCoord.xy).w; 267 261 … … 273 267 uniform sampler2D colors, 274 268 uniform sampler2D positions, 275 uniform sampler2D normals, 276 uniform sampler2D oldTex 269 uniform sampler2D normals 277 270 ) 278 271 { … … 282 275 float amb = normal.w; 283 276 284 //OUT.color.xyz = IN.view;285 277 // expand normal 286 278 normal = normalize(normal * 2.0f - float4(1.0f)); 287 279 288 280 float4 col = shade(IN, colors, positions, normal.xyz, amb); 289 //OUT.color = col; 290 291 float4 col1 = tex2D(oldTex, IN.texCoord.xy); 292 293 const float x = 0.01f; 294 OUT.color = col * x + col1 * float4(1.0f - x); 281 OUT.color = col; 295 282 296 283 return OUT; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2836 r2837 105 105 // hack: squeeze some information about ambient into the texture 106 106 pix.norm.w = ambient.x; 107 pix.pos.w = IN.mypos.w; //IN.projPos.w;107 pix.pos.w = IN.mypos.w; 108 108 pix.col.w = IN.mypos.z / IN.mypos.w; 109 109
Note: See TracChangeset
for help on using the changeset viewer.