mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-16 09:55:22 +02:00
Adjust shadowmap distortion to use entire SM texture (#12166)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
uniform mat4 LightMVP; // world matrix
|
||||
uniform vec4 CameraPos;
|
||||
varying vec4 tPos;
|
||||
#ifdef COLORED_SHADOWS
|
||||
varying vec3 varColor;
|
||||
@@ -10,10 +11,13 @@ uniform float zPerspectiveBias;
|
||||
|
||||
vec4 getPerspectiveFactor(in vec4 shadowPosition)
|
||||
{
|
||||
float pDistance = length(shadowPosition.xy);
|
||||
vec2 s = vec2(shadowPosition.x > CameraPos.x ? 1.0 : -1.0, shadowPosition.y > CameraPos.y ? 1.0 : -1.0);
|
||||
vec2 l = s * (shadowPosition.xy - CameraPos.xy) / (1.0 - s * CameraPos.xy);
|
||||
float pDistance = length(l);
|
||||
float pFactor = pDistance * xyPerspectiveBias0 + xyPerspectiveBias1;
|
||||
shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPerspectiveBias);
|
||||
|
||||
l /= pFactor;
|
||||
shadowPosition.xy = CameraPos.xy * (1.0 - l) + s * l;
|
||||
shadowPosition.z *= zPerspectiveBias;
|
||||
return shadowPosition;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user