Drop fixed pipeline support code (#15421)

OpenGL 2.0 is now mandatory.
This commit is contained in:
sfan5 2024-11-13 14:24:01 +01:00 committed by GitHub
parent 0fde9ab7e8
commit 794aea8e92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 117 additions and 411 deletions

@ -19,8 +19,6 @@
local component_funcs = dofile(core.get_mainmenu_path() .. DIR_DELIM .. local component_funcs = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
"settings" .. DIR_DELIM .. "components.lua") "settings" .. DIR_DELIM .. "components.lua")
local shader_warning_component = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
"settings" .. DIR_DELIM .. "shader_warning_component.lua")
local shadows_component = dofile(core.get_mainmenu_path() .. DIR_DELIM .. local shadows_component = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
"settings" .. DIR_DELIM .. "shadows_component.lua") "settings" .. DIR_DELIM .. "shadows_component.lua")
@ -154,12 +152,7 @@ local function load()
table.insert(page_by_id.controls_keyboard_and_mouse.content, 1, change_keys) table.insert(page_by_id.controls_keyboard_and_mouse.content, 1, change_keys)
do do
local content = page_by_id.graphics_and_audio_graphics.content local content = page_by_id.graphics_and_audio_effects.content
table.insert(content, 1, shader_warning_component)
content = page_by_id.graphics_and_audio_effects.content
table.insert(content, 1, shader_warning_component)
local idx = table.indexof(content, "enable_dynamic_shadows") local idx = table.indexof(content, "enable_dynamic_shadows")
table.insert(content, idx, shadows_component) table.insert(content, idx, shadows_component)
@ -348,7 +341,6 @@ local function check_requirements(name, requires)
end end
local video_driver = core.get_active_driver() local video_driver = core.get_active_driver()
local shaders_support = video_driver == "opengl" or video_driver == "opengl3" or video_driver == "ogles2"
local touch_support = core.irrlicht_device_supports_touch() local touch_support = core.irrlicht_device_supports_touch()
local touch_controls = core.settings:get("touch_controls") local touch_controls = core.settings:get("touch_controls")
local special = { local special = {
@ -359,8 +351,6 @@ local function check_requirements(name, requires)
-- be used, so we show settings for both. -- be used, so we show settings for both.
touchscreen = touch_support and (touch_controls == "auto" or core.is_yes(touch_controls)), touchscreen = touch_support and (touch_controls == "auto" or core.is_yes(touch_controls)),
keyboard_mouse = not touch_support or (touch_controls == "auto" or not core.is_yes(touch_controls)), keyboard_mouse = not touch_support or (touch_controls == "auto" or not core.is_yes(touch_controls)),
shaders_support = shaders_support,
shaders = core.settings:get_bool("enable_shaders") and shaders_support,
opengl = video_driver == "opengl", opengl = video_driver == "opengl",
gles = video_driver:sub(1, 5) == "ogles", gles = video_driver:sub(1, 5) == "ogles",
} }

@ -1,26 +0,0 @@
-- Luanti
-- SPDX-License-Identifier: LGPL-2.1-or-later
return {
query_text = "Shaders",
requires = {
shaders_support = true,
shaders = false,
},
full_width = true,
get_formspec = function(self, avail_w)
local fs = {
"box[0,0;", avail_w, ",1.2;", mt_color_orange, "]",
"label[0.2,0.4;", fgettext("Shaders are disabled."), "]",
"label[0.2,0.8;", fgettext("This is not a recommended configuration."), "]",
"button[", avail_w - 2.2, ",0.2;2,0.8;fix_shader_warning;", fgettext("Enable"), "]",
}
return table.concat(fs, ""), 1.2
end,
on_submit = function(self, fields)
if fields.fix_shader_warning then
core.settings:remove("enable_shaders") -- default value is true
return true
end
end,
}

@ -61,7 +61,7 @@
# #
# # This is a comment # # This is a comment
# # # #
# # Requires: shaders, enable_dynamic_shadows, !enable_waving_leaves # # Requires: enable_dynamic_shadows, !enable_waving_leaves
# name (Readable name) type type_args # name (Readable name) type type_args
# #
# A requirement can be the name of a boolean setting or an engine-defined value. # A requirement can be the name of a boolean setting or an engine-defined value.
@ -69,8 +69,6 @@
# #
# * The value of a boolean setting, such as enable_dynamic_shadows # * The value of a boolean setting, such as enable_dynamic_shadows
# * An engine-defined value: # * An engine-defined value:
# * shaders_support (a video driver that supports shaders, may not be enabled)
# * shaders (both enable_shaders and shaders_support)
# * desktop / android # * desktop / android
# * touchscreen / keyboard_mouse # * touchscreen / keyboard_mouse
# * opengl / gles # * opengl / gles
@ -277,7 +275,6 @@ undersampling (Undersampling) int 1 1 8
# - topbottom: split screen top/bottom. # - topbottom: split screen top/bottom.
# - sidebyside: split screen side by side. # - sidebyside: split screen side by side.
# - crossview: Cross-eyed 3d # - crossview: Cross-eyed 3d
# Note that the interlaced mode requires shaders to be enabled.
3d_mode (3D mode) enum none none,anaglyph,interlaced,topbottom,sidebyside,crossview 3d_mode (3D mode) enum none none,anaglyph,interlaced,topbottom,sidebyside,crossview
# Strength of 3D mode parallax. # Strength of 3D mode parallax.
@ -416,11 +413,11 @@ anisotropic_filter (Anisotropic filtering) bool false
# Smoothens out block edges but does not affect the insides of textures. # Smoothens out block edges but does not affect the insides of textures.
# A restart is required to change this option. # A restart is required to change this option.
# #
# * FXAA - Fast approximate antialiasing (requires shaders) # * FXAA - Fast approximate antialiasing
# Applies a post-processing filter to detect and smoothen high-contrast edges. # Applies a post-processing filter to detect and smoothen high-contrast edges.
# Provides balance between speed and image quality. # Provides balance between speed and image quality.
# #
# * SSAA - Super-sampling antialiasing (requires shaders) # * SSAA - Super-sampling antialiasing
# Renders higher-resolution image of the scene, then scales down to reduce # Renders higher-resolution image of the scene, then scales down to reduce
# the aliasing effects. This is the slowest and the most accurate method. # the aliasing effects. This is the slowest and the most accurate method.
antialiasing (Antialiasing method) enum none none,fsaa,fxaa,ssaa antialiasing (Antialiasing method) enum none none,fsaa,fxaa,ssaa
@ -473,18 +470,12 @@ enable_particles (Digging particles) bool true
[**Waving Nodes] [**Waving Nodes]
# Set to true to enable waving leaves. # Set to true to enable waving leaves.
#
# Requires: shaders
enable_waving_leaves (Waving leaves) bool false enable_waving_leaves (Waving leaves) bool false
# Set to true to enable waving plants. # Set to true to enable waving plants.
#
# Requires: shaders
enable_waving_plants (Waving plants) bool false enable_waving_plants (Waving plants) bool false
# Set to true to enable waving liquids (like water). # Set to true to enable waving liquids (like water).
#
# Requires: shaders
enable_waving_water (Waving liquids) bool false enable_waving_water (Waving liquids) bool false
# The maximum height of the surface of waving liquids. # The maximum height of the surface of waving liquids.
@ -492,70 +483,70 @@ enable_waving_water (Waving liquids) bool false
# 0.0 = Wave doesn't move at all. # 0.0 = Wave doesn't move at all.
# Default is 1.0 (1/2 node). # Default is 1.0 (1/2 node).
# #
# Requires: shaders, enable_waving_water # Requires: enable_waving_water
water_wave_height (Waving liquids wave height) float 1.0 0.0 4.0 water_wave_height (Waving liquids wave height) float 1.0 0.0 4.0
# Length of liquid waves. # Length of liquid waves.
# #
# Requires: shaders, enable_waving_water # Requires: enable_waving_water
water_wave_length (Waving liquids wavelength) float 20.0 0.1 water_wave_length (Waving liquids wavelength) float 20.0 0.1
# How fast liquid waves will move. Higher = faster. # How fast liquid waves will move. Higher = faster.
# If negative, liquid waves will move backwards. # If negative, liquid waves will move backwards.
# #
# Requires: shaders, enable_waving_water # Requires: enable_waving_water
water_wave_speed (Waving liquids wave speed) float 5.0 water_wave_speed (Waving liquids wave speed) float 5.0
[**Dynamic shadows] [**Dynamic shadows]
# Set to true to enable Shadow Mapping. # Set to true to enable Shadow Mapping.
# #
# Requires: shaders, opengl # Requires: opengl
enable_dynamic_shadows (Dynamic shadows) bool false enable_dynamic_shadows (Dynamic shadows) bool false
# Set the shadow strength gamma. # Set the shadow strength gamma.
# Adjusts the intensity of in-game dynamic shadows. # Adjusts the intensity of in-game dynamic shadows.
# Lower value means lighter shadows, higher value means darker shadows. # Lower value means lighter shadows, higher value means darker shadows.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_strength_gamma (Shadow strength gamma) float 1.0 0.1 10.0 shadow_strength_gamma (Shadow strength gamma) float 1.0 0.1 10.0
# Maximum distance to render shadows. # Maximum distance to render shadows.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_map_max_distance (Shadow map max distance in nodes to render shadows) float 140.0 10.0 1000.0 shadow_map_max_distance (Shadow map max distance in nodes to render shadows) float 140.0 10.0 1000.0
# Texture size to render the shadow map on. # Texture size to render the shadow map on.
# This must be a power of two. # This must be a power of two.
# Bigger numbers create better shadows but it is also more expensive. # Bigger numbers create better shadows but it is also more expensive.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_map_texture_size (Shadow map texture size) int 2048 128 8192 shadow_map_texture_size (Shadow map texture size) int 2048 128 8192
# Sets shadow texture quality to 32 bits. # Sets shadow texture quality to 32 bits.
# On false, 16 bits texture will be used. # On false, 16 bits texture will be used.
# This can cause much more artifacts in the shadow. # This can cause much more artifacts in the shadow.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_map_texture_32bit (Shadow map texture in 32 bits) bool true shadow_map_texture_32bit (Shadow map texture in 32 bits) bool true
# Enable Poisson disk filtering. # Enable Poisson disk filtering.
# On true uses Poisson disk to make "soft shadows". Otherwise uses PCF filtering. # On true uses Poisson disk to make "soft shadows". Otherwise uses PCF filtering.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_poisson_filter (Poisson filtering) bool true shadow_poisson_filter (Poisson filtering) bool true
# Define shadow filtering quality. # Define shadow filtering quality.
# This simulates the soft shadows effect by applying a PCF or Poisson disk # This simulates the soft shadows effect by applying a PCF or Poisson disk
# but also uses more resources. # but also uses more resources.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_filters (Shadow filter quality) enum 1 0,1,2 shadow_filters (Shadow filter quality) enum 1 0,1,2
# Enable colored shadows. # Enable colored shadows.
# On true translucent nodes cast colored shadows. This is expensive. # On true translucent nodes cast colored shadows. This is expensive.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_map_color (Colored shadows) bool false shadow_map_color (Colored shadows) bool false
# Spread a complete update of shadow map over given number of frames. # Spread a complete update of shadow map over given number of frames.
@ -563,28 +554,26 @@ shadow_map_color (Colored shadows) bool false
# will consume more resources. # will consume more resources.
# Minimum value: 1; maximum value: 16 # Minimum value: 1; maximum value: 16
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_update_frames (Map shadows update frames) int 8 1 16 shadow_update_frames (Map shadows update frames) int 8 1 16
# Set the soft shadow radius size. # Set the soft shadow radius size.
# Lower values mean sharper shadows, bigger values mean softer shadows. # Lower values mean sharper shadows, bigger values mean softer shadows.
# Minimum value: 1.0; maximum value: 15.0 # Minimum value: 1.0; maximum value: 15.0
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_soft_radius (Soft shadow radius) float 5.0 1.0 15.0 shadow_soft_radius (Soft shadow radius) float 5.0 1.0 15.0
# Set the default tilt of Sun/Moon orbit in degrees. # Set the default tilt of Sun/Moon orbit in degrees.
# Games may change orbit tilt via API. # Games may change orbit tilt via API.
# Value of 0 means no tilt / vertical orbit. # Value of 0 means no tilt / vertical orbit.
# #
# Requires: shaders, enable_dynamic_shadows, opengl # Requires: enable_dynamic_shadows, opengl
shadow_sky_body_orbit_tilt (Sky Body Orbit Tilt) float 0.0 -60.0 60.0 shadow_sky_body_orbit_tilt (Sky Body Orbit Tilt) float 0.0 -60.0 60.0
[**Post Processing] [**Post Processing]
# Enables the post processing pipeline. # Enables the post processing pipeline.
#
# Requires: shaders
enable_post_processing (Enable Post Processing) bool true enable_post_processing (Enable Post Processing) bool true
# Enables Hable's 'Uncharted 2' filmic tone mapping. # Enables Hable's 'Uncharted 2' filmic tone mapping.
@ -592,7 +581,7 @@ enable_post_processing (Enable Post Processing) bool true
# appearance of high dynamic range images. Mid-range contrast is slightly # appearance of high dynamic range images. Mid-range contrast is slightly
# enhanced, highlights and shadows are gradually compressed. # enhanced, highlights and shadows are gradually compressed.
# #
# Requires: shaders, enable_post_processing # Requires: enable_post_processing
tone_mapping (Filmic tone mapping) bool false tone_mapping (Filmic tone mapping) bool false
# Enable automatic exposure correction # Enable automatic exposure correction
@ -600,14 +589,14 @@ tone_mapping (Filmic tone mapping) bool false
# automatically adjust to the brightness of the scene, # automatically adjust to the brightness of the scene,
# simulating the behavior of human eye. # simulating the behavior of human eye.
# #
# Requires: shaders, enable_post_processing # Requires: enable_post_processing
enable_auto_exposure (Enable Automatic Exposure) bool false enable_auto_exposure (Enable Automatic Exposure) bool false
# Set the exposure compensation in EV units. # Set the exposure compensation in EV units.
# Value of 0.0 (default) means no exposure compensation. # Value of 0.0 (default) means no exposure compensation.
# Range: from -1 to 1.0 # Range: from -1 to 1.0
# #
# Requires: shaders, enable_post_processing, enable_auto_exposure # Requires: enable_post_processing, enable_auto_exposure
exposure_compensation (Exposure compensation) float 0.0 -1.0 1.0 exposure_compensation (Exposure compensation) float 0.0 -1.0 1.0
# Apply dithering to reduce color banding artifacts. # Apply dithering to reduce color banding artifacts.
@ -618,35 +607,35 @@ exposure_compensation (Exposure compensation) float 0.0 -1.0 1.0
# With OpenGL ES, dithering only works if the shader supports high # With OpenGL ES, dithering only works if the shader supports high
# floating-point precision and it may have a higher performance impact. # floating-point precision and it may have a higher performance impact.
# #
# Requires: shaders, enable_post_processing # Requires: enable_post_processing
debanding (Enable Debanding) bool true debanding (Enable Debanding) bool true
# Set to true to enable bloom effect. # Set to true to enable bloom effect.
# Bright colors will bleed over the neighboring objects. # Bright colors will bleed over the neighboring objects.
# #
# Requires: shaders, enable_post_processing # Requires: enable_post_processing
enable_bloom (Enable Bloom) bool false enable_bloom (Enable Bloom) bool false
# Set to true to enable volumetric lighting effect (a.k.a. "Godrays"). # Set to true to enable volumetric lighting effect (a.k.a. "Godrays").
# #
# Requires: shaders, enable_post_processing, enable_bloom # Requires: enable_post_processing, enable_bloom
enable_volumetric_lighting (Volumetric lighting) bool false enable_volumetric_lighting (Volumetric lighting) bool false
[**Other Effects] [**Other Effects]
# Simulate translucency when looking at foliage in the sunlight. # Simulate translucency when looking at foliage in the sunlight.
# #
# Requires: shaders, enable_dynamic_shadows # Requires: enable_dynamic_shadows
enable_translucent_foliage (Translucent foliage) bool false enable_translucent_foliage (Translucent foliage) bool false
# Apply specular shading to nodes. # Apply specular shading to nodes.
# #
# Requires: shaders, enable_dynamic_shadows # Requires: enable_dynamic_shadows
enable_node_specular (Node specular) bool false enable_node_specular (Node specular) bool false
# When enabled, liquid reflections are simulated. # When enabled, liquid reflections are simulated.
# #
# Requires: shaders, enable_waving_water, enable_dynamic_shadows # Requires: enable_waving_water, enable_dynamic_shadows
enable_water_reflections (Liquid reflections) bool false enable_water_reflections (Liquid reflections) bool false
[*Audio] [*Audio]
@ -1837,14 +1826,7 @@ ignore_world_load_errors (Ignore world errors) bool false
[**Graphics] [**Graphics]
# Shaders are a fundamental part of rendering and enable advanced visual effects.
#
# Requires: shaders_support
enable_shaders (Shaders) bool true
# Path to shader directory. If no path is defined, default location will be used. # Path to shader directory. If no path is defined, default location will be used.
#
# Requires: shaders
shader_path (Shader path) path shader_path (Shader path) path
# The rendering back-end. # The rendering back-end.
@ -1864,10 +1846,6 @@ cloud_radius (Cloud radius) int 12 1 62
# Whether node texture animations should be desynchronized per mapblock. # Whether node texture animations should be desynchronized per mapblock.
desynchronize_mapblock_texture_animation (Desynchronize block animation) bool false desynchronize_mapblock_texture_animation (Desynchronize block animation) bool false
# Enables caching of facedir rotated meshes.
# This is only effective with shaders disabled.
enable_mesh_cache (Mesh cache) bool false
# Delay between mesh updates on the client in ms. Increasing this will slow # Delay between mesh updates on the client in ms. Increasing this will slow
# down the rate of mesh updates, thus reducing jitter on slower clients. # down the rate of mesh updates, thus reducing jitter on slower clients.
mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50 mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50
@ -1922,7 +1900,7 @@ opengl_debug (OpenGL debug) bool false
# top-left - processed base image, top-right - final image # top-left - processed base image, top-right - final image
# bottom-left - raw base image, bottom-right - bloom texture. # bottom-left - raw base image, bottom-right - bloom texture.
# #
# Requires: shaders, enable_post_processing, enable_bloom # Requires: enable_post_processing, enable_bloom
enable_bloom_debug (Enable Bloom Debug) bool false enable_bloom_debug (Enable Bloom Debug) bool false
[**Sound] [**Sound]

@ -3,8 +3,6 @@ All Luanti builds, including the Android variant, are based on the same code.
However, additional Java code is used for proper Android integration. However, additional Java code is used for proper Android integration.
## Controls ## Controls
Compared to Luanti binaries for PC, the Android port has limited functionality
due to limited capabilities of common devices. What can be done is described below:
While you're playing the game normally (that is, no menu or inventory is While you're playing the game normally (that is, no menu or inventory is
shown), the following controls are available: shown), the following controls are available:
@ -58,35 +56,25 @@ Mobile device generally have less RAM than PC, this setting limit how many mapbl
this setting limit max FPS (Frame per second). Default value is 60, which lowest Android device screen refresh rate commonly found, but if you're using an device have lower refresh rate, change this this setting limit max FPS (Frame per second). Default value is 60, which lowest Android device screen refresh rate commonly found, but if you're using an device have lower refresh rate, change this
## Requirements ## Requirements
The minimal and recommended system requirements for Luanti are listed below. The recommended system requirements for Luanti are listed below.
### CPU ### CPU
Supported architectures: Supported architectures:
1. ARM v7 1. ARMv7
2. ARM v8 2. AArch64
3. x86 3. x86
4. x86_64 4. x86_64
CPU architectures similar to ARM or x86 might run Luanti but are not tested.
### Minimum
1. Graphics API: OpenGL ES 1.0
* Shaders might not work correctly or work at all on OpenGL ES 1.0.
2. Android version: Android 4.1 (API Level 16)
3. Free RAM: 500 MB
4. Free storage: 100 MB
* More storage is highly recommended
### Recommended ### Recommended
1. Graphics API: OpenGL ES 2.0 1. Graphics API: OpenGL ES 2.0
2. Android version: Android 4.4 (API Level 19) or newer 2. Android version: Android 5 (API Level 21) or newer
3. Empty RAM: 850 MB 3. Free RAM: 1 GB
4. Free storage: 480 MB 4. Free storage: 500 MB
## Rendering ## Rendering
Unlike on PC, Android devices use OpenGL ES which less powerful than OpenGL, thus Unlike on PC, Android devices use OpenGL ES which less powerful than OpenGL, thus
some shader settings cannot be used on OpenGL ES. some shader settings cannot be used on OpenGL ES.
Changing the graphic driver setting to OpenGL will result in undesirable behavior. Changing the graphic driver setting to OpenGL will not work.
## Building Requirements ## Building Requirements
In order to build, your PC has to be set up to build Luanti in the usual In order to build, your PC has to be set up to build Luanti in the usual

@ -45,13 +45,8 @@ There's usually no reason to raise this unless the NDK drops older versions.
**Compilers**: gcc, clang and MSVC (exceptions exist) **Compilers**: gcc, clang and MSVC (exceptions exist)
**OpenGL** is an entirely different beast, there is no formal consensus on changing the requirements We require **OpenGL** 2.0 or ES 2.0, so shaders can be relied on.
and neither do we have an exact set of requirements. Graphics code should generally work on both. Newer features can be used as long as a fallback exists.
We still support OpenGL 1.4 without shaders (fixed-pipeline), which could be considered very unreasonable in 2024.
OpenGL ES 2.0 is supported for the sake of mobile platforms.
It has been [proposed](https://irc.minetest.net/minetest-dev/2022-08-18) moving to OpenGL 2.x or 3.0 with shaders required.
General **system requirements** are not bounded either. General **system requirements** are not bounded either.
Being able to play Luanti on a recent low-end phone is a reasonable target. Being able to play Luanti on a recent low-end phone is a reasonable target.

@ -130,10 +130,10 @@ void COpenGLExtensionHandler::initExtensions(video::IContextManager *cmgr, bool
{ {
const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8 *>(glGetString(GL_VERSION))); const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8 *>(glGetString(GL_VERSION)));
Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f)); Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f));
if (Version >= 102) if (Version >= 200)
os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); os::Printer::log("OpenGL driver version is 2.0 or newer.", ELL_INFORMATION);
else else
os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); os::Printer::log("OpenGL driver version is older than 2.0.", ELL_WARNING);
{ {
const char *t = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)); const char *t = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));

@ -33,16 +33,13 @@ Clouds::Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc,
m_seed(seed) m_seed(seed)
{ {
assert(ssrc); assert(ssrc);
m_enable_shaders = g_settings->getBool("enable_shaders");
m_material.BackfaceCulling = true; m_material.BackfaceCulling = true;
m_material.FogEnable = true; m_material.FogEnable = true;
m_material.AntiAliasing = video::EAAM_SIMPLE; m_material.AntiAliasing = video::EAAM_SIMPLE;
if (m_enable_shaders) { {
auto sid = ssrc->getShader("cloud_shader", TILE_MATERIAL_ALPHA); auto sid = ssrc->getShader("cloud_shader", TILE_MATERIAL_ALPHA);
m_material.MaterialType = ssrc->getShaderInfo(sid).material; m_material.MaterialType = ssrc->getShaderInfo(sid).material;
} else {
m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
} }
m_params = SkyboxDefaults::getCloudDefaults(); m_params = SkyboxDefaults::getCloudDefaults();
@ -119,15 +116,11 @@ void Clouds::updateMesh()
// Colors with primitive shading // Colors with primitive shading
video::SColorf c_top_f(m_color); video::SColorf c_top_f(1, 1, 1, 1);
video::SColorf c_side_1_f(m_color); video::SColorf c_side_1_f(1, 1, 1, 1);
video::SColorf c_side_2_f(m_color); video::SColorf c_side_2_f(1, 1, 1, 1);
video::SColorf c_bottom_f(m_color); video::SColorf c_bottom_f(1, 1, 1, 1);
if (m_enable_shaders) { const video::SColorf shadow = m_params.color_shadow;
// shader mixes the base color, set via ColorParam
c_top_f = c_side_1_f = c_side_2_f = c_bottom_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
}
video::SColorf shadow = m_params.color_shadow;
c_side_1_f.r *= shadow.r * 0.25f + 0.75f; c_side_1_f.r *= shadow.r * 0.25f + 0.75f;
c_side_1_f.g *= shadow.g * 0.25f + 0.75f; c_side_1_f.g *= shadow.g * 0.25f + 0.75f;
@ -385,7 +378,6 @@ void Clouds::render()
} }
m_material.BackfaceCulling = is3D(); m_material.BackfaceCulling = is3D();
if (m_enable_shaders)
m_material.ColorParam = m_color.toSColor(); m_material.ColorParam = m_color.toSColor();
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);

@ -169,7 +169,7 @@ private:
v3s16 m_camera_offset; v3s16 m_camera_offset;
bool m_camera_inside_cloud = false; bool m_camera_inside_cloud = false;
bool m_enable_shaders, m_enable_3d; bool m_enable_3d;
video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
CloudParams m_params; CloudParams m_params;
}; };

@ -349,8 +349,6 @@ bool GenericCAO::collideWithObjects() const
void GenericCAO::initialize(const std::string &data) void GenericCAO::initialize(const std::string &data)
{ {
processInitData(data); processInitData(data);
m_enable_shaders = g_settings->getBool("enable_shaders");
} }
void GenericCAO::processInitData(const std::string &data) void GenericCAO::processInitData(const std::string &data)
@ -603,7 +601,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
m_material_type_param = 0.5f; // May cut off alpha < 128 depending on m_material_type m_material_type_param = 0.5f; // May cut off alpha < 128 depending on m_material_type
if (m_enable_shaders) { {
IShaderSource *shader_source = m_client->getShaderSource(); IShaderSource *shader_source = m_client->getShaderSource();
MaterialType material_type; MaterialType material_type;
@ -616,13 +614,6 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
u32 shader_id = shader_source->getShader("object_shader", material_type, NDT_NORMAL); u32 shader_id = shader_source->getShader("object_shader", material_type, NDT_NORMAL);
m_material_type = shader_source->getShaderInfo(shader_id).material; m_material_type = shader_source->getShaderInfo(shader_id).material;
} else {
if (m_prop.use_texture_alpha) {
m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m_material_type_param = 1.0f / 256.f; // minimal alpha for texture rendering
} else {
m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
}
} }
auto grabMatrixNode = [this] { auto grabMatrixNode = [this] {
@ -688,9 +679,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
// Set material // Set material
setMaterial(buf->getMaterial()); setMaterial(buf->getMaterial());
if (m_enable_shaders) {
buf->getMaterial().ColorParam = c; buf->getMaterial().ColorParam = c;
}
// Add to mesh // Add to mesh
mesh->addMeshBuffer(buf); mesh->addMeshBuffer(buf);
@ -714,9 +703,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
// Set material // Set material
setMaterial(buf->getMaterial()); setMaterial(buf->getMaterial());
if (m_enable_shaders) {
buf->getMaterial().ColorParam = c; buf->getMaterial().ColorParam = c;
}
// Add to mesh // Add to mesh
mesh->addMeshBuffer(buf); mesh->addMeshBuffer(buf);
@ -741,8 +728,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
}); });
} else if (m_prop.visual == "mesh") { } else if (m_prop.visual == "mesh") {
grabMatrixNode(); grabMatrixNode();
// can't cache mesh if shaders disabled, since we modify vertices scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, true);
scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, m_enable_shaders);
if (mesh) { if (mesh) {
if (!checkMeshNormals(mesh)) { if (!checkMeshNormals(mesh)) {
infostream << "GenericCAO: recalculating normals for mesh " infostream << "GenericCAO: recalculating normals for mesh "
@ -795,7 +781,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
/* Set VBO hint */ /* Set VBO hint */
// wieldmesh sets its own hint, no need to handle it // wieldmesh sets its own hint, no need to handle it
if (m_enable_shaders && (m_meshnode || m_animated_meshnode)) { if (m_meshnode || m_animated_meshnode) {
// sprite uses vertex animation // sprite uses vertex animation
if (m_meshnode && m_prop.visual != "upright_sprite") if (m_meshnode && m_prop.visual != "upright_sprite")
m_meshnode->getMesh()->setHardwareMappingHint(scene::EHM_STATIC); m_meshnode->getMesh()->setHardwareMappingHint(scene::EHM_STATIC);
@ -893,10 +879,7 @@ void GenericCAO::updateLight(u32 day_night_ratio)
// Encode light into color, adding a small boost // Encode light into color, adding a small boost
// based on the entity glow. // based on the entity glow.
if (m_enable_shaders)
light = encode_light(light_at_pos, m_prop.glow); light = encode_light(light_at_pos, m_prop.glow);
else
final_color_blend(&light, light_at_pos, day_night_ratio);
if (light != m_last_light) { if (light != m_last_light) {
m_last_light = light; m_last_light = light;
@ -912,22 +895,11 @@ void GenericCAO::setNodeLight(const video::SColor &light_color)
return; return;
} }
if (m_enable_shaders) { {
auto *node = getSceneNode(); auto *node = getSceneNode();
if (!node) if (!node)
return; return;
setColorParam(node, light_color); setColorParam(node, light_color);
} else {
// TODO refactor vertex colors to be separate from the other vertex attributes
// instead of mutating meshes / buffers for everyone via setMeshColor.
// (Note: There are a couple more places here where setMeshColor is used.)
if (m_meshnode) {
setMeshColor(m_meshnode->getMesh(), light_color);
} else if (m_animated_meshnode) {
setMeshColor(m_animated_meshnode->getMesh(), light_color);
} else if (m_spritenode) {
m_spritenode->setColor(light_color);
}
} }
} }

@ -116,8 +116,6 @@ private:
// Material // Material
video::E_MATERIAL_TYPE m_material_type; video::E_MATERIAL_TYPE m_material_type;
f32 m_material_type_param; f32 m_material_type_param;
// Settings
bool m_enable_shaders = false;
bool visualExpiryRequired(const ObjectProperties &newprops) const; bool visualExpiryRequired(const ObjectProperties &newprops) const;

@ -67,8 +67,6 @@ MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector
nodedef(data->nodedef), nodedef(data->nodedef),
meshmanip(mm), meshmanip(mm),
blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE), blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE),
enable_mesh_cache(g_settings->getBool("enable_mesh_cache") &&
!data->m_smooth_lighting), // Mesh cache is not supported with smooth lighting
smooth_liquids(g_settings->getBool("enable_water_reflections")) smooth_liquids(g_settings->getBool("enable_water_reflections"))
{ {
} }
@ -1657,31 +1655,27 @@ void MapblockMeshGenerator::drawMeshNode()
} else if (cur_node.f->param_type_2 == CPT2_WALLMOUNTED || } else if (cur_node.f->param_type_2 == CPT2_WALLMOUNTED ||
cur_node.f->param_type_2 == CPT2_COLORED_WALLMOUNTED) { cur_node.f->param_type_2 == CPT2_COLORED_WALLMOUNTED) {
// Convert wallmounted to 6dfacedir. // Convert wallmounted to 6dfacedir.
// When cache enabled, it is already converted.
facedir = cur_node.n.getWallMounted(nodedef); facedir = cur_node.n.getWallMounted(nodedef);
if (!enable_mesh_cache)
facedir = wallmounted_to_facedir[facedir]; facedir = wallmounted_to_facedir[facedir];
} else if (cur_node.f->param_type_2 == CPT2_DEGROTATE || } else if (cur_node.f->param_type_2 == CPT2_DEGROTATE ||
cur_node.f->param_type_2 == CPT2_COLORED_DEGROTATE) { cur_node.f->param_type_2 == CPT2_COLORED_DEGROTATE) {
degrotate = cur_node.n.getDegRotate(nodedef); degrotate = cur_node.n.getDegRotate(nodedef);
} }
if (!data->m_smooth_lighting && cur_node.f->mesh_ptr[facedir] && !degrotate) { if (cur_node.f->mesh_ptr) {
// use cached meshes // clone and rotate mesh
private_mesh = false;
mesh = cur_node.f->mesh_ptr[facedir];
} else if (cur_node.f->mesh_ptr[0]) {
// no cache, clone and rotate mesh
private_mesh = true; private_mesh = true;
mesh = cloneMesh(cur_node.f->mesh_ptr[0]); mesh = cloneMesh(cur_node.f->mesh_ptr);
if (facedir) if (facedir)
rotateMeshBy6dFacedir(mesh, facedir); rotateMeshBy6dFacedir(mesh, facedir);
else if (degrotate) else if (degrotate)
rotateMeshXZby(mesh, 1.5f * degrotate); rotateMeshXZby(mesh, 1.5f * degrotate);
recalculateBoundingBox(mesh); recalculateBoundingBox(mesh);
meshmanip->recalculateNormals(mesh, true, false); meshmanip->recalculateNormals(mesh, true, false);
} else } else {
warningstream << "drawMeshNode(): missing mesh" << std::endl;
return; return;
}
int mesh_buffer_count = mesh->getMeshBufferCount(); int mesh_buffer_count = mesh->getMeshBufferCount();
for (int j = 0; j < mesh_buffer_count; j++) { for (int j = 0; j < mesh_buffer_count; j++) {

@ -60,9 +60,6 @@ private:
const v3s16 blockpos_nodes; const v3s16 blockpos_nodes;
// options
const bool enable_mesh_cache;
// current node // current node
struct { struct {
v3s16 p; v3s16 p;

@ -84,15 +84,11 @@ Hud::Hud(Client *client, LocalPlayer *player,
} }
// Initialize m_selection_material // Initialize m_selection_material
if (g_settings->getBool("enable_shaders")) {
IShaderSource *shdrsrc = client->getShaderSource(); IShaderSource *shdrsrc = client->getShaderSource();
{
auto shader_id = shdrsrc->getShader( auto shader_id = shdrsrc->getShader(
m_mode == HIGHLIGHT_HALO ? "selection_shader" : "default_shader", TILE_MATERIAL_ALPHA); m_mode == HIGHLIGHT_HALO ? "selection_shader" : "default_shader", TILE_MATERIAL_ALPHA);
m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material; m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material;
} else {
m_selection_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
} }
if (m_mode == HIGHLIGHT_BOX) { if (m_mode == HIGHLIGHT_BOX) {
@ -106,12 +102,9 @@ Hud::Hud(Client *client, LocalPlayer *player,
} }
// Initialize m_block_bounds_material // Initialize m_block_bounds_material
if (g_settings->getBool("enable_shaders")) { {
IShaderSource *shdrsrc = client->getShaderSource();
auto shader_id = shdrsrc->getShader("default_shader", TILE_MATERIAL_ALPHA); auto shader_id = shdrsrc->getShader("default_shader", TILE_MATERIAL_ALPHA);
m_block_bounds_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material; m_block_bounds_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material;
} else {
m_block_bounds_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
} }
m_block_bounds_material.Thickness = m_block_bounds_material.Thickness =
rangelim(g_settings->getS16("selectionbox_width"), 1, 5); rangelim(g_settings->getS16("selectionbox_width"), 1, 5);
@ -1171,6 +1164,7 @@ void drawItemStack(
auto &p = imesh->buffer_colors[j]; auto &p = imesh->buffer_colors[j];
p.applyOverride(c); p.applyOverride(c);
// TODO: could be moved to a shader
if (p.needColorize(c)) { if (p.needColorize(c)) {
buf->setDirty(scene::EBT_VERTEX); buf->setDirty(scene::EBT_VERTEX);
if (imesh->needs_shading) if (imesh->needs_shading)

@ -25,10 +25,9 @@
MeshMakeData MeshMakeData
*/ */
MeshMakeData::MeshMakeData(const NodeDefManager *ndef, u16 side_length, bool use_shaders): MeshMakeData::MeshMakeData(const NodeDefManager *ndef, u16 side_length):
side_length(side_length), side_length(side_length),
nodedef(ndef), nodedef(ndef)
m_use_shaders(use_shaders)
{} {}
void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos) void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos)
@ -267,7 +266,8 @@ u16 getSmoothLightTransparent(const v3s16 &p, const v3s16 &corner, MeshMakeData
return getSmoothLightCombined(p, dirs, data); return getSmoothLightCombined(p, dirs, data);
} }
void get_sunlight_color(video::SColorf *sunlight, u32 daynight_ratio){ void get_sunlight_color(video::SColorf *sunlight, u32 daynight_ratio)
{
f32 rg = daynight_ratio / 1000.0f - 0.04f; f32 rg = daynight_ratio / 1000.0f - 0.04f;
f32 b = (0.98f * daynight_ratio) / 1000.0f + 0.078f; f32 b = (0.98f * daynight_ratio) / 1000.0f + 0.078f;
sunlight->r = rg; sunlight->r = rg;
@ -594,14 +594,12 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
m_shdrsrc(client->getShaderSource()), m_shdrsrc(client->getShaderSource()),
m_bounding_sphere_center((data->side_length * 0.5f - 0.5f) * BS), m_bounding_sphere_center((data->side_length * 0.5f - 0.5f) * BS),
m_animation_force_timer(0), // force initial animation m_animation_force_timer(0), // force initial animation
m_last_crack(-1), m_last_crack(-1)
m_last_daynight_ratio((u32) -1)
{ {
ZoneScoped; ZoneScoped;
for (auto &m : m_mesh) for (auto &m : m_mesh)
m = make_irr<scene::SMesh>(); m = make_irr<scene::SMesh>();
m_enable_shaders = data->m_use_shaders;
auto mesh_grid = client->getMeshGrid(); auto mesh_grid = client->getMeshGrid();
v3s16 bp = data->m_blockpos; v3s16 bp = data->m_blockpos;
@ -695,30 +693,6 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
p.layer.texture = (*p.layer.frames)[0].texture; p.layer.texture = (*p.layer.frames)[0].texture;
} }
if (!m_enable_shaders) {
// Extract colors for day-night animation
// Dummy sunlight to handle non-sunlit areas
video::SColorf sunlight;
get_sunlight_color(&sunlight, 0);
std::map<u32, video::SColor> colors;
const u32 vertex_count = p.vertices.size();
for (u32 j = 0; j < vertex_count; j++) {
video::SColor *vc = &p.vertices[j].Color;
video::SColor copy = *vc;
if (vc->getAlpha() == 0) // No sunlight - no need to animate
final_color_blend(vc, copy, sunlight); // Finalize color
else // Record color to animate
colors[j] = copy;
// The sunlight ratio has been stored,
// delete alpha (for the final rendering).
vc->setAlpha(255);
}
if (!colors.empty())
m_daynight_diffs[{layer, i}] = std::move(colors);
}
// Create material // Create material
video::SMaterial material; video::SMaterial material;
material.BackfaceCulling = true; material.BackfaceCulling = true;
@ -729,12 +703,10 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
tex.MagFilter = video::ETMAGF_NEAREST; tex.MagFilter = video::ETMAGF_NEAREST;
}); });
if (m_enable_shaders) { {
material.MaterialType = m_shdrsrc->getShaderInfo( material.MaterialType = m_shdrsrc->getShaderInfo(
p.layer.shader_id).material; p.layer.shader_id).material;
p.layer.applyMaterialOptionsWithShaders(material); p.layer.applyMaterialOptionsWithShaders(material);
} else {
p.layer.applyMaterialOptions(material);
} }
scene::SMeshBuffer *buf = new scene::SMeshBuffer(); scene::SMeshBuffer *buf = new scene::SMeshBuffer();
@ -771,7 +743,6 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
// Check if animation is required for this mesh // Check if animation is required for this mesh
m_has_animation = m_has_animation =
!m_crack_materials.empty() || !m_crack_materials.empty() ||
!m_daynight_diffs.empty() ||
!m_animation_info.empty(); !m_animation_info.empty();
} }
@ -844,24 +815,6 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack,
buf->getMaterial().setTexture(0, frame.texture); buf->getMaterial().setTexture(0, frame.texture);
} }
// Day-night transition
if (!m_enable_shaders && (daynight_ratio != m_last_daynight_ratio)) {
video::SColorf day_color;
get_sunlight_color(&day_color, daynight_ratio);
for (auto &daynight_diff : m_daynight_diffs) {
auto *mesh = m_mesh[daynight_diff.first.first].get();
mesh->setDirty(scene::EBT_VERTEX); // force reload to VBO
scene::IMeshBuffer *buf = mesh->
getMeshBuffer(daynight_diff.first.second);
video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices();
for (const auto &j : daynight_diff.second)
final_color_blend(&(vertices[j.first].Color), j.second,
day_color);
}
m_last_daynight_ratio = daynight_ratio;
}
return true; return true;
} }

@ -35,9 +35,8 @@ struct MeshMakeData
u16 side_length; u16 side_length;
const NodeDefManager *nodedef; const NodeDefManager *nodedef;
bool m_use_shaders;
MeshMakeData(const NodeDefManager *ndef, u16 side_length, bool use_shaders); MeshMakeData(const NodeDefManager *ndef, u16 side_length);
/* /*
Copy block data manually (to allow optimizations by the caller) Copy block data manually (to allow optimizations by the caller)
@ -235,8 +234,6 @@ private:
f32 m_bounding_radius; f32 m_bounding_radius;
v3f m_bounding_sphere_center; v3f m_bounding_sphere_center;
bool m_enable_shaders;
// Must animate() be called before rendering? // Must animate() be called before rendering?
bool m_has_animation; bool m_has_animation;
int m_animation_force_timer; int m_animation_force_timer;
@ -252,14 +249,6 @@ private:
// Keys are pairs of (mesh index, buffer index in the mesh) // Keys are pairs of (mesh index, buffer index in the mesh)
std::map<std::pair<u8, u32>, AnimationInfo> m_animation_info; std::map<std::pair<u8, u32>, AnimationInfo> m_animation_info;
// Animation info: day/night transitions
// Last daynight_ratio value passed to animate()
u32 m_last_daynight_ratio;
// For each mesh and mesh buffer, stores pre-baked colors
// of sunlit vertices
// Keys are pairs of (mesh index, buffer index in the mesh)
std::map<std::pair<u8, u32>, std::map<u32, video::SColor > > m_daynight_diffs;
// list of all semitransparent triangles in the mapblock // list of all semitransparent triangles in the mapblock
std::vector<MeshTriangle> m_transparent_triangles; std::vector<MeshTriangle> m_transparent_triangles;
// Binary Space Partitioning tree for the block // Binary Space Partitioning tree for the block

@ -39,7 +39,6 @@ QueuedMeshUpdate::~QueuedMeshUpdate()
MeshUpdateQueue::MeshUpdateQueue(Client *client): MeshUpdateQueue::MeshUpdateQueue(Client *client):
m_client(client) m_client(client)
{ {
m_cache_enable_shaders = g_settings->getBool("enable_shaders");
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting"); m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
} }
@ -177,7 +176,7 @@ void MeshUpdateQueue::done(v3s16 pos)
void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q) void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
{ {
auto mesh_grid = m_client->getMeshGrid(); auto mesh_grid = m_client->getMeshGrid();
MeshMakeData *data = new MeshMakeData(m_client->ndef(), MAP_BLOCKSIZE * mesh_grid.cell_size, m_cache_enable_shaders); MeshMakeData *data = new MeshMakeData(m_client->ndef(), MAP_BLOCKSIZE * mesh_grid.cell_size);
q->data = data; q->data = data;
data->fillBlockDataBegin(q->p); data->fillBlockDataBegin(q->p);

@ -70,11 +70,9 @@ private:
std::mutex m_mutex; std::mutex m_mutex;
// TODO: Add callback to update these when g_settings changes // TODO: Add callback to update these when g_settings changes
bool m_cache_enable_shaders;
bool m_cache_smooth_lighting; bool m_cache_smooth_lighting;
void fillDataFromMapBlocks(QueuedMeshUpdate *q); void fillDataFromMapBlocks(QueuedMeshUpdate *q);
void cleanupCache();
}; };
struct MeshUpdateResult struct MeshUpdateResult

@ -173,7 +173,6 @@ Minimap::Minimap(Client *client)
m_current_mode_index = 0; m_current_mode_index = 0;
// Initialize static settings // Initialize static settings
m_enable_shaders = g_settings->getBool("enable_shaders");
m_surface_mode_scan_height = m_surface_mode_scan_height =
g_settings->getBool("minimap_double_scan_height") ? 256 : 128; g_settings->getBool("minimap_double_scan_height") ? 256 : 128;
@ -599,7 +598,7 @@ void Minimap::drawMinimap(core::rect<s32> rect)
material.TextureLayers[0].Texture = minimap_texture; material.TextureLayers[0].Texture = minimap_texture;
material.TextureLayers[1].Texture = data->heightmap_texture; material.TextureLayers[1].Texture = data->heightmap_texture;
if (m_enable_shaders && data->mode.type == MINIMAP_TYPE_SURFACE) { if (data->mode.type == MINIMAP_TYPE_SURFACE) {
auto sid = m_shdrsrc->getShader("minimap_shader", TILE_MATERIAL_ALPHA); auto sid = m_shdrsrc->getShader("minimap_shader", TILE_MATERIAL_ALPHA);
material.MaterialType = m_shdrsrc->getShaderInfo(sid).material; material.MaterialType = m_shdrsrc->getShaderInfo(sid).material;
} else { } else {

@ -152,7 +152,6 @@ private:
const NodeDefManager *m_ndef; const NodeDefManager *m_ndef;
std::unique_ptr<MinimapUpdateThread> m_minimap_update_thread; std::unique_ptr<MinimapUpdateThread> m_minimap_update_thread;
irr_ptr<scene::SMeshBuffer> m_meshbuffer; irr_ptr<scene::SMeshBuffer> m_meshbuffer;
bool m_enable_shaders;
std::vector<MinimapModeDef> m_modes; std::vector<MinimapModeDef> m_modes;
size_t m_current_mode_index; size_t m_current_mode_index;
u16 m_surface_mode_scan_height; u16 m_surface_mode_scan_height;

@ -87,7 +87,7 @@ void UpscaleStep::run(PipelineContext &context)
std::unique_ptr<RenderStep> create3DStage(Client *client, v2f scale) std::unique_ptr<RenderStep> create3DStage(Client *client, v2f scale)
{ {
RenderStep *step = new Draw3D(); RenderStep *step = new Draw3D();
if (g_settings->getBool("enable_shaders") && g_settings->getBool("enable_post_processing")) { if (g_settings->getBool("enable_post_processing")) {
RenderPipeline *pipeline = new RenderPipeline(); RenderPipeline *pipeline = new RenderPipeline();
pipeline->addStep(pipeline->own(std::unique_ptr<RenderStep>(step))); pipeline->addStep(pipeline->own(std::unique_ptr<RenderStep>(step)));
@ -111,8 +111,8 @@ RenderStep* addUpscaling(RenderPipeline *pipeline, RenderStep *previousStep, v2f
if (downscale_factor.X == 1.0f && downscale_factor.Y == 1.0f) if (downscale_factor.X == 1.0f && downscale_factor.Y == 1.0f)
return previousStep; return previousStep;
// When shaders are enabled, post-processing pipeline takes care of rescaling // post-processing pipeline takes care of rescaling
if (g_settings->getBool("enable_shaders") && g_settings->getBool("enable_post_processing")) if (g_settings->getBool("enable_post_processing"))
return previousStep; return previousStep;

@ -307,9 +307,6 @@ public:
private: private:
// Are shaders even enabled?
bool m_enabled;
// The id of the thread that is allowed to use irrlicht directly // The id of the thread that is allowed to use irrlicht directly
std::thread::id m_main_thread; std::thread::id m_main_thread;
@ -348,12 +345,6 @@ ShaderSource::ShaderSource()
// Add a dummy ShaderInfo as the first index, named "" // Add a dummy ShaderInfo as the first index, named ""
m_shaderinfo_cache.emplace_back(); m_shaderinfo_cache.emplace_back();
m_enabled = g_settings->getBool("enable_shaders");
if (!m_enabled) {
warningstream << "You are running " PROJECT_NAME_C " with shaders disabled, "
"this is not a recommended configuration." << std::endl;
}
// Add main global constant setter // Add main global constant setter
addShaderConstantSetterFactory(new MainShaderConstantSetterFactory()); addShaderConstantSetterFactory(new MainShaderConstantSetterFactory());
} }
@ -362,11 +353,9 @@ ShaderSource::~ShaderSource()
{ {
MutexAutoLock lock(m_shaderinfo_cache_mutex); MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials // Delete materials
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices(); auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
assert(gpu);
for (ShaderInfo &i : m_shaderinfo_cache) { for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty()) if (!i.name.empty())
gpu->deleteShaderMaterial(i.material); gpu->deleteShaderMaterial(i.material);
@ -495,11 +484,9 @@ void ShaderSource::rebuildShaders()
{ {
MutexAutoLock lock(m_shaderinfo_cache_mutex); MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials // Delete materials
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices(); auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
assert(gpu);
for (ShaderInfo &i : m_shaderinfo_cache) { for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty()) { if (!i.name.empty()) {
gpu->deleteShaderMaterial(i.material); gpu->deleteShaderMaterial(i.material);
@ -546,14 +533,14 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
} }
shaderinfo.material = shaderinfo.base_material; shaderinfo.material = shaderinfo.base_material;
if (!m_enabled) video::IVideoDriver *driver = RenderingEngine::get_video_driver();
// The null driver doesn't support shaders (duh), but we can pretend it does.
if (driver->getDriverType() == video::EDT_NULL)
return shaderinfo; return shaderinfo;
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
auto *gpu = driver->getGPUProgrammingServices(); auto *gpu = driver->getGPUProgrammingServices();
if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) { if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) {
throw ShaderException(gettext("Shaders are enabled but GLSL is not " throw ShaderException(gettext("GLSL is not supported by the driver"));
"supported by the driver."));
} }
// Create shaders header // Create shaders header

@ -107,25 +107,13 @@ void ShadowRenderer::disable()
void ShadowRenderer::preInit(IWritableShaderSource *shsrc) void ShadowRenderer::preInit(IWritableShaderSource *shsrc)
{ {
if (g_settings->getBool("enable_shaders") && if (g_settings->getBool("enable_dynamic_shadows")) {
g_settings->getBool("enable_dynamic_shadows")) {
shsrc->addShaderConstantSetterFactory(new ShadowConstantSetterFactory()); shsrc->addShaderConstantSetterFactory(new ShadowConstantSetterFactory());
} }
} }
void ShadowRenderer::initialize() void ShadowRenderer::initialize()
{ {
auto *gpu = m_driver->getGPUProgrammingServices();
// we need glsl
if (!m_shadows_supported || !gpu || !m_driver->queryFeature(video::EVDF_ARB_GLSL)) {
m_shadows_supported = false;
warningstream << "Shadows: GLSL Shader not supported on this system."
<< std::endl;
return;
}
createShaders(); createShaders();
@ -533,7 +521,7 @@ void ShadowRenderer::mixShadowsQuad()
void ShadowRenderer::createShaders() void ShadowRenderer::createShaders()
{ {
video::IGPUProgrammingServices *gpu = m_driver->getGPUProgrammingServices(); auto *gpu = m_driver->getGPUProgrammingServices();
if (depth_shader == -1) { if (depth_shader == -1) {
std::string depth_shader_vs = getShaderPath("shadow_shaders", "pass1_vertex.glsl"); std::string depth_shader_vs = getShaderPath("shadow_shaders", "pass1_vertex.glsl");
@ -706,14 +694,12 @@ std::string ShadowRenderer::readShaderFile(const std::string &path)
ShadowRenderer *createShadowRenderer(IrrlichtDevice *device, Client *client) ShadowRenderer *createShadowRenderer(IrrlichtDevice *device, Client *client)
{ {
// disable if unsupported // disable if unsupported
if (g_settings->getBool("enable_dynamic_shadows") && ( if (g_settings->getBool("enable_dynamic_shadows") &&
device->getVideoDriver()->getDriverType() != video::EDT_OPENGL || device->getVideoDriver()->getDriverType() != video::EDT_OPENGL) {
!g_settings->getBool("enable_shaders"))) {
g_settings->setBool("enable_dynamic_shadows", false); g_settings->setBool("enable_dynamic_shadows", false);
} }
if (g_settings->getBool("enable_shaders") && if (g_settings->getBool("enable_dynamic_shadows")) {
g_settings->getBool("enable_dynamic_shadows")) {
ShadowRenderer *shadow_renderer = new ShadowRenderer(device, client); ShadowRenderer *shadow_renderer = new ShadowRenderer(device, client);
shadow_renderer->initialize(); shadow_renderer->initialize();
return shadow_renderer; return shadow_renderer;

@ -53,8 +53,6 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade
m_box.MaxEdge.set(0, 0, 0); m_box.MaxEdge.set(0, 0, 0);
m_box.MinEdge.set(0, 0, 0); m_box.MinEdge.set(0, 0, 0);
m_enable_shaders = g_settings->getBool("enable_shaders");
m_sky_params = SkyboxDefaults::getSkyDefaults(); m_sky_params = SkyboxDefaults::getSkyDefaults();
m_sun_params = SkyboxDefaults::getSunDefaults(); m_sun_params = SkyboxDefaults::getSunDefaults();
m_moon_params = SkyboxDefaults::getMoonDefaults(); m_moon_params = SkyboxDefaults::getMoonDefaults();
@ -63,9 +61,8 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade
// Create materials // Create materials
m_materials[0] = baseMaterial(); m_materials[0] = baseMaterial();
m_materials[0].MaterialType = m_enable_shaders ? m_materials[0].MaterialType =
ssrc->getShaderInfo(ssrc->getShader("stars_shader", TILE_MATERIAL_ALPHA)).material : ssrc->getShaderInfo(ssrc->getShader("stars_shader", TILE_MATERIAL_ALPHA)).material;
video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m_materials[1] = baseMaterial(); m_materials[1] = baseMaterial();
m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
@ -668,10 +665,7 @@ void Sky::draw_stars(video::IVideoDriver * driver, float wicked_time_of_day)
color.a *= alpha; color.a *= alpha;
if (color.a <= 0.0f) // Stars are only drawn when not fully transparent if (color.a <= 0.0f) // Stars are only drawn when not fully transparent
return; return;
if (m_enable_shaders)
m_materials[0].ColorParam = color.toSColor(); m_materials[0].ColorParam = color.toSColor();
else
setMeshBufferColor(m_stars.get(), color.toSColor());
auto sky_rotation = core::matrix4().setRotationAxisRadians(2.0f * M_PI * (wicked_time_of_day - 0.25f), v3f(0.0f, 0.0f, 1.0f)); auto sky_rotation = core::matrix4().setRotationAxisRadians(2.0f * M_PI * (wicked_time_of_day - 0.25f), v3f(0.0f, 0.0f, 1.0f));
auto world_matrix = driver->getTransform(video::ETS_WORLD); auto world_matrix = driver->getTransform(video::ETS_WORLD);
@ -841,7 +835,6 @@ void Sky::updateStars()
indices.push_back(i * 4 + 3); indices.push_back(i * 4 + 3);
indices.push_back(i * 4 + 0); indices.push_back(i * 4 + 0);
} }
if (m_enable_shaders)
m_stars->setHardwareMappingHint(scene::EHM_STATIC); m_stars->setHardwareMappingHint(scene::EHM_STATIC);
} }

@ -173,7 +173,6 @@ private:
bool m_clouds_enabled = true; // Initialised to true, reset only by set_sky API bool m_clouds_enabled = true; // Initialised to true, reset only by set_sky API
bool m_directional_colored_fog; bool m_directional_colored_fog;
bool m_in_clouds = true; // Prevent duplicating bools to remember old values bool m_in_clouds = true; // Prevent duplicating bools to remember old values
bool m_enable_shaders = false;
video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);

@ -78,7 +78,6 @@ struct TileLayer
return !(*this == other); return !(*this == other);
} }
// Sets everything else except the texture in the material
void applyMaterialOptions(video::SMaterial &material) const; void applyMaterialOptions(video::SMaterial &material) const;
void applyMaterialOptionsWithShaders(video::SMaterial &material) const; void applyMaterialOptionsWithShaders(video::SMaterial &material) const;

@ -184,7 +184,6 @@ WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id):
scene::ISceneNode(mgr->getRootSceneNode(), mgr, id), scene::ISceneNode(mgr->getRootSceneNode(), mgr, id),
m_material_type(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF) m_material_type(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
{ {
m_enable_shaders = g_settings->getBool("enable_shaders");
m_anisotropic_filter = g_settings->getBool("anisotropic_filter"); m_anisotropic_filter = g_settings->getBool("anisotropic_filter");
m_bilinear_filter = g_settings->getBool("bilinear_filter"); m_bilinear_filter = g_settings->getBool("bilinear_filter");
m_trilinear_filter = g_settings->getBool("trilinear_filter"); m_trilinear_filter = g_settings->getBool("trilinear_filter");
@ -233,7 +232,7 @@ void WieldMeshSceneNode::setCube(const ContentFeatures &f,
scene::IMesh *cubemesh = g_extrusion_mesh_cache->createCube(); scene::IMesh *cubemesh = g_extrusion_mesh_cache->createCube();
scene::SMesh *copy = cloneMesh(cubemesh); scene::SMesh *copy = cloneMesh(cubemesh);
cubemesh->drop(); cubemesh->drop();
postProcessNodeMesh(copy, f, false, true, &m_material_type, &m_colors, true); postProcessNodeMesh(copy, f, false, &m_material_type, &m_colors, true);
changeToMesh(copy); changeToMesh(copy);
copy->drop(); copy->drop();
m_meshnode->setScale(wield_scale * WIELD_SCALE_FACTOR); m_meshnode->setScale(wield_scale * WIELD_SCALE_FACTOR);
@ -297,7 +296,7 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n, static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n,
std::vector<ItemPartColor> *colors, const ContentFeatures &f) std::vector<ItemPartColor> *colors, const ContentFeatures &f)
{ {
MeshMakeData mesh_make_data(client->ndef(), 1, false); MeshMakeData mesh_make_data(client->ndef(), 1);
MeshCollector collector(v3f(0.0f * BS), v3f()); MeshCollector collector(v3f(0.0f * BS), v3f());
mesh_make_data.setSmoothLighting(false); mesh_make_data.setSmoothLighting(false);
MapblockMeshGenerator gen(&mesh_make_data, &collector, MapblockMeshGenerator gen(&mesh_make_data, &collector,
@ -354,10 +353,8 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che
scene::SMesh *mesh = nullptr; scene::SMesh *mesh = nullptr;
if (m_enable_shaders) {
u32 shader_id = shdrsrc->getShader("object_shader", TILE_MATERIAL_BASIC, NDT_NORMAL); u32 shader_id = shdrsrc->getShader("object_shader", TILE_MATERIAL_BASIC, NDT_NORMAL);
m_material_type = shdrsrc->getShaderInfo(shader_id).material; m_material_type = shdrsrc->getShaderInfo(shader_id).material;
}
// Color-related // Color-related
m_colors.clear(); m_colors.clear();
@ -500,10 +497,7 @@ void WieldMeshSceneNode::setColor(video::SColor c)
if (m_colors[j].needColorize(buffercolor)) { if (m_colors[j].needColorize(buffercolor)) {
buf->setDirty(scene::EBT_VERTEX); buf->setDirty(scene::EBT_VERTEX);
if (m_enable_shaders)
setMeshBufferColor(buf, buffercolor); setMeshBufferColor(buf, buffercolor);
else
colorizeMeshBuffer(buf, &buffercolor);
} }
} }
} }
@ -513,13 +507,11 @@ void WieldMeshSceneNode::setNodeLightColor(video::SColor color)
if (!m_meshnode) if (!m_meshnode)
return; return;
if (m_enable_shaders) { {
for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) { for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) {
video::SMaterial &material = m_meshnode->getMaterial(i); video::SMaterial &material = m_meshnode->getMaterial(i);
material.ColorParam = color; material.ColorParam = color;
} }
} else {
setColor(color);
} }
} }
@ -538,12 +530,7 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
dummymesh->drop(); // m_meshnode grabbed it dummymesh->drop(); // m_meshnode grabbed it
} else { } else {
m_meshnode->setMesh(mesh); m_meshnode->setMesh(mesh);
// without shaders recolored often for lighting
// otherwise only once
if (m_enable_shaders)
mesh->setHardwareMappingHint(scene::EHM_STATIC); mesh->setHardwareMappingHint(scene::EHM_STATIC);
else
mesh->setHardwareMappingHint(scene::EHM_DYNAMIC);
} }
m_meshnode->setVisible(true); m_meshnode->setVisible(true);
@ -596,7 +583,7 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
} else } else
scaleMesh(mesh, v3f(1.2, 1.2, 1.2)); scaleMesh(mesh, v3f(1.2, 1.2, 1.2));
// add overlays // add overlays
postProcessNodeMesh(mesh, f, false, false, nullptr, postProcessNodeMesh(mesh, f, false, nullptr,
&result->buffer_colors, true); &result->buffer_colors, true);
if (f.drawtype == NDT_ALLFACES) if (f.drawtype == NDT_ALLFACES)
scaleMesh(mesh, v3f(f.visual_scale)); scaleMesh(mesh, v3f(f.visual_scale));
@ -704,7 +691,7 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc,
} }
void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f, void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f,
bool use_shaders, bool set_material, const video::E_MATERIAL_TYPE *mattype, bool set_material, const video::E_MATERIAL_TYPE *mattype,
std::vector<ItemPartColor> *colors, bool apply_scale) std::vector<ItemPartColor> *colors, bool apply_scale)
{ {
const u32 mc = mesh->getMeshBufferCount(); const u32 mc = mesh->getMeshBufferCount();

@ -117,7 +117,6 @@ private:
scene::IMeshSceneNode *m_meshnode = nullptr; scene::IMeshSceneNode *m_meshnode = nullptr;
video::E_MATERIAL_TYPE m_material_type; video::E_MATERIAL_TYPE m_material_type;
bool m_enable_shaders;
bool m_anisotropic_filter; bool m_anisotropic_filter;
bool m_bilinear_filter; bool m_bilinear_filter;
bool m_trilinear_filter; bool m_trilinear_filter;
@ -152,6 +151,6 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc, const std::string &imagename
* be NULL to leave the original material. * be NULL to leave the original material.
* \param colors returns the colors of the mesh buffers in the mesh. * \param colors returns the colors of the mesh buffers in the mesh.
*/ */
void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f, bool use_shaders, void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f,
bool set_material, const video::E_MATERIAL_TYPE *mattype, bool set_material, const video::E_MATERIAL_TYPE *mattype,
std::vector<ItemPartColor> *colors, bool apply_scale = false); std::vector<ItemPartColor> *colors, bool apply_scale = false);

@ -102,7 +102,6 @@ void set_default_settings()
settings->setDefault("sound_volume_unfocused", "0.3"); settings->setDefault("sound_volume_unfocused", "0.3");
settings->setDefault("mute_sound", "false"); settings->setDefault("mute_sound", "false");
settings->setDefault("sound_extensions_blacklist", ""); settings->setDefault("sound_extensions_blacklist", "");
settings->setDefault("enable_mesh_cache", "false");
settings->setDefault("mesh_generation_interval", "0"); settings->setDefault("mesh_generation_interval", "0");
settings->setDefault("mesh_generation_threads", "0"); settings->setDefault("mesh_generation_threads", "0");
settings->setDefault("free_move", "false"); settings->setDefault("free_move", "false");
@ -299,7 +298,6 @@ void set_default_settings()
settings->setDefault("enable_local_map_saving", "false"); settings->setDefault("enable_local_map_saving", "false");
settings->setDefault("show_entity_selectionbox", "false"); settings->setDefault("show_entity_selectionbox", "false");
settings->setDefault("ambient_occlusion_gamma", "1.8"); settings->setDefault("ambient_occlusion_gamma", "1.8");
settings->setDefault("enable_shaders", "true");
settings->setDefault("enable_particles", "true"); settings->setDefault("enable_particles", "true");
settings->setDefault("arm_inertia", "true"); settings->setDefault("arm_inertia", "true");
settings->setDefault("show_nametag_backgrounds", "true"); settings->setDefault("show_nametag_backgrounds", "true");

@ -17,7 +17,6 @@ Environment::Environment(IGameDef *gamedef):
m_day_count(0), m_day_count(0),
m_gamedef(gamedef) m_gamedef(gamedef)
{ {
m_cache_enable_shaders = g_settings->getBool("enable_shaders");
m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval"); m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval");
m_cache_abm_interval = g_settings->getFloat("abm_interval"); m_cache_abm_interval = g_settings->getFloat("abm_interval");
m_cache_nodetimer_interval = g_settings->getFloat("nodetimer_interval"); m_cache_nodetimer_interval = g_settings->getFloat("nodetimer_interval");
@ -32,7 +31,7 @@ u32 Environment::getDayNightRatio()
MutexAutoLock lock(m_time_lock); MutexAutoLock lock(m_time_lock);
if (m_enable_day_night_ratio_override) if (m_enable_day_night_ratio_override)
return m_day_night_ratio_override; return m_day_night_ratio_override;
return time_to_daynight_ratio(m_time_of_day_f * 24000, m_cache_enable_shaders); return time_to_daynight_ratio(m_time_of_day_f * 24000, true);
} }
void Environment::setTimeOfDaySpeed(float speed) void Environment::setTimeOfDaySpeed(float speed)

@ -131,7 +131,6 @@ protected:
* (as opposed to the this local caching). This can be addressed in * (as opposed to the this local caching). This can be addressed in
* a later release. * a later release.
*/ */
bool m_cache_enable_shaders;
float m_cache_active_block_mgmt_interval; float m_cache_active_block_mgmt_interval;
float m_cache_abm_interval; float m_cache_abm_interval;
float m_cache_nodetimer_interval; float m_cache_nodetimer_interval;

@ -98,11 +98,6 @@ void GUIScene::draw()
if (m_inf_rot) if (m_inf_rot)
rotateCamera(v3f(0.f, -0.03f * (float)dtime_ms, 0.f)); rotateCamera(v3f(0.f, -0.03f * (float)dtime_ms, 0.f));
// HACK restore mesh vertex colors to full brightness:
// They may have been mutated in entity rendering code before.
if (!g_settings->getBool("enable_shaders"))
setMeshColor(m_mesh->getMesh(), irr::video::SColor(0xFFFFFFFF));
m_smgr->drawAll(); m_smgr->drawAll();
if (m_initial_rotation && m_mesh) { if (m_initial_rotation && m_mesh) {

@ -270,18 +270,12 @@ void TextureSettings::readSettings()
{ {
connected_glass = g_settings->getBool("connected_glass"); connected_glass = g_settings->getBool("connected_glass");
translucent_liquids = g_settings->getBool("translucent_liquids"); translucent_liquids = g_settings->getBool("translucent_liquids");
bool smooth_lighting = g_settings->getBool("smooth_lighting");
enable_mesh_cache = g_settings->getBool("enable_mesh_cache");
enable_minimap = g_settings->getBool("enable_minimap"); enable_minimap = g_settings->getBool("enable_minimap");
node_texture_size = std::max<u16>(g_settings->getU16("texture_min_size"), 1); node_texture_size = std::max<u16>(g_settings->getU16("texture_min_size"), 1);
std::string leaves_style_str = g_settings->get("leaves_style"); std::string leaves_style_str = g_settings->get("leaves_style");
std::string world_aligned_mode_str = g_settings->get("world_aligned_mode"); std::string world_aligned_mode_str = g_settings->get("world_aligned_mode");
std::string autoscale_mode_str = g_settings->get("autoscale_mode"); std::string autoscale_mode_str = g_settings->get("autoscale_mode");
// Mesh cache is not supported in combination with smooth lighting
if (smooth_lighting)
enable_mesh_cache = false;
if (leaves_style_str == "fancy") { if (leaves_style_str == "fancy") {
leaves_style = LEAVES_FANCY; leaves_style = LEAVES_FANCY;
} else if (leaves_style_str == "simple") { } else if (leaves_style_str == "simple") {
@ -357,8 +351,7 @@ void ContentFeatures::reset()
drawtype = NDT_NORMAL; drawtype = NDT_NORMAL;
mesh.clear(); mesh.clear();
#if CHECK_CLIENT_BUILD() #if CHECK_CLIENT_BUILD()
for (auto &i : mesh_ptr) mesh_ptr = nullptr;
i = NULL;
minimap_color = video::SColor(0, 0, 0, 0); minimap_color = video::SColor(0, 0, 0, 0);
#endif #endif
visual_scale = 1.0; visual_scale = 1.0;
@ -952,48 +945,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
if (drawtype == NDT_MESH && !mesh.empty()) { if (drawtype == NDT_MESH && !mesh.empty()) {
// Meshnode drawtype // Meshnode drawtype
// Read the mesh and apply scale // Read the mesh and apply scale
mesh_ptr[0] = client->getMesh(mesh); mesh_ptr = client->getMesh(mesh);
if (mesh_ptr[0]){ if (mesh_ptr) {
v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale; v3f scale = v3f(BS) * visual_scale;
scaleMesh(mesh_ptr[0], scale); scaleMesh(mesh_ptr, scale);
recalculateBoundingBox(mesh_ptr[0]); recalculateBoundingBox(mesh_ptr);
meshmanip->recalculateNormals(mesh_ptr[0], true, false); meshmanip->recalculateNormals(mesh_ptr, true, false);
} }
} }
//Cache 6dfacedir and wallmounted rotated clones of meshes
if (tsettings.enable_mesh_cache && mesh_ptr[0] &&
(param_type_2 == CPT2_FACEDIR
|| param_type_2 == CPT2_COLORED_FACEDIR)) {
for (u16 j = 1; j < 24; j++) {
mesh_ptr[j] = cloneMesh(mesh_ptr[0]);
rotateMeshBy6dFacedir(mesh_ptr[j], j);
recalculateBoundingBox(mesh_ptr[j]);
meshmanip->recalculateNormals(mesh_ptr[j], true, false);
}
} else if (tsettings.enable_mesh_cache && mesh_ptr[0] &&
(param_type_2 == CPT2_4DIR
|| param_type_2 == CPT2_COLORED_4DIR)) {
for (u16 j = 1; j < 4; j++) {
mesh_ptr[j] = cloneMesh(mesh_ptr[0]);
rotateMeshBy6dFacedir(mesh_ptr[j], j);
recalculateBoundingBox(mesh_ptr[j]);
meshmanip->recalculateNormals(mesh_ptr[j], true, false);
}
} else if (tsettings.enable_mesh_cache && mesh_ptr[0]
&& (param_type_2 == CPT2_WALLMOUNTED ||
param_type_2 == CPT2_COLORED_WALLMOUNTED)) {
static const u8 wm_to_6d[6] = { 20, 0, 16 + 1, 12 + 3, 8, 4 + 2 };
for (u16 j = 1; j < 6; j++) {
mesh_ptr[j] = cloneMesh(mesh_ptr[0]);
rotateMeshBy6dFacedir(mesh_ptr[j], wm_to_6d[j]);
recalculateBoundingBox(mesh_ptr[j]);
meshmanip->recalculateNormals(mesh_ptr[j], true, false);
}
rotateMeshBy6dFacedir(mesh_ptr[0], wm_to_6d[0]);
recalculateBoundingBox(mesh_ptr[0]);
meshmanip->recalculateNormals(mesh_ptr[0], true, false);
}
} }
#endif #endif
@ -1014,10 +973,8 @@ NodeDefManager::~NodeDefManager()
{ {
#if CHECK_CLIENT_BUILD() #if CHECK_CLIENT_BUILD()
for (ContentFeatures &f : m_content_features) { for (ContentFeatures &f : m_content_features) {
for (auto &j : f.mesh_ptr) { if (f.mesh_ptr)
if (j) f.mesh_ptr->drop();
j->drop();
}
} }
#endif #endif
} }

@ -171,7 +171,6 @@ public:
int node_texture_size; int node_texture_size;
bool translucent_liquids; bool translucent_liquids;
bool connected_glass; bool connected_glass;
bool enable_mesh_cache;
bool enable_minimap; bool enable_minimap;
TextureSettings() = default; TextureSettings() = default;
@ -337,7 +336,7 @@ struct ContentFeatures
enum NodeDrawType drawtype; enum NodeDrawType drawtype;
std::string mesh; std::string mesh;
#if CHECK_CLIENT_BUILD() #if CHECK_CLIENT_BUILD()
scene::IMesh *mesh_ptr[24]; scene::IMesh *mesh_ptr; // mesh in case of mesh node
video::SColor minimap_color; video::SColor minimap_color;
#endif #endif
float visual_scale; // Misc. scale parameter float visual_scale; // Misc. scale parameter

@ -36,9 +36,9 @@ public:
node_mgr()->resolveCrossrefs(); node_mgr()->resolveCrossrefs();
} }
MeshMakeData makeSingleNodeMMD(bool smooth_lighting = true, bool for_shaders = true) MeshMakeData makeSingleNodeMMD(bool smooth_lighting = true)
{ {
MeshMakeData data{ndef(), 1, for_shaders}; MeshMakeData data{ndef(), 1};
data.setSmoothLighting(smooth_lighting); data.setSmoothLighting(smooth_lighting);
data.m_blockpos = {0, 0, 0}; data.m_blockpos = {0, 0, 0};
for (s16 x = -1; x <= 1; x++) for (s16 x = -1; x <= 1; x++)

@ -29,7 +29,7 @@ mkdir -p "$worldpath/worldmods"
printf '%s\n' >"$testspath/client1.conf" \ printf '%s\n' >"$testspath/client1.conf" \
video_driver=null name=client1 viewing_range=10 \ video_driver=null name=client1 viewing_range=10 \
enable_{sound,minimap,shaders}=false enable_{sound,minimap,post_processing}=false
printf '%s\n' >"$testspath/server.conf" \ printf '%s\n' >"$testspath/server.conf" \
max_block_send_distance=1 active_block_range=1 \ max_block_send_distance=1 active_block_range=1 \