1
0
Fork 0

Make the number of shadow cascades and the range of each configurable

This commit is contained in:
Frederic Bouvier 2012-04-17 09:12:57 +02:00
parent e09670ea33
commit e4b856805e
3 changed files with 16 additions and 5 deletions

View file

@ -77,6 +77,8 @@
- fg_ViewMatrixInverse - fg_ViewMatrixInverse
- fg_ViewMatrix - fg_ViewMatrix
- fg_Planes - fg_Planes
- fg_ShadowNumber
- fg_ShadowDistances
--> -->
</pass> </pass>
</technique> </technique>

View file

@ -8,6 +8,8 @@ uniform vec4 fg_SunDiffuseColor;
uniform vec4 fg_SunSpecularColor; uniform vec4 fg_SunSpecularColor;
uniform vec3 fg_SunDirection; uniform vec3 fg_SunDirection;
uniform vec3 fg_Planes; uniform vec3 fg_Planes;
uniform int fg_ShadowNumber;
uniform vec4 fg_ShadowDistances;
varying vec3 ray; varying vec3 ray;
vec3 position( vec3 viewdir, float depth ); vec3 position( vec3 viewdir, float depth );
@ -18,18 +20,20 @@ vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint )
vec4 coords; vec4 coords;
vec2 shift = vec2( 0.0 ); vec2 shift = vec2( 0.0 );
int index = 4; int index = 4;
if (ecPosition.z > -5.0) { float factor = 0.5;
if (ecPosition.z > -fg_ShadowDistances.x) {
index = 1; index = 1;
factor = 1.0;
tint = vec4(0.0,1.0,0.0,1.0); tint = vec4(0.0,1.0,0.0,1.0);
} else if (ecPosition.z > -50.0) { } else if (ecPosition.z > -fg_ShadowDistances.y && fg_ShadowNumber > 1) {
index = 2; index = 2;
shift = vec2( 0.0, 0.5 ); shift = vec2( 0.0, 0.5 );
tint = vec4(0.0,0.0,1.0,1.0); tint = vec4(0.0,0.0,1.0,1.0);
} else if (ecPosition.z > -512.0) { } else if (ecPosition.z > -fg_ShadowDistances.z && fg_ShadowNumber > 2) {
index = 3; index = 3;
shift = vec2( 0.5, 0.0 ); shift = vec2( 0.5, 0.0 );
tint = vec4(1.0,1.0,0.0,1.0); tint = vec4(1.0,1.0,0.0,1.0);
} else if (ecPosition.z > -10000.0) { } else if (ecPosition.z > -fg_ShadowDistances.w && fg_ShadowNumber > 3) {
shift = vec2( 0.5, 0.5 ); shift = vec2( 0.5, 0.5 );
tint = vec4(1.0,0.0,0.0,1.0); tint = vec4(1.0,0.0,0.0,1.0);
} else { } else {
@ -39,7 +43,7 @@ vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint )
coords.t = dot( ecPosition, gl_EyePlaneT[index] ); coords.t = dot( ecPosition, gl_EyePlaneT[index] );
coords.p = dot( ecPosition, gl_EyePlaneR[index] ); coords.p = dot( ecPosition, gl_EyePlaneR[index] );
coords.q = dot( ecPosition, gl_EyePlaneQ[index] ); coords.q = dot( ecPosition, gl_EyePlaneQ[index] );
coords.st *= .5; coords.st *= factor;
coords.st += shift; coords.st += shift;
return coords; return coords;
} }

View file

@ -182,6 +182,11 @@ Started September 2000 by David Megginson, david@megginson.com
<debug type="bool" <debug type="bool"
userarchive="y">false</debug> userarchive="y">false</debug>
<map-size type="int">4096</map-size> <map-size type="int">4096</map-size>
<num-cascades type="int">4</num-cascades>
<cascade-far-m index="0" type="float">5.0</cascade-far-m>
<cascade-far-m index="1" type="float">50.0</cascade-far-m>
<cascade-far-m index="2" type="float">500.0</cascade-far-m>
<cascade-far-m index="3" type="float">5000.0</cascade-far-m>
</shadows> </shadows>
<shader-experimental type="bool" <shader-experimental type="bool"
userarchive="y">false</shader-experimental> userarchive="y">false</shader-experimental>