1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-17 15:15:27 +01:00

More minor shader cleanups

This commit is contained in:
sfan5
2025-11-12 17:48:36 +01:00
parent 4cbe7b2597
commit 00eea43131
7 changed files with 36 additions and 38 deletions

View File

@@ -4,7 +4,6 @@ uniform float animationTimer;
uniform lowp vec4 materialColor;
VARYING_ vec3 vNormal;
VARYING_ vec3 vPosition;
VARYING_ vec3 worldPosition;
VARYING_ lowp vec4 varColor;
CENTROID_ VARYING_ mediump vec2 varTexCoord;
@@ -32,14 +31,13 @@ VARYING_ float nightRatio;
// Color of the light emitted by the light sources.
const vec3 artificialLight = vec3(1.04, 1.04, 1.04);
VARYING_ float vIDiff;
const float e = 2.718281828459;
const float BS = 10.0;
#ifdef ENABLE_DYNAMIC_SHADOWS
uniform float xyPerspectiveBias0;
uniform float xyPerspectiveBias1;
uniform float zPerspectiveBias;
#ifdef ENABLE_DYNAMIC_SHADOWS
vec4 getRelativePosition(in vec4 position)
{
vec2 l = position.xy - CameraPos.xy;
@@ -66,8 +64,9 @@ vec4 applyPerspectiveDistortion(in vec4 position)
return position;
}
// custom smoothstep implementation because it's not defined in glsl1.2
// https://docs.gl/sl4/smoothstep
#if __VERSION__ >= 130
#define mtsmoothstep smoothstep
#else
float mtsmoothstep(in float edge0, in float edge1, in float x)
{
float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
@@ -75,6 +74,8 @@ float mtsmoothstep(in float edge0, in float edge1, in float x)
}
#endif
#endif
float directional_ambient(vec3 normal)
{
@@ -95,7 +96,6 @@ void main(void)
gl_Position = mWorldViewProj * inVertexPosition;
vPosition = gl_Position.xyz;
vNormal = (mWorld * vec4(inVertexNormal, 0.0)).xyz;
worldPosition = (mWorld * inVertexPosition).xyz;
eyeVec = -(mWorldView * inVertexPosition).xyz;