mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Various fixes
Fix binormal and tangent Fix inconsistent sunrise/sunset timings and bright foliage at night
This commit is contained in:
parent
e7c7441429
commit
91f614cbee
4 changed files with 20 additions and 18 deletions
|
@ -51,6 +51,7 @@ centroid varying vec2 varTexCoord;
|
|||
#endif
|
||||
varying highp vec3 eyeVec;
|
||||
varying float nightRatio;
|
||||
varying float nightFactor;
|
||||
|
||||
#ifdef ENABLE_DYNAMIC_SHADOWS
|
||||
#if (MATERIAL_WAVING_LIQUID && defined(ENABLE_WATER_REFLECTIONS))
|
||||
|
@ -448,6 +449,7 @@ void main(void)
|
|||
if (max(abs(posLightSpace.x - 0.5), abs(posLightSpace.y - 0.5)) > 0.5)
|
||||
distance_rate = 0.0;
|
||||
float f_adj_shadow_strength = max(adj_shadow_strength - mtsmoothstep(0.9, 1.1, posLightSpace.z),0.0);
|
||||
float f_shadow_factor = adj_shadow_strength / f_shadow_strength;
|
||||
|
||||
if (distance_rate > 1e-7) {
|
||||
|
||||
|
@ -531,7 +533,7 @@ void main(void)
|
|||
mtsmoothstep(0.85, 0.9, pow(clamp(dot(reflect_ray, viewVec), 0.0, 1.0), 32.0));
|
||||
|
||||
// Sun reflection
|
||||
col.rgb += water_reflect_color * brightness_factor;
|
||||
col.rgb += water_reflect_color * f_shadow_factor * brightness_factor;
|
||||
#endif
|
||||
|
||||
#if (defined(ENABLE_NODE_SPECULAR) && !MATERIAL_WAVING_LIQUID)
|
||||
|
@ -543,14 +545,16 @@ void main(void)
|
|||
const float fresnel_exponent = 4.0;
|
||||
|
||||
col.rgb +=
|
||||
sunTint * intensity * dayLight * (1.0 - nightRatio) * (1.0 - shadow_uncorrected) *
|
||||
sunTint * intensity * f_shadow_factor * dayLight * (1.0 - nightRatio) * (1.0 - shadow_uncorrected) *
|
||||
pow(max(dot(reflect_ray, viewVec), 0.0), fresnel_exponent) * pow(1.0 - abs(dot(viewVec, fNormal)), specular_exponent);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES) && defined(ENABLE_TRANSLUCENT_FOLIAGE)
|
||||
// Simulate translucent foliage.
|
||||
col.rgb += foliage_translucency * sunTint * dayLight * base.rgb * normalize(base.rgb * varColor.rgb * varColor.rgb) * pow(max(-dot(v_LightDirection, viewVec), 0.0), 4.0) * max(1.0 - shadow_uncorrected, 0.0);
|
||||
col.rgb +=
|
||||
foliage_translucency * nightFactor * sunTint * dayLight * base.rgb * normalize(base.rgb * varColor.rgb * varColor.rgb) *
|
||||
pow(max(-dot(v_LightDirection, viewVec), 0.0), 4.0) * max(1.0 - shadow_uncorrected, 0.0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7,8 +7,6 @@ uniform highp vec3 cameraOffset;
|
|||
uniform float animationTimer;
|
||||
|
||||
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.
|
||||
|
@ -48,6 +46,7 @@ varying float area_enable_parallax;
|
|||
varying highp vec3 eyeVec;
|
||||
varying float nightRatio;
|
||||
varying vec3 sunTint;
|
||||
varying float nightFactor;
|
||||
// Color of the light emitted by the light sources.
|
||||
uniform vec3 artificialLight;
|
||||
const float e = 2.718281828459;
|
||||
|
@ -209,8 +208,6 @@ void main(void)
|
|||
normalPass = normalize((inVertexNormal+1)/2);
|
||||
#endif
|
||||
vNormal = inVertexNormal;
|
||||
vTangent = inVertexTangent.xyz;
|
||||
vBinormal = inVertexBinormal.xyz;
|
||||
|
||||
// Calculate color.
|
||||
vec4 color = inVertexColor;
|
||||
|
@ -272,6 +269,7 @@ void main(void)
|
|||
perspective_factor = pFactor;
|
||||
|
||||
sunTint = vec3(1.0);
|
||||
nightFactor = 0.;
|
||||
if (f_timeofday < 0.21) {
|
||||
adj_shadow_strength = f_shadow_strength * 0.5 *
|
||||
(1.0 - mtsmoothstep(0.18, 0.21, f_timeofday));
|
||||
|
@ -280,10 +278,11 @@ void main(void)
|
|||
mtsmoothstep(0.793, 0.823, f_timeofday);
|
||||
} else {
|
||||
adj_shadow_strength = f_shadow_strength *
|
||||
mtsmoothstep(0.21, 0.26, f_timeofday) *
|
||||
(1.0 - mtsmoothstep(0.743, 0.793, f_timeofday));
|
||||
mtsmoothstep(0.21, 0.24, f_timeofday) *
|
||||
(1.0 - mtsmoothstep(0.763, 0.793, f_timeofday));
|
||||
nightFactor = adj_shadow_strength / f_shadow_strength;
|
||||
#ifdef ENABLE_TINTED_SUNLIGHT
|
||||
sunTint = mix(vec3(1.0), getDirectLightScatteringAtGround(v_LightDirection), min(1.0, 4.0 * adj_shadow_strength));
|
||||
sunTint = mix(vec3(1.0), getDirectLightScatteringAtGround(v_LightDirection), adj_shadow_strength / f_shadow_strength);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,9 +182,9 @@ void main(void)
|
|||
mtsmoothstep(0.793, 0.823, f_timeofday);
|
||||
} else {
|
||||
adj_shadow_strength = f_shadow_strength *
|
||||
mtsmoothstep(0.21, 0.26, f_timeofday) *
|
||||
(1.0 - mtsmoothstep(0.743, 0.793, f_timeofday));
|
||||
sunTint = mix(vec3(1.0), getDirectLightScatteringAtGround(v_LightDirection), min(1.0, 4.0 * adj_shadow_strength));
|
||||
mtsmoothstep(0.21, 0.24, f_timeofday) *
|
||||
(1.0 - mtsmoothstep(0.763, 0.793, f_timeofday));
|
||||
sunTint = mix(vec3(1.0), getDirectLightScatteringAtGround(v_LightDirection), adj_shadow_strength / f_shadow_strength);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -674,11 +674,10 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
bool enable_waving_water = g_settings->getBool("enable_waving_water");
|
||||
shaders_header << "#define ENABLE_WAVING_WATER " << enable_waving_water << "\n";
|
||||
|
||||
if (enable_waving_water) {
|
||||
shaders_header << "#define WATER_WAVE_HEIGHT " << g_settings->getFloat("water_wave_height") << "\n";
|
||||
shaders_header << "#define WATER_WAVE_LENGTH " << g_settings->getFloat("water_wave_length") << "\n";
|
||||
shaders_header << "#define WATER_WAVE_SPEED " << g_settings->getFloat("water_wave_speed") << "\n";
|
||||
}
|
||||
shaders_header << "#define WATER_WAVE_HEIGHT " << g_settings->getFloat("water_wave_height") << "\n";
|
||||
shaders_header << "#define WATER_WAVE_LENGTH " << g_settings->getFloat("water_wave_length") << "\n";
|
||||
shaders_header << "#define WATER_WAVE_SPEED " << g_settings->getFloat("water_wave_speed") << "\n";
|
||||
|
||||
switch (material_type) {
|
||||
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
|
||||
case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue