Skip to content

Commit

Permalink
Fix always waving semitransparent liquid regression
Browse files Browse the repository at this point in the history
  • Loading branch information
Desour authored Jan 13, 2025
1 parent 636a734 commit 2bfcd45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions client/shaders/nodes_shader/opengl_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ centroid varying float nightRatio;
varying highp vec3 eyeVec;

#ifdef ENABLE_DYNAMIC_SHADOWS
#if (defined(ENABLE_WATER_REFLECTIONS) && MATERIAL_WAVING_LIQUID && ENABLE_WAVING_WATER)
#if (defined(ENABLE_WATER_REFLECTIONS) && MATERIAL_WATER_REFLECTIONS && ENABLE_WAVING_WATER)
vec4 perm(vec4 x)
{
return mod(((x * 34.0) + 1.0) * x, 289.0);
Expand Down Expand Up @@ -502,7 +502,7 @@ void main(void)
vec3 viewVec = normalize(worldPosition + cameraOffset - cameraPosition);

// Water reflections
#if (defined(ENABLE_WATER_REFLECTIONS) && MATERIAL_WAVING_LIQUID && ENABLE_WAVING_WATER)
#if (defined(ENABLE_WATER_REFLECTIONS) && MATERIAL_WATER_REFLECTIONS && ENABLE_WAVING_WATER)
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;
Expand Down Expand Up @@ -530,7 +530,7 @@ void main(void)
col.rgb += water_reflect_color * f_adj_shadow_strength * brightness_factor;
#endif

#if (defined(ENABLE_NODE_SPECULAR) && !MATERIAL_WAVING_LIQUID)
#if (defined(ENABLE_NODE_SPECULAR) && !MATERIAL_WATER_REFLECTIONS)
// Apply specular to blocks.
if (dot(v_LightDirection, vNormal) < 0.0) {
float intensity = 2.0 * (1.0 - (base.r * varColor.r));
Expand Down
12 changes: 11 additions & 1 deletion src/client/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,23 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
case TILE_MATERIAL_WAVING_LIQUID_BASIC:
case TILE_MATERIAL_LIQUID_TRANSPARENT:
shaders_header << "#define MATERIAL_WAVING_LIQUID 1\n";
break;
default:
shaders_header << "#define MATERIAL_WAVING_LIQUID 0\n";
break;
}
switch (material_type) {
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
case TILE_MATERIAL_WAVING_LIQUID_BASIC:
case TILE_MATERIAL_LIQUID_TRANSPARENT:
shaders_header << "#define MATERIAL_WATER_REFLECTIONS 1\n";
break;
default:
shaders_header << "#define MATERIAL_WATER_REFLECTIONS 0\n";
break;
}

shaders_header << "#define ENABLE_WAVING_LEAVES " << g_settings->getBool("enable_waving_leaves") << "\n";
shaders_header << "#define ENABLE_WAVING_PLANTS " << g_settings->getBool("enable_waving_plants") << "\n";
Expand Down

0 comments on commit 2bfcd45

Please sign in to comment.