- Timestamp:
- 08/27/08 07:50:52 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2871 r2872 10 10 //#define SAMPLE_INTENSITY 0.125f 11 11 12 #define AREA_SIZE 9e-1f 13 //#define VIEW_CORRECTION_SCALE 0.3f 14 #define VIEW_CORRECTION_SCALE 0.5f 12 #define AREA_SIZE 7e-1f 13 //#define AREA_SIZE 3e-1f 14 #define VIEW_CORRECTION_SCALE 0.3f 15 //#define VIEW_CORRECTION_SCALE 0.5f 15 16 #define DISTANCE_SCALE 1e-6f 16 17 … … 114 115 } 115 116 116 return (1.0f - total_ao);117 return max(0.0f, 1.0f - total_ao); 117 118 //return dot(currentViewDir, currentNormal); 118 119 } … … 121 122 /** Computes ambient occlusion + diffuse reflections 122 123 */ 123 /*124 124 float4 globIllum(fragment IN, 125 125 uniform sampler2D colors, … … 140 140 // Summing up these angles gives an estimation of the occlusion at the current position. 141 141 142 float total_ao = 0.0;143 float 3 total_color = float3(0.0f);142 // ao is in stored in the w 143 float4 total_color = float4(0, 0, 0, 1); 144 144 145 145 const float areaSize = 5e-1f; … … 153 153 154 154 // rotation 155 float2 offsetTransformed = r otate(offset, mynoise);155 float2 offsetTransformed = reflect(offset, mynoise); 156 156 157 157 // weight with projected coordinate to reach similar kernel size for near and far … … 159 159 160 160 float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 161 float3 sample_color = tex2D (colors, float4(texcoord, 0, 1)).xyz;161 float3 sample_color = tex2Dlod(colors, float4(texcoord, 0, 1)).xyz; 162 162 163 163 float3 vector_to_sample = sample_position - centerPosition.xyz; … … 176 176 float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 177 177 178 total_ao += cos_angle * distance_intensity * view_correction; 179 float scale_factor = 0.3f; 180 total_color += cos_angle * distance_intensity * view_correction * sample_color * scale_factor; 181 } 182 183 return float4(total_color, 1.0f - total_ao); 184 } 185 */ 178 total_color.w -= cos_angle * distance_intensity * view_correction; 179 180 const float scale_factor = 0.3f; 181 total_color.xyz += cos_angle * distance_intensity * view_correction * sample_color * scale_factor; 182 } 183 184 return saturate(total_color); 185 } 186 186 187 187 188 /** The mrt shader for screen space ambient occlusion … … 208 209 209 210 // expand normal 210 float3 normal = normalize(norm.xyz); // * 2.0f - 1.0f);211 float3 normal = normalize(norm.xyz); 211 212 /// the current view direction 212 213 float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); … … 219 220 const float currentDepth = currentCol.w; 220 221 221 float4 new_col = (float4)ssao(IN, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition);222 //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition);222 //float4 new_col = (float4)ssao(IN, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition); 223 float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition); 223 224 224 225 … … 250 251 } 251 252 252 253 OUT.combined_col = currentCol * OUT.illum_col; 253 //const float ao = OUT.illum_col.x; 254 const float ao = OUT.illum_col.w; 255 256 //OUT.combined_col = (currentCol + OUT.illum_col) * ao; 257 OUT.combined_col = currentCol * ao; 254 258 255 259 OUT.illum_col.w = currentDepth;
Note: See TracChangeset
for help on using the changeset viewer.