Changeset 2822 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 07/08/08 03:35:16 (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
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 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2821 r2822 37 37 float4 col: COLOR0; 38 38 float4 pos: COLOR1; 39 float 3norm: COLOR2;39 float4 norm: COLOR2; 40 40 }; 41 41 … … 62 62 63 63 64 pixel fragtex(fragin IN, uniform sampler2D tex, uniform float maxDepth, uniform float4 diffuse) 64 pixel fragtex(fragin IN, 65 uniform sampler2D tex, 66 uniform float maxDepth, 67 uniform float4 ambient, 68 uniform float4 diffuse) 65 69 { 66 70 pixel pix; 67 71 68 pix.col = diffuse* tex2D(tex, IN.texCoord.xy);72 pix.col = (ambient + diffuse) * tex2D(tex, IN.texCoord.xy); 69 73 pix.pos = IN.worldPos * maxDepth; 70 pix.norm = IN.normal; 74 pix.norm.xyz = IN.normal * 0.5f + 0.5f; 75 // hack: squeeze some information about ambient into the texture 76 pix.norm.w = ambient.x; 77 // hack: store projection coordinate for scaling ssao 71 78 pix.pos.w = IN.projPos.w; 72 79 … … 75 82 76 83 77 pixel frag(fragin IN, uniform float maxDepth, uniform float4 diffuse) 84 pixel frag(fragin IN, 85 uniform float maxDepth, 86 uniform float4 ambient, 87 uniform float4 diffuse) 78 88 { 79 89 pixel pix; … … 81 91 pix.col = diffuse; 82 92 pix.pos = IN.worldPos * maxDepth; 83 pix.norm = IN.normal; 93 pix.norm.xyz = IN.normal * 0.5f + 0.5f; 94 // hack: squeeze some information about ambient into the texture 95 pix.norm.w = ambient.x; 84 96 pix.pos.w = IN.projPos.w; 85 97
Note: See TracChangeset
for help on using the changeset viewer.