mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Remove redundant stuff and other small fixes
This commit is contained in:
parent
1fa9731172
commit
45289b6919
6 changed files with 21 additions and 50 deletions
|
@ -40,12 +40,7 @@ uniform float animationTimer;
|
|||
varying float perspective_factor;
|
||||
#endif
|
||||
|
||||
uniform vec2 windowSize;
|
||||
uniform float fov;
|
||||
|
||||
varying vec3 vNormal;
|
||||
varying vec3 vTangent;
|
||||
varying vec3 vBinormal;
|
||||
varying vec3 vPosition;
|
||||
// World position in the visible world (i.e. relative to the cameraOffset.)
|
||||
// This can be used for many shader effects without loss of precision.
|
||||
|
@ -449,8 +444,6 @@ void main(void)
|
|||
|
||||
vec3 viewVec = normalize(worldPosition + cameraOffset - cameraPosition);
|
||||
|
||||
float adj_cosLight = cosLight;
|
||||
|
||||
if (f_shadow_strength > 0.0) {
|
||||
float shadow_int = 0.0;
|
||||
vec3 shadow_color = vec3(0.0, 0.0, 0.0);
|
||||
|
@ -465,14 +458,14 @@ void main(void)
|
|||
|
||||
#ifdef COLORED_SHADOWS
|
||||
vec4 visibility;
|
||||
if (adj_cosLight > 0.0 || f_normal_length < 1e-3)
|
||||
if (cosLight > 0.0 || f_normal_length < 1e-3)
|
||||
visibility = getShadowColor(ShadowMapSampler, posLightSpace.xy, posLightSpace.z);
|
||||
else
|
||||
visibility = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
shadow_int = visibility.r;
|
||||
shadow_color = visibility.gba;
|
||||
#else
|
||||
if (adj_cosLight > 0.0 || f_normal_length < 1e-3)
|
||||
if (cosLight > 0.0 || f_normal_length < 1e-3)
|
||||
shadow_int = getShadow(ShadowMapSampler, posLightSpace.xy, posLightSpace.z);
|
||||
else
|
||||
shadow_int = 1.0;
|
||||
|
@ -493,9 +486,9 @@ void main(void)
|
|||
// Cosine of the cut-off angle.
|
||||
const float self_shadow_cutoff_cosine = 0.035;
|
||||
|
||||
if (f_normal_length != 0 && adj_cosLight < self_shadow_cutoff_cosine) {
|
||||
shadow_int = max(shadow_int, 1 - clamp(adj_cosLight, 0.0, self_shadow_cutoff_cosine)/self_shadow_cutoff_cosine);
|
||||
shadow_color = mix(vec3(0.0), shadow_color, min(adj_cosLight, self_shadow_cutoff_cosine)/self_shadow_cutoff_cosine);
|
||||
if (f_normal_length != 0 && cosLight < self_shadow_cutoff_cosine) {
|
||||
shadow_int = max(shadow_int, 1 - clamp(cosLight, 0.0, self_shadow_cutoff_cosine)/self_shadow_cutoff_cosine);
|
||||
shadow_color = mix(vec3(0.0), shadow_color, min(cosLight, self_shadow_cutoff_cosine)/self_shadow_cutoff_cosine);
|
||||
|
||||
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES || MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS)
|
||||
// Prevents foliage from becoming insanely bright outside the shadow map.
|
||||
|
@ -518,12 +511,6 @@ void main(void)
|
|||
// Water reflections
|
||||
#if (defined(MATERIAL_WAVING_LIQUID) && defined(ENABLE_WATER_REFLECTIONS))
|
||||
|
||||
#if !ENABLE_WAVING_WATER
|
||||
#define WATER_WAVE_HEIGHT 0.5
|
||||
#define WATER_WAVE_SPEED 5.0
|
||||
#define WATER_WAVE_LENGTH 10.0
|
||||
#endif
|
||||
|
||||
vec3 wavePos = worldPosition * vec3(2.0, 0.0, 2.0);
|
||||
float off = animationTimer * WATER_WAVE_SPEED * 10.0;
|
||||
wavePos.x /= WATER_WAVE_LENGTH * 3.0;
|
||||
|
|
|
@ -450,7 +450,17 @@ void main(void)
|
|||
float clarity = clamp(fogShadingParameter
|
||||
- fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
|
||||
|
||||
#ifdef ENABLE_TINTED_FOG
|
||||
float fogColorMax = max(max(fogColor.r, fogColor.g), fogColor.b);
|
||||
// Prevent zero division.
|
||||
if (fogColorMax < 0.0000001) fogColorMax = 1.0;
|
||||
// For high clarity (light fog) we tint the fog color.
|
||||
// For this to not make the fog color artificially dark we need to normalize using the
|
||||
// fog color's brightest value. We then blend our base color with this to make the fog.
|
||||
col = mix(fogColor * pow(fogColor / fogColorMax, vec4(2.0 * clarity)), col, clarity);
|
||||
#else
|
||||
col = mix(fogColor, col, clarity);
|
||||
#endif
|
||||
|
||||
col = vec4(col.rgb, base.a);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue