1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

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
This commit is contained in:
x2048 2022-03-31 22:40:06 +02:00 committed by GitHub
parent 06d197cdd0
commit 31578303a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 117 additions and 59 deletions

View file

@ -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;
}