Changeset 2821 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 07/07/08 18:41:45 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2820 r2821 1 1 #define NUM_SAMPLES 8 2 #define SAMPLE_INTENSITY 0.6 2 #define SAMPLE_INTENSITY 0.5f 3 //#define SAMPLE_INTENSITY 0.2f 3 4 #define AREA_SIZE 3e-1f 5 4 6 // kustls magic sample positions 5 7 /*static const float2 samples[NUM_SAMPLES] = … … 57 59 58 60 61 float2 rotate(float2 pt, float2 n) 62 { 63 float2 ptTransformed; 64 ptTransformed.x = n.r * pt.x - n.g * pt.y; 65 ptTransformed.y = n.g * pt.x + n.r * pt.y; 66 67 return ptTransformed; 68 } 69 70 59 71 //based on kustls shader 60 72 float ssao(fragment IN, … … 88 100 89 101 //sample noisetex; r stores costheta, g stores sintheta 90 float 3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz* 2.0f - 1.0f;102 float2 noise = tex2D(noiseTexture, IN.texCoord.xy).xy * 2.0f - 1.0f; 91 103 92 104 // rotation 93 105 //float2 offsetTransformed = offset; 94 float2 offsetTransformed; 95 offsetTransformed.x = noise.r * offset.x - noise.g * offset.y; 96 offsetTransformed.y = noise.g * offset.x + noise.r * offset.y; 106 float2 offsetTransformed = rotate(offset, noise); 107 //float2 offsetTransformed = reflect(offset, noise); 108 109 //offsetTransformed.x = noise.r * offset.x - noise.g * offset.y; 110 //offsetTransformed.y = noise.g * offset.x + noise.r * offset.y; 97 111 98 112 // weight with projected coordinate to reach similar kernel size for near and far … … 114 128 115 129 float distance_intensity = maxdist - length_to_sample; 130 distance_intensity = max(distance_intensity, 0.0f); 131 // quadratic influence 116 132 distance_intensity *= distance_intensity; 117 distance_intensity = max(distance_intensity, 0.0f);118 133 119 134 total_ao += cos_angle * SAMPLE_INTENSITY * distance_intensity; … … 155 170 156 171 172 pixel main_ssao(fragment IN, 173 uniform sampler2D colors, 174 uniform sampler2D positions, 175 uniform sampler2D normals, 176 uniform sampler2D noiseTexture, 177 uniform float2 samples[NUM_SAMPLES]) 178 { 179 pixel OUT; 180 181 float4 col = shade(IN, colors, positions, normals); 182 float ao = ssao(IN, positions, normals, noiseTexture, samples); 183 184 //OUT.color = tex2D(positions, IN.texCoord.xy); 185 //OUT.color = ao; 186 //OUT.color = col; 187 OUT.color = ao * col; 188 189 return OUT; 190 } 191 192 157 193 pixel main(fragment IN, 158 194 uniform sampler2D colors, 159 195 uniform sampler2D positions, 160 uniform sampler2D normals, 161 uniform sampler2D noiseTexture, 162 uniform float2 samples[NUM_SAMPLES]) 196 uniform sampler2D normals) 163 197 { 164 198 pixel OUT; 165 199 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; 171 //OUT.color = (ambient + diffuse) * color; 172 200 float4 col = shade(IN, colors, positions, normals); 201 OUT.color = col; 202 173 203 return OUT; 174 204 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2819 r2821 56 56 OUT.position = mul(ModelViewProj, OUT.worldPos); 57 57 58 OUT.worldPos = IN.position;59 60 58 OUT.normal = IN.normal; 61 59 62 60 return OUT; 63 61 } 64 65 /*struct Material66 {67 float4 diffuse;68 }*/69 62 70 63
Note: See TracChangeset
for help on using the changeset viewer.