summaryrefslogtreecommitdiff
path: root/client/shaders/object_shader/opengl_vertex.glsl
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/object_shader/opengl_vertex.glsl
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/object_shader/opengl_vertex.glsl')
-rw-r--r--client/shaders/object_shader/opengl_vertex.glsl8
1 files changed, 4 insertions, 4 deletions
diff --git a/client/shaders/object_shader/opengl_vertex.glsl b/client/shaders/object_shader/opengl_vertex.glsl
index ff0067302..55861b0e9 100644
--- a/client/shaders/object_shader/opengl_vertex.glsl
+++ b/client/shaders/object_shader/opengl_vertex.glsl
@@ -37,8 +37,8 @@ const vec3 artificialLight = vec3(1.04, 1.04, 1.04);
varying float vIDiff;
const float e = 2.718281828459;
const float BS = 10.0;
-const float bias0 = 0.9;
-const float bias1 = 1.0 - bias0;
+uniform float xyPerspectiveBias0;
+uniform float xyPerspectiveBias1;
#ifdef ENABLE_DYNAMIC_SHADOWS
// custom smoothstep implementation because it's not defined in glsl1.2
@@ -116,9 +116,9 @@ void main(void)
// Distance from the vertex to the player
float distanceToPlayer = length(eyeToVertex - v_LightDirection * dot(eyeToVertex, v_LightDirection)) / f_shadowfar;
// perspective factor estimation according to the
- float perspectiveFactor = distanceToPlayer * bias0 + bias1;
+ float perspectiveFactor = distanceToPlayer * xyPerspectiveBias0 + xyPerspectiveBias1;
float texelSize = f_shadowfar * perspectiveFactor * perspectiveFactor /
- (f_textureresolution * bias1 - perspectiveFactor * bias0);
+ (f_textureresolution * xyPerspectiveBias1 - perspectiveFactor * xyPerspectiveBias0);
float slopeScale = clamp(pow(1.0 - cosLight*cosLight, 0.5), 0.0, 1.0);
normalOffsetScale = texelSize * slopeScale;