aboutsummaryrefslogtreecommitdiff
path: root/client/shaders/shadow_shaders
diff options
context:
space:
mode:
authorx2048 <codeforsmile@gmail.com>2022-03-31 22:40:06 +0200
committerGitHub <noreply@github.com>2022-03-31 22:40:06 +0200
commit31578303a4eab6b6b083e57b6bf8d12ff3b3d991 (patch)
tree3ff56df6e29207c1ca3f2f93c5327f1cc786a7ec /client/shaders/shadow_shaders
parent06d197cdd042392e1551e5e7244c61300a6bb4e3 (diff)
downloadminetest-31578303a4eab6b6b083e57b6bf8d12ff3b3d991.tar.gz
minetest-31578303a4eab6b6b083e57b6bf8d12ff3b3d991.tar.bz2
minetest-31578303a4eab6b6b083e57b6bf8d12ff3b3d991.zip
Tune shadow perspective distortion (#12146)
* Pass perspective distortion parameters as uniforms * Set all perspective bias parameters via ShadowRenderer * Recalibrate perspective distortion and shadow range to render less shadow geometry with the same quality and observed shadow distance
Diffstat (limited to 'client/shaders/shadow_shaders')
-rw-r--r--client/shaders/shadow_shaders/pass1_trans_vertex.glsl10
-rw-r--r--client/shaders/shadow_shaders/pass1_vertex.glsl10
2 files changed, 10 insertions, 10 deletions
diff --git a/client/shaders/shadow_shaders/pass1_trans_vertex.glsl b/client/shaders/shadow_shaders/pass1_trans_vertex.glsl
index 0a9efe450..6d2877d18 100644
--- a/client/shaders/shadow_shaders/pass1_trans_vertex.glsl
+++ b/client/shaders/shadow_shaders/pass1_trans_vertex.glsl
@@ -4,15 +4,15 @@ varying vec4 tPos;
varying vec3 varColor;
#endif
-const float bias0 = 0.9;
-const float zPersFactor = 0.5;
-const float bias1 = 1.0 - bias0 + 1e-6;
+uniform float xyPerspectiveBias0;
+uniform float xyPerspectiveBias1;
+uniform float zPerspectiveBias;
vec4 getPerspectiveFactor(in vec4 shadowPosition)
{
float pDistance = length(shadowPosition.xy);
- float pFactor = pDistance * bias0 + bias1;
- shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPersFactor);
+ float pFactor = pDistance * xyPerspectiveBias0 + xyPerspectiveBias1;
+ shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPerspectiveBias);
return shadowPosition;
}
diff --git a/client/shaders/shadow_shaders/pass1_vertex.glsl b/client/shaders/shadow_shaders/pass1_vertex.glsl
index feee9467f..3873ac6e6 100644
--- a/client/shaders/shadow_shaders/pass1_vertex.glsl
+++ b/client/shaders/shadow_shaders/pass1_vertex.glsl
@@ -1,15 +1,15 @@
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;
+uniform float xyPerspectiveBias0;
+uniform float xyPerspectiveBias1;
+uniform float zPerspectiveBias;
vec4 getPerspectiveFactor(in vec4 shadowPosition)
{
float pDistance = length(shadowPosition.xy);
- float pFactor = pDistance * bias0 + bias1;
- shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPersFactor);
+ float pFactor = pDistance * xyPerspectiveBias0 + xyPerspectiveBias1;
+ shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPerspectiveBias);
return shadowPosition;
}