Changeset 2954 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 09/17/08 19:35:11 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2952 r2954 36 36 float3 lightDir) 37 37 { 38 const float diffuseLight = saturate(dot(normal, lightDir));39 40 38 /* 41 39 float4 lightDir2 = float4(-0.5f, 0.5f, 0.4f, 0.0f); … … 43 41 float diffuseLight2 = saturate(dot(normal, light2)); 44 42 */ 45 float diffuse = diffuseLight;// + diffuseLight2; 43 // diffuse intensity 44 const float angle = saturate(dot(normal, lightDir)); 45 46 float4 lightDiffuse = glstate.light[0].diffuse; 47 float4 diffuse = angle * lightDiffuse; 46 48 47 49 // global ambient 48 const float4 ambient = 0.25f; 49 //const float4 ambient = 0.0f; 50 50 const float4 ambient = glstate.light[0].ambient; 51 51 52 return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 52 53 } … … 76 77 float4 col = shade(IN, color, position, normal, amb, lightDir); 77 78 78 //OUT.color = float4(1.0f);79 79 OUT.color = col; 80 80 OUT.color.w = color.w; … … 93 93 ) 94 94 { 95 //float shadowDepth = tex2D(shadowMap, lightSpacePos).x; 96 //return step(depth, shadowDepth); 97 95 98 float total_d = 0.0; 96 99 97 100 for (int i = 0; i < NUM_SAMPLES; ++ i) 98 101 { … … 120 123 return total_d; 121 124 } 122 123 124 #if 0125 /** The mrt shader for standard rendering126 */127 pixel main_shadow(fragment IN,128 uniform sampler2D colors,129 uniform sampler2D positions,130 uniform sampler2D normals,131 uniform sampler2D shadowMap,132 uniform float4x4 shadowMatrix,133 uniform float maxDepth,134 uniform float sampleWidth,135 uniform float3 lightDir136 )137 {138 pixel OUT;139 140 float4 norm = tex2D(normals, IN.texCoord.xy);141 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0));142 float4 position = tex2D(positions, IN.texCoord.xy);143 144 145 // an ambient color term146 float amb = norm.w;147 148 float3 normal = normalize(norm.xyz);149 float4 col = shade(IN, color, position, normal, amb);150 151 position *= maxDepth;152 position.w = 1.0f;153 154 float4 lightSpacePos = mul(shadowMatrix, position);155 lightSpacePos /= lightSpacePos.w;156 157 OUT.color = col;158 159 float shadowDepth[9];160 161 float w = sampleWidth;162 163 // pcf sampling using 3 x 3 tab164 shadowDepth[0] = tex2D(shadowMap, lightSpacePos.xy).x;165 166 shadowDepth[1] = tex2D(shadowMap, lightSpacePos.xy + float2( w, w)).x;167 shadowDepth[2] = tex2D(shadowMap, lightSpacePos.xy + float2( w, -w)).x;168 shadowDepth[3] = tex2D(shadowMap, lightSpacePos.xy + float2(-w, -w)).x;169 shadowDepth[4] = tex2D(shadowMap, lightSpacePos.xy + float2(-w, w)).x;170 171 shadowDepth[5] = tex2D(shadowMap, lightSpacePos.xy + float2( w, 0)).x;172 shadowDepth[6] = tex2D(shadowMap, lightSpacePos.xy + float2( 0, w)).x;173 shadowDepth[7] = tex2D(shadowMap, lightSpacePos.xy + float2(-w, 0)).x;174 shadowDepth[8] = tex2D(shadowMap, lightSpacePos.xy + float2( 0, -w)).x;175 176 177 float depth = lightSpacePos.z;178 179 float d = 0.0f;180 181 for (int i = 0; i < 9; ++ i)182 {183 d += step(shadowDepth[i], depth);184 }185 186 d /= 9.0f;187 188 if (amb < 0.9f) // hack: prevent shadowing the sky189 {190 // base lighting191 const float x = 0.4f;192 OUT.color *= x + (1.0f - x) * (1.0f - d);193 }194 195 /*196 // hard shadows197 float shadowDepth = tex2D(shadowMap, lightSpacePos.xy).x;198 199 if ((amb < 0.9f) && // hack: prevent shadowing the sky200 (lightSpacePos.z > shadowDepth))201 {202 OUT.color *= 0.1f;203 }*/204 205 OUT.color.w = color.w;206 207 return OUT;208 }209 210 #else211 125 212 126 … … 237 151 // diffuse intensity 238 152 const float angle = saturate(dot(normal, lightDir)); 239 float diffuse = angle; 153 //float4 lightDiffuse = float4(1.0f, 1.0f, 0.9f, 1.0f); 154 float4 lightDiffuse = glstate.light[0].diffuse; 155 //float4(1.0f, 1.0f, 0.9f, 1.0f); 156 157 float4 diffuse = lightDiffuse * angle; 240 158 241 159 // calc diffuse illumination + shadow term … … 256 174 257 175 // global ambient 258 const float4 ambient = 0.25f; 176 //const float4 ambient = 0.25f; 177 const float4 ambient = glstate.light[0].ambient; 259 178 260 179 // base lighting … … 266 185 return OUT; 267 186 } 268 269 #endif
Note: See TracChangeset
for help on using the changeset viewer.