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:
parent
06d197cdd0
commit
31578303a4
12 changed files with 117 additions and 59 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue