diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-09-19 20:56:13 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-09-19 20:56:13 +0200 |
commit | c8900e169a1ddceec07a449f1ae7c4322ff02036 (patch) | |
tree | 5156605fb473d25786426eb6876ba2e7d3b7507b /client/shaders/shadow_shaders/pass1_trans_vertex.glsl | |
parent | 950d2c9b3e10cbace9236e820c8119d1abb9e01f (diff) | |
parent | e0529da5c84f224c380e6d5e063392cb01f85683 (diff) | |
download | dragonfireclient-c8900e169a1ddceec07a449f1ae7c4322ff02036.tar.xz |
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'client/shaders/shadow_shaders/pass1_trans_vertex.glsl')
-rw-r--r-- | client/shaders/shadow_shaders/pass1_trans_vertex.glsl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/client/shaders/shadow_shaders/pass1_trans_vertex.glsl b/client/shaders/shadow_shaders/pass1_trans_vertex.glsl new file mode 100644 index 000000000..ca59f2796 --- /dev/null +++ b/client/shaders/shadow_shaders/pass1_trans_vertex.glsl @@ -0,0 +1,26 @@ +uniform mat4 LightMVP; // world matrix +varying vec4 tPos; + +const float bias0 = 0.9; +const float zPersFactor = 0.5; +const float bias1 = 1.0 - bias0 + 1e-6; + +vec4 getPerspectiveFactor(in vec4 shadowPosition) +{ + float pDistance = length(shadowPosition.xy); + float pFactor = pDistance * bias0 + bias1; + shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPersFactor); + + 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; +} |