Changeset 2820 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 07/07/08 16:34:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2819 r2820 1 #define SAMPLES 24 2 1 #define NUM_SAMPLES 8 2 #define SAMPLE_INTENSITY 0.6 3 #define AREA_SIZE 3e-1f 3 4 // kustls magic sample positions 4 static const float2 samples[SAMPLES] =5 /*static const float2 samples[NUM_SAMPLES] = 5 6 { 6 7 {-0.326212f, -0.405805f}, … … 28 29 {0.32194f, 0.932615f}, 29 30 {0.791559f, 0.597705f} 30 }; 31 };*/ 31 32 32 33 … … 60 61 uniform sampler2D positions, 61 62 uniform sampler2D normals, 62 uniform sampler2D noiseTexture 63 uniform sampler2D noiseTexture, 64 uniform float2 samples[NUM_SAMPLES] 63 65 ) 64 66 { … … 79 81 80 82 //const float areaSize = 5e-1f; 81 const float areaSize = 3e-1f;82 const float sampleIntensity = 0.2f;83 //const float areaSize = 3e-1f; 84 //const float sampleIntensity = 0.2f; 83 85 84 for (int i = 0; i < SAMPLES; i ++) {86 for (int i = 0; i < NUM_SAMPLES; i ++) { 85 87 float2 offset = samples[i]; 86 88 … … 95 97 96 98 // weight with projected coordinate to reach similar kernel size for near and far 97 float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize* w;99 float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w; 98 100 99 101 float3 sample_position = tex2D(positions, texcoord).xyz; … … 101 103 float3 vector_to_sample = sample_position - centerPosition.xyz; 102 104 float length_to_sample = length(vector_to_sample); 103 float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f);105 float3 direction_to_sample = vector_to_sample / length_to_sample; 104 106 105 107 // Angle between current normal and direction to sample controls AO intensity. … … 115 117 distance_intensity = max(distance_intensity, 0.0f); 116 118 117 total_ao += cos_angle * sampleIntensity* distance_intensity;119 total_ao += cos_angle * SAMPLE_INTENSITY * distance_intensity; 118 120 } 119 121 … … 122 124 123 125 124 pixel main(fragment IN, 125 uniform sampler2D colors, 126 uniform sampler2D positions, 127 uniform sampler2D normals, 128 uniform sampler2D noiseTexture) 126 float4 shade(fragment IN, 127 uniform sampler2D colors, 128 uniform sampler2D positions, 129 uniform sampler2D normals) 129 130 { 130 pixel OUT;131 132 131 float4 lightDir = float4(0.8f, -1.0f, 0.7f, 0.0f); 133 132 float4 lightDir2 = float4(-0.5f, 0.5f, 0.4f, 0.0f); … … 152 151 float diffuse = diffuseLight + diffuseLight2; 153 152 154 //float ao = ssao(IN, positions, normals, noiseTexture); 155 float ao = 1.0f; 156 //OUT.color = ao; 157 OUT.color = ao * (ambient + diffuse) * color; 153 return (ambient + diffuse) * color; 154 } 155 156 157 pixel main(fragment IN, 158 uniform sampler2D colors, 159 uniform sampler2D positions, 160 uniform sampler2D normals, 161 uniform sampler2D noiseTexture, 162 uniform float2 samples[NUM_SAMPLES]) 163 { 164 pixel OUT; 165 166 float4 col = Shade(IN, positions, normals); 167 float ao = ssao(IN, positions, normals, noiseTexture, samples); 168 //float ao = 1.0f; 169 OUT.color = ao * col; 170 //OUT.color = ao * (ambient + diffuse) * color; 158 171 //OUT.color = (ambient + diffuse) * color; 159 172
Note: See TracChangeset
for help on using the changeset viewer.