]> git.lizzy.rs Git - dragonfireclient.git/blob - client/shaders/shadow_shaders/pass1_vertex.glsl
Tune shadow perspective distortion (#12146)
[dragonfireclient.git] / client / shaders / shadow_shaders / pass1_vertex.glsl
1 uniform mat4 LightMVP; // world matrix
2 varying vec4 tPos;
3
4 uniform float xyPerspectiveBias0;
5 uniform float xyPerspectiveBias1;
6 uniform float zPerspectiveBias;
7
8 vec4 getPerspectiveFactor(in vec4 shadowPosition)
9 {
10         float pDistance = length(shadowPosition.xy);
11         float pFactor = pDistance * xyPerspectiveBias0 + xyPerspectiveBias1;
12         shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPerspectiveBias);
13
14         return shadowPosition;
15 }
16
17
18 void main()
19 {
20         vec4 pos = LightMVP * gl_Vertex;
21
22         tPos = getPerspectiveFactor(pos);
23
24         gl_Position = vec4(tPos.xyz, 1.0);
25         gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
26 }