- Timestamp:
- 08/29/08 15:46:36 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2882 r2884 1 #include "../shaderenv.h" 2 1 3 //////////////////// 2 4 // Screen Spaced Ambient Occlusion shader 3 5 // based on shader of Alexander Kusternig 4 6 5 #define NUM_SAMPLES 106 //#define NUM_SAMPLES 167 8 // rule of thumb: approx 1 / NUM_SAMPLES9 //#define SAMPLE_INTENSITY 0.15f10 #define SAMPLE_INTENSITY 0.22f11 12 #define AREA_SIZE 7e-1f13 //#define AREA_SIZE 3e-1f14 #define VIEW_CORRECTION_SCALE 0.3f15 //#define VIEW_CORRECTION_SCALE 0.5f16 #define DISTANCE_SCALE 1e-6f17 7 18 8 … … 66 56 for (int i = 0; i < NUM_SAMPLES; ++ i) 67 57 { 68 float2 offset = samples[i];58 const float2 offset = samples[i]; 69 59 70 60 //////////////////// 71 61 // add random noise: r stores costheta, g stores sintheta 72 62 73 // float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f;63 //const float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 74 64 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 75 65 76 float2 offsetTransformed = reflect(offset, mynoise);66 const float2 offsetTransformed = reflect(offset, mynoise); 77 67 78 68 // weight with projected coordinate to reach similar kernel size for near and far … … 165 155 (abs(depthDif) < 1e-3f)) 166 156 { 167 OUT.illum_col .x =ao * expFactor + oldCol.x * (1.0f - expFactor);157 OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor); 168 158 } 169 159 else 170 160 { 171 OUT.illum_col .x =ao;161 OUT.illum_col = (float4)ao; 172 162 } 173 163 … … 178 168 179 169 180 181 170 pixel combine(fragment IN, 182 171 uniform sampler2D colors, … … 185 174 pixel OUT; 186 175 187 float4 col = tex2D (colors, IN.texCoord.xy);176 float4 col = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 188 177 float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 189 178 190 179 OUT.illum_col = col * ao.x; 180 OUT.illum_col.w = ao.w; 191 181 192 182 return OUT;
Note: See TracChangeset
for help on using the changeset viewer.