2021-06-06 18:51:21 +02:00
|
|
|
uniform mat4 LightMVP; // world matrix
|
|
|
|
varying vec4 tPos;
|
2021-10-01 16:21:53 +02:00
|
|
|
#ifdef COLORED_SHADOWS
|
|
|
|
varying vec3 varColor;
|
|
|
|
#endif
|
2021-06-06 18:51:21 +02:00
|
|
|
|
2022-03-31 22:40:06 +02:00
|
|
|
uniform float xyPerspectiveBias0;
|
|
|
|
uniform float xyPerspectiveBias1;
|
|
|
|
uniform float zPerspectiveBias;
|
2021-06-06 18:51:21 +02:00
|
|
|
|
|
|
|
vec4 getPerspectiveFactor(in vec4 shadowPosition)
|
|
|
|
{
|
|
|
|
float pDistance = length(shadowPosition.xy);
|
2022-03-31 22:40:06 +02:00
|
|
|
float pFactor = pDistance * xyPerspectiveBias0 + xyPerspectiveBias1;
|
|
|
|
shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPerspectiveBias);
|
2021-06-06 18:51:21 +02:00
|
|
|
|
|
|
|
return shadowPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 pos = LightMVP * gl_Vertex;
|
|
|
|
|
|
|
|
tPos = getPerspectiveFactor(LightMVP * gl_Vertex);
|
|
|
|
|
|
|
|
gl_Position = vec4(tPos.xyz, 1.0);
|
|
|
|
gl_TexCoord[0].st = gl_MultiTexCoord0.st;
|
2021-10-01 16:21:53 +02:00
|
|
|
|
|
|
|
#ifdef COLORED_SHADOWS
|
|
|
|
varColor = gl_Color.rgb;
|
|
|
|
#endif
|
2021-06-06 18:51:21 +02:00
|
|
|
}
|