- Timestamp:
- 08/26/08 13:30:31 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2866 r2867 7 7 8 8 // rule of thumb: approx 1 / NUM_SAMPLES 9 #define SAMPLE_INTENSITY 0.1 79 #define SAMPLE_INTENSITY 0.15 10 10 //#define SAMPLE_INTENSITY 0.125f 11 11 … … 37 37 float2 rpt = pt - d * 2.0f * n; 38 38 39 //return pt;40 39 return rpt; 41 40 } … … 80 79 81 80 //sample noisetex; r stores costheta, g stores sintheta 82 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 81 //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 82 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 83 83 84 84 // rotation 85 85 //float2 offsetTransformed = offset; 86 float2 offsetTransformed = rotate(offset, mynoise);87 //float2 offsetTransformed = reflect(offset,noise);86 //float2 offsetTransformed = rotate(offset, mynoise); 87 float2 offsetTransformed = reflect(offset, mynoise); 88 88 89 89 // weight with projected coordinate to reach similar kernel size for near and far 90 90 float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w; 91 91 92 float3 sample_position = tex2D(positions, texcoord).xyz; 92 // sample downsampled texture in order to speed up texture accesses 93 float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 94 //float3 sample_position = tex2D(positions, texcoord).xyz; 93 95 94 96 float3 vector_to_sample = sample_position - centerPosition.xyz; … … 112 114 113 115 return (1.0f - total_ao); 114 //return float4(dot(currentViewDir, currentNormal));116 //return dot(currentViewDir, currentNormal); 115 117 } 116 118 … … 180 182 181 183 184 /** function for standard deferred shading 185 */ 182 186 float4 shade(fragment IN, 183 187 uniform sampler2D colors, … … 199 203 float3 light2 = normalize(lightDir2.xyz); 200 204 201 float diffuseLight = max(dot(normal, light), 0.0f);202 float diffuseLight2 = max(dot(normal, light2), 0.0f);205 float diffuseLight = saturate(dot(normal, light)); 206 float diffuseLight2 = saturate(dot(normal, light2)); 203 207 204 208 float diffuse = diffuseLight + diffuseLight2; 205 //float diffuse = diffuseLight;206 209 207 210 return (ambient + diffuse) * color * (1.0f - amb) + amb * color; … … 227 230 228 231 float4 normal = tex2D(normals, IN.texCoord.xy); 232 233 // the ambient term 229 234 float amb = normal.w; 230 235 231 236 // expand normal 232 normal = normalize(normal * 2.0f - 1.0f);237 normal = normalize(normal);// * 2.0f - 1.0f); 233 238 /// the current view direction 234 239 float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); … … 263 268 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 264 269 (tex.y >= 0.0f) && (tex.y < 1.0f) && 265 (abs(depthDif) < 8e-5f))270 (abs(depthDif) < 1e-4f)) 266 271 { 267 272 OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); … … 292 297 293 298 float4 normal = tex2D(normals, IN.texCoord.xy); 299 300 // an ambient color term 294 301 float amb = normal.w; 295 302 296 303 // expand normal 297 normal = normalize(normal * 2.0f - float4(1.0f));304 normal = normalize(normal);// * 2.0f - float4(1.0f)); 298 305 299 306 float4 col = shade(IN, colors, positions, normal.xyz, amb);
Note: See TracChangeset
for help on using the changeset viewer.