Add (potentially physically-flawed) shadow support to the water shader

pull/1547/head
AnyOldName3 7 years ago
parent ab669a434e
commit e15d461921

@ -142,6 +142,9 @@ uniform vec3 nodePosition;
uniform float rainIntensity;
uniform sampler2DShadow shadowTexture0;
varying vec4 shadowSpaceCoords;
float frustumDepth;
float linearizeDepth(float depth) // takes <0,1> non-linear depth value and returns <0,1> linearized value
@ -158,7 +161,7 @@ void main(void)
vec2 UV = worldPos.xy / (8192.0*5.0) * 3.0;
UV.y *= -1.0;
float shadow = 1.0;
float shadow = shadow2DProj(shadowTexture0, shadowSpaceCoords).r;
vec2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
screenCoords.y = (1.0-screenCoords.y);

@ -4,6 +4,8 @@ varying vec3 screenCoordsPassthrough;
varying vec4 position;
varying float depthPassthrough;
varying vec4 shadowSpaceCoords;
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
@ -19,4 +21,8 @@ void main(void)
position = gl_Vertex;
depthPassthrough = gl_Position.z;
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
mat4 eyePlaneMat = mat4(gl_EyePlaneS[1], gl_EyePlaneT[1], gl_EyePlaneR[1], gl_EyePlaneQ[1]);
shadowSpaceCoords = (gl_ModelViewMatrix * gl_Vertex) * eyePlaneMat;
}

Loading…
Cancel
Save