- Timestamp:
- 07/08/08 03:35:16 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2821 r2822 1 #define NUM_SAMPLES 82 #define SAMPLE_INTENSITY 0.5f3 //#define SAMPLE_INTENSITY 0.2f4 #define AREA_SIZE 3e-1f1 #define NUM_SAMPLES 12 2 //#define SAMPLE_INTENSITY 0.4f 3 #define SAMPLE_INTENSITY 0.7f 4 #define AREA_SIZE 5e-1f 5 5 6 6 // kustls magic sample positions … … 72 72 float ssao(fragment IN, 73 73 uniform sampler2D positions, 74 uniform sampler2D normals,75 74 uniform sampler2D noiseTexture, 76 uniform float2 samples[NUM_SAMPLES] 75 uniform float2 samples[NUM_SAMPLES], 76 uniform float3 currentNormal 77 77 ) 78 78 { … … 82 82 float w = centerPosition.w; 83 83 84 // the normal on the current position85 float3 centerNormal = tex2D(normals, IN.texCoord.xy).xyz;86 //normalize(centerNormal);87 88 84 // Check in a circular area around the current position. 89 85 // Shoot vectors to the positions there, and check the angle to these positions. … … 120 116 121 117 // Angle between current normal and direction to sample controls AO intensity. 122 float cos_angle = dot(direction_to_sample, c enterNormal);118 float cos_angle = dot(direction_to_sample, currentNormal); 123 119 cos_angle = max(cos_angle, 0.0f); 124 120 125 121 // distance between current position and sample position controls AO intensity. 122 //const float maxdist = 2e-1f; 126 123 const float maxdist = 5e-1f; 127 //const float scale = 50.0f; 128 124 129 125 float distance_intensity = maxdist - length_to_sample; 126 //float distance_intensity = 0.5f / (1.0f + length_to_sample * length_to_sample); 130 127 distance_intensity = max(distance_intensity, 0.0f); 131 128 // quadratic influence … … 142 139 uniform sampler2D colors, 143 140 uniform sampler2D positions, 144 uniform sampler2D normals) 141 uniform float3 normal, 142 uniform float amb) 145 143 { 146 144 float4 lightDir = float4(0.8f, -1.0f, 0.7f, 0.0f); … … 148 146 149 147 float4 color = tex2D(colors, IN.texCoord.xy); 150 float3 normal = tex2D(normals, IN.texCoord.xy).xyz; 151 152 // expand normal 153 normal = normalize(normal * 2.0f - 1.0f); 154 148 155 149 float4 position = tex2D(positions, IN.texCoord.xy); 156 150 157 float4 ambient = float4(0.3f);151 float4 ambient = 0.3f; 158 152 159 153 // float3 L = normalize(lightPosition - position); … … 166 160 float diffuse = diffuseLight + diffuseLight2; 167 161 168 return (ambient + diffuse) * color ;162 return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 169 163 } 170 164 … … 179 173 pixel OUT; 180 174 181 float4 col = shade(IN, colors, positions, normals); 182 float ao = ssao(IN, positions, normals, noiseTexture, samples); 175 float4 normal = tex2D(normals, IN.texCoord.xy); 176 float amb = normal.w; 177 178 // expand normal 179 normal = normalize(normal * 2.0f - 1.0f); 180 181 float4 col = shade(IN, colors, positions, normal, amb); 182 float ao = ssao(IN, positions, noiseTexture, samples, normal); 183 183 184 184 //OUT.color = tex2D(positions, IN.texCoord.xy); 185 185 //OUT.color = ao; 186 //OUT.color = 186 //OUT.color = col; 187 187 OUT.color = ao * col; 188 188 … … 197 197 { 198 198 pixel OUT; 199 200 float4 col = shade(IN, colors, positions, normals); 199 200 float4 normal = tex2D(normals, IN.texCoord.xy); 201 float amb = normal.w; 202 203 // expand normal 204 normal = normalize(normal * 2.0f - 1.0f); 205 206 float4 col = shade(IN, colors, positions, normal.xyz, amb); 201 207 OUT.color = col; 202 208
Note: See TracChangeset
for help on using the changeset viewer.