diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 64e1cb197..41cb2cf8c 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -485,22 +485,19 @@ enable_waving_water (Waving liquids) bool false # 0.0 = Wave doesn't move at all. # Default is 1.0 (1/2 node). # -# Requires: enable_waving_water water_wave_height (Waving liquids wave height) float 1.0 0.0 4.0 # Length of liquid waves. # -# Requires: enable_waving_water water_wave_length (Waving liquids wavelength) float 20.0 0.1 # How fast liquid waves will move. Higher = faster. # If negative, liquid waves will move backwards. # -# Requires: enable_waving_water water_wave_speed (Waving liquids wave speed) float 5.0 # When enabled, crude liquid reflections are simulated. -# When waving liquids are enabled, the wave parameters will affect these reflections. +# Wave height, length and speed will affect these reflections. # # Requires: enable_dynamic_shadows enable_water_reflections (Liquid reflections) bool false diff --git a/client/shaders/nodes_shader/opengl_fragment.glsl b/client/shaders/nodes_shader/opengl_fragment.glsl index 75585d9c4..b0cc7c266 100644 --- a/client/shaders/nodes_shader/opengl_fragment.glsl +++ b/client/shaders/nodes_shader/opengl_fragment.glsl @@ -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; diff --git a/client/shaders/object_shader/opengl_fragment.glsl b/client/shaders/object_shader/opengl_fragment.glsl index b41e234e1..504a10964 100644 --- a/client/shaders/object_shader/opengl_fragment.glsl +++ b/client/shaders/object_shader/opengl_fragment.glsl @@ -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); diff --git a/doc/lua_api.md b/doc/lua_api.md index 96eb38fa2..f99e2eea8 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -8827,7 +8827,7 @@ child will follow movement and rotation of that bone. * This may be used to create effects like differently colored sunsets on alien planets. * Setting all components to zero effectively disables tinted sunlight. * `vignette`: is a table that controls the vignette post-processing effect. - * This has no effect on clients who have the "Vignette" effects disabled. + * This has no effect on clients who have post processing disabled. * `dark`: brightness of the vignette's darkest part (default: `1.0`) * `bright`: brightness of the vignette's brightest part (default: `1.0`) * `power`: the higher this is set, the more the vignette "retreats" to the edges of the screen (default: `1.0`) diff --git a/src/client/game.cpp b/src/client/game.cpp index b27db749b..a7555b55d 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -373,10 +373,6 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter CachedPixelShaderSetting m_camera_offset_pixel{ "cameraOffset" }; CachedVertexShaderSetting m_camera_position_vertex{"cameraPosition"}; CachedPixelShaderSetting m_camera_position_pixel{"cameraPosition"}; - CachedVertexShaderSetting m_camera_projinv_vertex{"mCameraProjInv"}; - CachedPixelShaderSetting m_camera_projinv_pixel{"mCameraProjInv"}; - CachedVertexShaderSetting m_camera_view_vertex{"mCameraView"}; - CachedPixelShaderSetting m_camera_view_pixel{"mCameraView"}; CachedPixelShaderSetting m_texture0{"texture0"}; CachedPixelShaderSetting m_texture1{"texture1"}; CachedPixelShaderSetting m_texture2{"texture2"}; @@ -418,8 +414,6 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter CachedPixelShaderSetting m_vignette_dark_pixel{"vignette_dark"}; CachedPixelShaderSetting m_vignette_bright_pixel{"vignette_bright"}; CachedPixelShaderSetting m_vignette_power_pixel{"vignette_power"}; - CachedPixelShaderSetting m_fov_pixel{"fov"}; - CachedPixelShaderSetting m_window_size_pixel{"windowSize"}; static constexpr std::array SETTING_CALLBACKS = { "exposure_compensation", @@ -488,22 +482,6 @@ public: m_camera_position_vertex.set(camera_position, services); m_camera_position_pixel.set(camera_position, services); - core::matrix4 camera_proj = m_client->getCamera()->getCameraNode()->getProjectionMatrix(); - core::matrix4 camera_projinv; - camera_proj.getInverse(camera_projinv); - m_camera_projinv_vertex.set(camera_projinv, services); - m_camera_projinv_pixel.set(camera_projinv, services); - - core::matrix4 camera_view = m_client->getCamera()->getCameraNode()->getViewMatrix(); - m_camera_view_vertex.set(camera_view, services); - m_camera_view_pixel.set(camera_view, services); - - float fov = m_client->getCamera()->getFovMax(); - m_fov_pixel.set(&fov, services); - v2u32 window_size_int = RenderingEngine::getWindowSize(); - core::vector2df window_size = core::vector2df(window_size_int.X, window_size_int.Y); - m_window_size_pixel.set(window_size, services); - SamplerLayer_t tex_id; tex_id = 0; m_texture0.set(&tex_id, services); diff --git a/src/client/shader.cpp b/src/client/shader.cpp index 139d82a2f..ddb0f8f85 100644 --- a/src/client/shader.cpp +++ b/src/client/shader.cpp @@ -659,11 +659,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"; 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";