mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Shadow mapping render pass (#11244)
Co-authored-by: x2048 <codeforsmile@gmail.com>
This commit is contained in:
parent
46f42e15c4
commit
c47313db65
35 changed files with 2624 additions and 38 deletions
26
client/shaders/shadow_shaders/pass1_vertex.glsl
Normal file
26
client/shaders/shadow_shaders/pass1_vertex.glsl
Normal file
|
@ -0,0 +1,26 @@
|
|||
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;
|
||||
|
||||
vec4 getPerspectiveFactor(in vec4 shadowPosition)
|
||||
{
|
||||
float pDistance = length(shadowPosition.xy);
|
||||
float pFactor = pDistance * bias0 + bias1;
|
||||
shadowPosition.xyz *= vec3(vec2(1.0 / pFactor), zPersFactor);
|
||||
|
||||
return shadowPosition;
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = LightMVP * gl_Vertex;
|
||||
|
||||
tPos = getPerspectiveFactor(pos);
|
||||
|
||||
gl_Position = vec4(tPos.xyz, 1.0);
|
||||
gl_TexCoord[0].st = gl_MultiTexCoord0.st;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue