- Timestamp:
- 09/02/08 15:29:20 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2893 r2895 81 81 uniform sampler2D shadowMap, 82 82 uniform float4x4 shadowMatrix, 83 uniform float maxDepth 83 uniform float maxDepth, 84 uniform float sampleWidth 84 85 ) 85 86 { … … 102 103 float4 lightSpacePos = mul(shadowMatrix, position); 103 104 104 float shadowDepth = tex2D(shadowMap, lightSpacePos.xy); 105 float shadowDepth[9]; 106 107 float w = sampleWidth; 108 109 // pcf sampling using 3 x 3 tab 110 111 shadowDepth[0] = tex2D(shadowMap, lightSpacePos.xy).x; 112 113 shadowDepth[1] = tex2D(shadowMap, lightSpacePos.xy + float2( w, w)).x; 114 shadowDepth[2] = tex2D(shadowMap, lightSpacePos.xy - float2( w, -w)).x; 115 shadowDepth[3] = tex2D(shadowMap, lightSpacePos.xy - float2(-w, -w)).x; 116 shadowDepth[4] = tex2D(shadowMap, lightSpacePos.xy - float2(-w, w)).x; 117 118 shadowDepth[5] = tex2D(shadowMap, lightSpacePos.xy - float2( w, 0)).x; 119 shadowDepth[6] = tex2D(shadowMap, lightSpacePos.xy - float2( 0, w)).x; 120 shadowDepth[7] = tex2D(shadowMap, lightSpacePos.xy - float2(-w, 0)).x; 121 shadowDepth[8] = tex2D(shadowMap, lightSpacePos.xy - float2( 0, -w)).x; 105 122 106 123 OUT.color = col; 107 124 108 // hack: prevent shadowing the sky 109 if ((amb < 0.9) && 125 float depth = lightSpacePos.z / lightSpacePos.w; 126 127 float d = 0.0f; 128 129 for (int i = 0; i < 9; ++ i) 130 { 131 d += step(shadowDepth[i], depth); 132 } 133 134 d /= 9.0f; 135 136 /*if ((amb < 0.9) && // hack: prevent shadowing the sky 110 137 (lightSpacePos.z / lightSpacePos.w > shadowDepth)) 111 138 { 112 139 OUT.color *= 0.1f; 140 }*/ 141 142 if (amb < 0.9) // hack: prevent shadowing the sky 143 { 144 const float x = 0.1f; 145 OUT.color *= x + (1.0f - x) * (1.0f - d); 113 146 } 114 147
Note: See TracChangeset
for help on using the changeset viewer.