diff --git a/builtin/mainmenu/settings/dlg_settings.lua b/builtin/mainmenu/settings/dlg_settings.lua index 57e5a1300..dbd77a4db 100644 --- a/builtin/mainmenu/settings/dlg_settings.lua +++ b/builtin/mainmenu/settings/dlg_settings.lua @@ -19,8 +19,6 @@ local component_funcs = dofile(core.get_mainmenu_path() .. DIR_DELIM .. "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 .. "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) do - local content = page_by_id.graphics_and_audio_graphics.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 content = page_by_id.graphics_and_audio_effects.content local idx = table.indexof(content, "enable_dynamic_shadows") table.insert(content, idx, shadows_component) @@ -348,7 +341,6 @@ local function check_requirements(name, requires) end 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_controls = core.settings:get("touch_controls") local special = { @@ -359,8 +351,6 @@ local function check_requirements(name, requires) -- be used, so we show settings for both. 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)), - shaders_support = shaders_support, - shaders = core.settings:get_bool("enable_shaders") and shaders_support, opengl = video_driver == "opengl", gles = video_driver:sub(1, 5) == "ogles", } diff --git a/builtin/mainmenu/settings/shader_warning_component.lua b/builtin/mainmenu/settings/shader_warning_component.lua deleted file mode 100644 index b227bcee3..000000000 --- a/builtin/mainmenu/settings/shader_warning_component.lua +++ /dev/null @@ -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, -} diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 728eaf425..71d976ec7 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -61,7 +61,7 @@ # # # 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 # # 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 # * 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 # * touchscreen / keyboard_mouse # * opengl / gles @@ -277,7 +275,6 @@ undersampling (Undersampling) int 1 1 8 # - topbottom: split screen top/bottom. # - sidebyside: split screen side by side. # - 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 # 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. # 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. # 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 # the aliasing effects. This is the slowest and the most accurate method. antialiasing (Antialiasing method) enum none none,fsaa,fxaa,ssaa @@ -473,18 +470,12 @@ enable_particles (Digging particles) bool true [**Waving Nodes] # Set to true to enable waving leaves. -# -# Requires: shaders enable_waving_leaves (Waving leaves) bool false # Set to true to enable waving plants. -# -# Requires: shaders enable_waving_plants (Waving plants) bool false # Set to true to enable waving liquids (like water). -# -# Requires: shaders enable_waving_water (Waving liquids) bool false # 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. # 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 # Length of liquid waves. # -# Requires: shaders, enable_waving_water +# 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: shaders, enable_waving_water +# Requires: enable_waving_water water_wave_speed (Waving liquids wave speed) float 5.0 [**Dynamic shadows] # Set to true to enable Shadow Mapping. # -# Requires: shaders, opengl +# Requires: opengl enable_dynamic_shadows (Dynamic shadows) bool false # Set the shadow strength gamma. # Adjusts the intensity of in-game dynamic 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 # 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 # Texture size to render the shadow map on. # This must be a power of two. # 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 # Sets shadow texture quality to 32 bits. # On false, 16 bits texture will be used. # 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 # Enable Poisson disk 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 # Define shadow filtering quality. # This simulates the soft shadows effect by applying a PCF or Poisson disk # 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 # Enable colored shadows. # 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 # 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. # 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 # Set the soft shadow radius size. # Lower values mean sharper shadows, bigger values mean softer shadows. # 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 # Set the default tilt of Sun/Moon orbit in degrees. # Games may change orbit tilt via API. # 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 [**Post Processing] # Enables the post processing pipeline. -# -# Requires: shaders enable_post_processing (Enable Post Processing) bool true # 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 # enhanced, highlights and shadows are gradually compressed. # -# Requires: shaders, enable_post_processing +# Requires: enable_post_processing tone_mapping (Filmic tone mapping) bool false # Enable automatic exposure correction @@ -600,14 +589,14 @@ tone_mapping (Filmic tone mapping) bool false # automatically adjust to the brightness of the scene, # simulating the behavior of human eye. # -# Requires: shaders, enable_post_processing +# Requires: enable_post_processing enable_auto_exposure (Enable Automatic Exposure) bool false # Set the exposure compensation in EV units. # Value of 0.0 (default) means no exposure compensation. # 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 # 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 # 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 # Set to true to enable bloom effect. # Bright colors will bleed over the neighboring objects. # -# Requires: shaders, enable_post_processing +# Requires: enable_post_processing enable_bloom (Enable Bloom) bool false # 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 [**Other Effects] # 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 # Apply specular shading to nodes. # -# Requires: shaders, enable_dynamic_shadows +# Requires: enable_dynamic_shadows enable_node_specular (Node specular) bool false # 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 [*Audio] @@ -1837,14 +1826,7 @@ ignore_world_load_errors (Ignore world errors) bool false [**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. -# -# Requires: shaders shader_path (Shader path) path # 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. 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 # down the rate of mesh updates, thus reducing jitter on slower clients. 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 # 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 [**Sound] diff --git a/doc/android.md b/doc/android.md index 19d7e569b..65cc0440c 100644 --- a/doc/android.md +++ b/doc/android.md @@ -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. ## 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 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 ## Requirements -The minimal and recommended system requirements for Luanti are listed below. +The recommended system requirements for Luanti are listed below. ### CPU Supported architectures: -1. ARM v7 -2. ARM v8 +1. ARMv7 +2. AArch64 3. x86 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 1. Graphics API: OpenGL ES 2.0 -2. Android version: Android 4.4 (API Level 19) or newer -3. Empty RAM: 850 MB -4. Free storage: 480 MB +2. Android version: Android 5 (API Level 21) or newer +3. Free RAM: 1 GB +4. Free storage: 500 MB ## Rendering Unlike on PC, Android devices use OpenGL ES which less powerful than OpenGL, thus 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 In order to build, your PC has to be set up to build Luanti in the usual diff --git a/doc/developing/os-compatibility.md b/doc/developing/os-compatibility.md index 29b271e6f..794328e7b 100644 --- a/doc/developing/os-compatibility.md +++ b/doc/developing/os-compatibility.md @@ -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) -**OpenGL** is an entirely different beast, there is no formal consensus on changing the requirements -and neither do we have an exact set of requirements. - -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. +We require **OpenGL** 2.0 or ES 2.0, so shaders can be relied on. +Graphics code should generally work on both. Newer features can be used as long as a fallback exists. General **system requirements** are not bounded either. Being able to play Luanti on a recent low-end phone is a reasonable target. diff --git a/irr/src/COpenGLExtensionHandler.cpp b/irr/src/COpenGLExtensionHandler.cpp index 6127d6e46..a20932c8f 100644 --- a/irr/src/COpenGLExtensionHandler.cpp +++ b/irr/src/COpenGLExtensionHandler.cpp @@ -130,10 +130,10 @@ void COpenGLExtensionHandler::initExtensions(video::IContextManager *cmgr, bool { const f32 ogl_ver = core::fast_atof(reinterpret_cast(glGetString(GL_VERSION))); Version = static_cast(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f)); - if (Version >= 102) - os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); + if (Version >= 200) + os::Printer::log("OpenGL driver version is 2.0 or newer.", ELL_INFORMATION); 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(glGetString(GL_EXTENSIONS)); diff --git a/src/client/clouds.cpp b/src/client/clouds.cpp index 37f044f22..82a85d7b0 100644 --- a/src/client/clouds.cpp +++ b/src/client/clouds.cpp @@ -33,16 +33,13 @@ Clouds::Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc, m_seed(seed) { assert(ssrc); - m_enable_shaders = g_settings->getBool("enable_shaders"); m_material.BackfaceCulling = true; m_material.FogEnable = true; m_material.AntiAliasing = video::EAAM_SIMPLE; - if (m_enable_shaders) { + { auto sid = ssrc->getShader("cloud_shader", TILE_MATERIAL_ALPHA); m_material.MaterialType = ssrc->getShaderInfo(sid).material; - } else { - m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; } m_params = SkyboxDefaults::getCloudDefaults(); @@ -119,15 +116,11 @@ void Clouds::updateMesh() // Colors with primitive shading - video::SColorf c_top_f(m_color); - video::SColorf c_side_1_f(m_color); - video::SColorf c_side_2_f(m_color); - video::SColorf c_bottom_f(m_color); - if (m_enable_shaders) { - // 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; + video::SColorf c_top_f(1, 1, 1, 1); + video::SColorf c_side_1_f(1, 1, 1, 1); + video::SColorf c_side_2_f(1, 1, 1, 1); + video::SColorf c_bottom_f(1, 1, 1, 1); + const video::SColorf shadow = m_params.color_shadow; c_side_1_f.r *= shadow.r * 0.25f + 0.75f; c_side_1_f.g *= shadow.g * 0.25f + 0.75f; @@ -385,8 +378,7 @@ void Clouds::render() } 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->setMaterial(m_material); diff --git a/src/client/clouds.h b/src/client/clouds.h index 06a4f090b..950327aa2 100644 --- a/src/client/clouds.h +++ b/src/client/clouds.h @@ -169,7 +169,7 @@ private: v3s16 m_camera_offset; 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); CloudParams m_params; }; diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 6c7976ea7..b73b3602c 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -349,8 +349,6 @@ bool GenericCAO::collideWithObjects() const void GenericCAO::initialize(const std::string &data) { processInitData(data); - - m_enable_shaders = g_settings->getBool("enable_shaders"); } 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 - if (m_enable_shaders) { + { IShaderSource *shader_source = m_client->getShaderSource(); 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); 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] { @@ -688,9 +679,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) // Set material setMaterial(buf->getMaterial()); - if (m_enable_shaders) { - buf->getMaterial().ColorParam = c; - } + buf->getMaterial().ColorParam = c; // Add to mesh mesh->addMeshBuffer(buf); @@ -714,9 +703,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) // Set material setMaterial(buf->getMaterial()); - if (m_enable_shaders) { - buf->getMaterial().ColorParam = c; - } + buf->getMaterial().ColorParam = c; // Add to mesh mesh->addMeshBuffer(buf); @@ -741,8 +728,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) }); } else if (m_prop.visual == "mesh") { grabMatrixNode(); - // can't cache mesh if shaders disabled, since we modify vertices - scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, m_enable_shaders); + scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, true); if (mesh) { if (!checkMeshNormals(mesh)) { infostream << "GenericCAO: recalculating normals for mesh " @@ -795,7 +781,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) /* Set VBO hint */ // 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 if (m_meshnode && m_prop.visual != "upright_sprite") 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 // based on the entity glow. - if (m_enable_shaders) - light = encode_light(light_at_pos, m_prop.glow); - else - final_color_blend(&light, light_at_pos, day_night_ratio); + light = encode_light(light_at_pos, m_prop.glow); if (light != m_last_light) { m_last_light = light; @@ -912,22 +895,11 @@ void GenericCAO::setNodeLight(const video::SColor &light_color) return; } - if (m_enable_shaders) { + { auto *node = getSceneNode(); if (!node) return; 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); - } } } diff --git a/src/client/content_cao.h b/src/client/content_cao.h index 714a7f241..1115b6819 100644 --- a/src/client/content_cao.h +++ b/src/client/content_cao.h @@ -116,8 +116,6 @@ private: // Material video::E_MATERIAL_TYPE m_material_type; f32 m_material_type_param; - // Settings - bool m_enable_shaders = false; bool visualExpiryRequired(const ObjectProperties &newprops) const; diff --git a/src/client/content_mapblock.cpp b/src/client/content_mapblock.cpp index 0c1113d0c..2d294953a 100644 --- a/src/client/content_mapblock.cpp +++ b/src/client/content_mapblock.cpp @@ -67,8 +67,6 @@ MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector nodedef(data->nodedef), meshmanip(mm), 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")) { } @@ -1657,31 +1655,27 @@ void MapblockMeshGenerator::drawMeshNode() } else if (cur_node.f->param_type_2 == CPT2_WALLMOUNTED || cur_node.f->param_type_2 == CPT2_COLORED_WALLMOUNTED) { // Convert wallmounted to 6dfacedir. - // When cache enabled, it is already converted. 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 || cur_node.f->param_type_2 == CPT2_COLORED_DEGROTATE) { degrotate = cur_node.n.getDegRotate(nodedef); } - if (!data->m_smooth_lighting && cur_node.f->mesh_ptr[facedir] && !degrotate) { - // use cached meshes - private_mesh = false; - mesh = cur_node.f->mesh_ptr[facedir]; - } else if (cur_node.f->mesh_ptr[0]) { - // no cache, clone and rotate mesh + if (cur_node.f->mesh_ptr) { + // clone and rotate mesh private_mesh = true; - mesh = cloneMesh(cur_node.f->mesh_ptr[0]); + mesh = cloneMesh(cur_node.f->mesh_ptr); if (facedir) rotateMeshBy6dFacedir(mesh, facedir); else if (degrotate) rotateMeshXZby(mesh, 1.5f * degrotate); recalculateBoundingBox(mesh); meshmanip->recalculateNormals(mesh, true, false); - } else + } else { + warningstream << "drawMeshNode(): missing mesh" << std::endl; return; + } int mesh_buffer_count = mesh->getMeshBufferCount(); for (int j = 0; j < mesh_buffer_count; j++) { diff --git a/src/client/content_mapblock.h b/src/client/content_mapblock.h index 88b0e8a79..0473a9b75 100644 --- a/src/client/content_mapblock.h +++ b/src/client/content_mapblock.h @@ -60,9 +60,6 @@ private: const v3s16 blockpos_nodes; -// options - const bool enable_mesh_cache; - // current node struct { v3s16 p; diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 2da9efa5e..6929d4c9e 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -84,15 +84,11 @@ Hud::Hud(Client *client, LocalPlayer *player, } // Initialize m_selection_material - - - if (g_settings->getBool("enable_shaders")) { - IShaderSource *shdrsrc = client->getShaderSource(); + IShaderSource *shdrsrc = client->getShaderSource(); + { auto shader_id = shdrsrc->getShader( m_mode == HIGHLIGHT_HALO ? "selection_shader" : "default_shader", TILE_MATERIAL_ALPHA); m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material; - } else { - m_selection_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; } if (m_mode == HIGHLIGHT_BOX) { @@ -106,12 +102,9 @@ Hud::Hud(Client *client, LocalPlayer *player, } // 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); 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 = rangelim(g_settings->getS16("selectionbox_width"), 1, 5); @@ -1171,6 +1164,7 @@ void drawItemStack( auto &p = imesh->buffer_colors[j]; p.applyOverride(c); + // TODO: could be moved to a shader if (p.needColorize(c)) { buf->setDirty(scene::EBT_VERTEX); if (imesh->needs_shading) diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 0922b9500..c212bd148 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -25,10 +25,9 @@ MeshMakeData */ -MeshMakeData::MeshMakeData(const NodeDefManager *ndef, u16 side_length, bool use_shaders): +MeshMakeData::MeshMakeData(const NodeDefManager *ndef, u16 side_length): side_length(side_length), - nodedef(ndef), - m_use_shaders(use_shaders) + nodedef(ndef) {} void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos) @@ -267,7 +266,8 @@ u16 getSmoothLightTransparent(const v3s16 &p, const v3s16 &corner, MeshMakeData 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 b = (0.98f * daynight_ratio) / 1000.0f + 0.078f; sunlight->r = rg; @@ -594,14 +594,12 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs m_shdrsrc(client->getShaderSource()), m_bounding_sphere_center((data->side_length * 0.5f - 0.5f) * BS), m_animation_force_timer(0), // force initial animation - m_last_crack(-1), - m_last_daynight_ratio((u32) -1) + m_last_crack(-1) { ZoneScoped; for (auto &m : m_mesh) m = make_irr(); - m_enable_shaders = data->m_use_shaders; auto mesh_grid = client->getMeshGrid(); 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; } - 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 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 video::SMaterial material; material.BackfaceCulling = true; @@ -729,12 +703,10 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs tex.MagFilter = video::ETMAGF_NEAREST; }); - if (m_enable_shaders) { + { material.MaterialType = m_shdrsrc->getShaderInfo( p.layer.shader_id).material; p.layer.applyMaterialOptionsWithShaders(material); - } else { - p.layer.applyMaterialOptions(material); } 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 m_has_animation = !m_crack_materials.empty() || - !m_daynight_diffs.empty() || !m_animation_info.empty(); } @@ -844,24 +815,6 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, 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; } diff --git a/src/client/mapblock_mesh.h b/src/client/mapblock_mesh.h index 9bdebec7c..5a8daf50c 100644 --- a/src/client/mapblock_mesh.h +++ b/src/client/mapblock_mesh.h @@ -35,9 +35,8 @@ struct MeshMakeData u16 side_length; 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) @@ -235,8 +234,6 @@ private: f32 m_bounding_radius; v3f m_bounding_sphere_center; - bool m_enable_shaders; - // Must animate() be called before rendering? bool m_has_animation; int m_animation_force_timer; @@ -252,14 +249,6 @@ private: // Keys are pairs of (mesh index, buffer index in the mesh) std::map, 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::map > m_daynight_diffs; - // list of all semitransparent triangles in the mapblock std::vector m_transparent_triangles; // Binary Space Partitioning tree for the block diff --git a/src/client/mesh_generator_thread.cpp b/src/client/mesh_generator_thread.cpp index ec868980c..3d80f8e67 100644 --- a/src/client/mesh_generator_thread.cpp +++ b/src/client/mesh_generator_thread.cpp @@ -39,7 +39,6 @@ QueuedMeshUpdate::~QueuedMeshUpdate() MeshUpdateQueue::MeshUpdateQueue(Client *client): m_client(client) { - m_cache_enable_shaders = g_settings->getBool("enable_shaders"); m_cache_smooth_lighting = g_settings->getBool("smooth_lighting"); } @@ -177,7 +176,7 @@ void MeshUpdateQueue::done(v3s16 pos) void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q) { 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; data->fillBlockDataBegin(q->p); diff --git a/src/client/mesh_generator_thread.h b/src/client/mesh_generator_thread.h index d6e2863bf..fb9b5ae9e 100644 --- a/src/client/mesh_generator_thread.h +++ b/src/client/mesh_generator_thread.h @@ -70,11 +70,9 @@ private: std::mutex m_mutex; // TODO: Add callback to update these when g_settings changes - bool m_cache_enable_shaders; bool m_cache_smooth_lighting; void fillDataFromMapBlocks(QueuedMeshUpdate *q); - void cleanupCache(); }; struct MeshUpdateResult diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 3bc208808..f28f6a39a 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -173,7 +173,6 @@ Minimap::Minimap(Client *client) m_current_mode_index = 0; // Initialize static settings - m_enable_shaders = g_settings->getBool("enable_shaders"); m_surface_mode_scan_height = g_settings->getBool("minimap_double_scan_height") ? 256 : 128; @@ -599,7 +598,7 @@ void Minimap::drawMinimap(core::rect rect) material.TextureLayers[0].Texture = minimap_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); material.MaterialType = m_shdrsrc->getShaderInfo(sid).material; } else { diff --git a/src/client/minimap.h b/src/client/minimap.h index 5bc69894f..15112d565 100644 --- a/src/client/minimap.h +++ b/src/client/minimap.h @@ -152,7 +152,6 @@ private: const NodeDefManager *m_ndef; std::unique_ptr m_minimap_update_thread; irr_ptr m_meshbuffer; - bool m_enable_shaders; std::vector m_modes; size_t m_current_mode_index; u16 m_surface_mode_scan_height; diff --git a/src/client/render/plain.cpp b/src/client/render/plain.cpp index c08ae78b2..2215ad777 100644 --- a/src/client/render/plain.cpp +++ b/src/client/render/plain.cpp @@ -87,7 +87,7 @@ void UpscaleStep::run(PipelineContext &context) std::unique_ptr create3DStage(Client *client, v2f scale) { 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(); pipeline->addStep(pipeline->own(std::unique_ptr(step))); @@ -111,8 +111,8 @@ RenderStep* addUpscaling(RenderPipeline *pipeline, RenderStep *previousStep, v2f if (downscale_factor.X == 1.0f && downscale_factor.Y == 1.0f) return previousStep; - // When shaders are enabled, post-processing pipeline takes care of rescaling - if (g_settings->getBool("enable_shaders") && g_settings->getBool("enable_post_processing")) + // post-processing pipeline takes care of rescaling + if (g_settings->getBool("enable_post_processing")) return previousStep; diff --git a/src/client/shader.cpp b/src/client/shader.cpp index 778e17d2d..8d2d5744a 100644 --- a/src/client/shader.cpp +++ b/src/client/shader.cpp @@ -307,9 +307,6 @@ public: private: - // Are shaders even enabled? - bool m_enabled; - // The id of the thread that is allowed to use irrlicht directly std::thread::id m_main_thread; @@ -348,12 +345,6 @@ ShaderSource::ShaderSource() // Add a dummy ShaderInfo as the first index, named "" 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 addShaderConstantSetterFactory(new MainShaderConstantSetterFactory()); } @@ -362,11 +353,9 @@ ShaderSource::~ShaderSource() { MutexAutoLock lock(m_shaderinfo_cache_mutex); - if (!m_enabled) - return; - // Delete materials auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices(); + assert(gpu); for (ShaderInfo &i : m_shaderinfo_cache) { if (!i.name.empty()) gpu->deleteShaderMaterial(i.material); @@ -495,11 +484,9 @@ void ShaderSource::rebuildShaders() { MutexAutoLock lock(m_shaderinfo_cache_mutex); - if (!m_enabled) - return; - // Delete materials auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices(); + assert(gpu); for (ShaderInfo &i : m_shaderinfo_cache) { if (!i.name.empty()) { gpu->deleteShaderMaterial(i.material); @@ -546,14 +533,14 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, } 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; - video::IVideoDriver *driver = RenderingEngine::get_video_driver(); auto *gpu = driver->getGPUProgrammingServices(); if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) { - throw ShaderException(gettext("Shaders are enabled but GLSL is not " - "supported by the driver.")); + throw ShaderException(gettext("GLSL is not supported by the driver")); } // Create shaders header diff --git a/src/client/shadows/dynamicshadowsrender.cpp b/src/client/shadows/dynamicshadowsrender.cpp index 466903cbc..2bf3adeb3 100644 --- a/src/client/shadows/dynamicshadowsrender.cpp +++ b/src/client/shadows/dynamicshadowsrender.cpp @@ -107,25 +107,13 @@ void ShadowRenderer::disable() void ShadowRenderer::preInit(IWritableShaderSource *shsrc) { - if (g_settings->getBool("enable_shaders") && - g_settings->getBool("enable_dynamic_shadows")) { + if (g_settings->getBool("enable_dynamic_shadows")) { shsrc->addShaderConstantSetterFactory(new ShadowConstantSetterFactory()); } } 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(); @@ -533,7 +521,7 @@ void ShadowRenderer::mixShadowsQuad() void ShadowRenderer::createShaders() { - video::IGPUProgrammingServices *gpu = m_driver->getGPUProgrammingServices(); + auto *gpu = m_driver->getGPUProgrammingServices(); if (depth_shader == -1) { 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) { // disable if unsupported - if (g_settings->getBool("enable_dynamic_shadows") && ( - device->getVideoDriver()->getDriverType() != video::EDT_OPENGL || - !g_settings->getBool("enable_shaders"))) { + if (g_settings->getBool("enable_dynamic_shadows") && + device->getVideoDriver()->getDriverType() != video::EDT_OPENGL) { g_settings->setBool("enable_dynamic_shadows", false); } - if (g_settings->getBool("enable_shaders") && - g_settings->getBool("enable_dynamic_shadows")) { + if (g_settings->getBool("enable_dynamic_shadows")) { ShadowRenderer *shadow_renderer = new ShadowRenderer(device, client); shadow_renderer->initialize(); return shadow_renderer; diff --git a/src/client/sky.cpp b/src/client/sky.cpp index cd02b5554..cfce57ef3 100644 --- a/src/client/sky.cpp +++ b/src/client/sky.cpp @@ -53,8 +53,6 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade m_box.MaxEdge.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_sun_params = SkyboxDefaults::getSunDefaults(); m_moon_params = SkyboxDefaults::getMoonDefaults(); @@ -63,9 +61,8 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade // Create materials m_materials[0] = baseMaterial(); - m_materials[0].MaterialType = m_enable_shaders ? - ssrc->getShaderInfo(ssrc->getShader("stars_shader", TILE_MATERIAL_ALPHA)).material : - video::EMT_TRANSPARENT_ALPHA_CHANNEL; + m_materials[0].MaterialType = + ssrc->getShaderInfo(ssrc->getShader("stars_shader", TILE_MATERIAL_ALPHA)).material; m_materials[1] = baseMaterial(); 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; if (color.a <= 0.0f) // Stars are only drawn when not fully transparent return; - if (m_enable_shaders) - m_materials[0].ColorParam = color.toSColor(); - else - setMeshBufferColor(m_stars.get(), color.toSColor()); + m_materials[0].ColorParam = 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 world_matrix = driver->getTransform(video::ETS_WORLD); @@ -841,8 +835,7 @@ void Sky::updateStars() indices.push_back(i * 4 + 3); indices.push_back(i * 4 + 0); } - if (m_enable_shaders) - m_stars->setHardwareMappingHint(scene::EHM_STATIC); + m_stars->setHardwareMappingHint(scene::EHM_STATIC); } void Sky::setSkyColors(const SkyColor &sky_color) diff --git a/src/client/sky.h b/src/client/sky.h index 8986a505c..73f377ae2 100644 --- a/src/client/sky.h +++ b/src/client/sky.h @@ -173,7 +173,6 @@ private: bool m_clouds_enabled = true; // Initialised to true, reset only by set_sky API bool m_directional_colored_fog; 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_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/src/client/tile.h b/src/client/tile.h index ceee54243..df02d2244 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -78,7 +78,6 @@ struct TileLayer return !(*this == other); } - // Sets everything else except the texture in the material void applyMaterialOptions(video::SMaterial &material) const; void applyMaterialOptionsWithShaders(video::SMaterial &material) const; diff --git a/src/client/wieldmesh.cpp b/src/client/wieldmesh.cpp index 28fe362a7..5e645e9be 100644 --- a/src/client/wieldmesh.cpp +++ b/src/client/wieldmesh.cpp @@ -184,7 +184,6 @@ WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id): scene::ISceneNode(mgr->getRootSceneNode(), mgr, id), 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_bilinear_filter = g_settings->getBool("bilinear_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::SMesh *copy = cloneMesh(cubemesh); 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); copy->drop(); 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, std::vector *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()); mesh_make_data.setSmoothLighting(false); MapblockMeshGenerator gen(&mesh_make_data, &collector, @@ -354,10 +353,8 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che scene::SMesh *mesh = nullptr; - if (m_enable_shaders) { - u32 shader_id = shdrsrc->getShader("object_shader", TILE_MATERIAL_BASIC, NDT_NORMAL); - m_material_type = shdrsrc->getShaderInfo(shader_id).material; - } + u32 shader_id = shdrsrc->getShader("object_shader", TILE_MATERIAL_BASIC, NDT_NORMAL); + m_material_type = shdrsrc->getShaderInfo(shader_id).material; // Color-related m_colors.clear(); @@ -500,10 +497,7 @@ void WieldMeshSceneNode::setColor(video::SColor c) if (m_colors[j].needColorize(buffercolor)) { buf->setDirty(scene::EBT_VERTEX); - if (m_enable_shaders) - setMeshBufferColor(buf, buffercolor); - else - colorizeMeshBuffer(buf, &buffercolor); + setMeshBufferColor(buf, buffercolor); } } } @@ -513,13 +507,11 @@ void WieldMeshSceneNode::setNodeLightColor(video::SColor color) if (!m_meshnode) return; - if (m_enable_shaders) { + { for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) { video::SMaterial &material = m_meshnode->getMaterial(i); material.ColorParam = color; } - } else { - setColor(color); } } @@ -538,12 +530,7 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh) dummymesh->drop(); // m_meshnode grabbed it } else { m_meshnode->setMesh(mesh); - // without shaders recolored often for lighting - // otherwise only once - if (m_enable_shaders) - mesh->setHardwareMappingHint(scene::EHM_STATIC); - else - mesh->setHardwareMappingHint(scene::EHM_DYNAMIC); + mesh->setHardwareMappingHint(scene::EHM_STATIC); } m_meshnode->setVisible(true); @@ -596,7 +583,7 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result) } else scaleMesh(mesh, v3f(1.2, 1.2, 1.2)); // add overlays - postProcessNodeMesh(mesh, f, false, false, nullptr, + postProcessNodeMesh(mesh, f, false, nullptr, &result->buffer_colors, true); if (f.drawtype == NDT_ALLFACES) scaleMesh(mesh, v3f(f.visual_scale)); @@ -704,7 +691,7 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc, } 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 *colors, bool apply_scale) { const u32 mc = mesh->getMeshBufferCount(); diff --git a/src/client/wieldmesh.h b/src/client/wieldmesh.h index 8291cce14..5a5a6957a 100644 --- a/src/client/wieldmesh.h +++ b/src/client/wieldmesh.h @@ -117,7 +117,6 @@ private: scene::IMeshSceneNode *m_meshnode = nullptr; video::E_MATERIAL_TYPE m_material_type; - bool m_enable_shaders; bool m_anisotropic_filter; bool m_bilinear_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. * \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, std::vector *colors, bool apply_scale = false); diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 7758c96bf..2142615e2 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -102,7 +102,6 @@ void set_default_settings() settings->setDefault("sound_volume_unfocused", "0.3"); settings->setDefault("mute_sound", "false"); settings->setDefault("sound_extensions_blacklist", ""); - settings->setDefault("enable_mesh_cache", "false"); settings->setDefault("mesh_generation_interval", "0"); settings->setDefault("mesh_generation_threads", "0"); settings->setDefault("free_move", "false"); @@ -299,7 +298,6 @@ void set_default_settings() settings->setDefault("enable_local_map_saving", "false"); settings->setDefault("show_entity_selectionbox", "false"); settings->setDefault("ambient_occlusion_gamma", "1.8"); - settings->setDefault("enable_shaders", "true"); settings->setDefault("enable_particles", "true"); settings->setDefault("arm_inertia", "true"); settings->setDefault("show_nametag_backgrounds", "true"); diff --git a/src/environment.cpp b/src/environment.cpp index 533959723..fe582afd4 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -17,7 +17,6 @@ Environment::Environment(IGameDef *gamedef): m_day_count(0), 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_abm_interval = g_settings->getFloat("abm_interval"); m_cache_nodetimer_interval = g_settings->getFloat("nodetimer_interval"); @@ -32,7 +31,7 @@ u32 Environment::getDayNightRatio() MutexAutoLock lock(m_time_lock); if (m_enable_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) diff --git a/src/environment.h b/src/environment.h index 925154d84..b668e69c2 100644 --- a/src/environment.h +++ b/src/environment.h @@ -131,7 +131,6 @@ protected: * (as opposed to the this local caching). This can be addressed in * a later release. */ - bool m_cache_enable_shaders; float m_cache_active_block_mgmt_interval; float m_cache_abm_interval; float m_cache_nodetimer_interval; diff --git a/src/gui/guiScene.cpp b/src/gui/guiScene.cpp index f30c4f3d1..88865b384 100644 --- a/src/gui/guiScene.cpp +++ b/src/gui/guiScene.cpp @@ -98,11 +98,6 @@ void GUIScene::draw() if (m_inf_rot) 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(); if (m_initial_rotation && m_mesh) { diff --git a/src/nodedef.cpp b/src/nodedef.cpp index c956bbdfd..2301b179f 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -270,18 +270,12 @@ void TextureSettings::readSettings() { connected_glass = g_settings->getBool("connected_glass"); 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"); node_texture_size = std::max(g_settings->getU16("texture_min_size"), 1); std::string leaves_style_str = g_settings->get("leaves_style"); std::string world_aligned_mode_str = g_settings->get("world_aligned_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") { leaves_style = LEAVES_FANCY; } else if (leaves_style_str == "simple") { @@ -357,8 +351,7 @@ void ContentFeatures::reset() drawtype = NDT_NORMAL; mesh.clear(); #if CHECK_CLIENT_BUILD() - for (auto &i : mesh_ptr) - i = NULL; + mesh_ptr = nullptr; minimap_color = video::SColor(0, 0, 0, 0); #endif visual_scale = 1.0; @@ -952,48 +945,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc if (drawtype == NDT_MESH && !mesh.empty()) { // Meshnode drawtype // Read the mesh and apply scale - mesh_ptr[0] = client->getMesh(mesh); - if (mesh_ptr[0]){ - v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale; - scaleMesh(mesh_ptr[0], scale); - recalculateBoundingBox(mesh_ptr[0]); - meshmanip->recalculateNormals(mesh_ptr[0], true, false); + mesh_ptr = client->getMesh(mesh); + if (mesh_ptr) { + v3f scale = v3f(BS) * visual_scale; + scaleMesh(mesh_ptr, scale); + recalculateBoundingBox(mesh_ptr); + 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 @@ -1014,10 +973,8 @@ NodeDefManager::~NodeDefManager() { #if CHECK_CLIENT_BUILD() for (ContentFeatures &f : m_content_features) { - for (auto &j : f.mesh_ptr) { - if (j) - j->drop(); - } + if (f.mesh_ptr) + f.mesh_ptr->drop(); } #endif } diff --git a/src/nodedef.h b/src/nodedef.h index bc0058101..c3f88ce83 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -171,7 +171,6 @@ public: int node_texture_size; bool translucent_liquids; bool connected_glass; - bool enable_mesh_cache; bool enable_minimap; TextureSettings() = default; @@ -337,7 +336,7 @@ struct ContentFeatures enum NodeDrawType drawtype; std::string mesh; #if CHECK_CLIENT_BUILD() - scene::IMesh *mesh_ptr[24]; + scene::IMesh *mesh_ptr; // mesh in case of mesh node video::SColor minimap_color; #endif float visual_scale; // Misc. scale parameter diff --git a/src/unittest/test_content_mapblock.cpp b/src/unittest/test_content_mapblock.cpp index acc6213a4..6e0026cba 100644 --- a/src/unittest/test_content_mapblock.cpp +++ b/src/unittest/test_content_mapblock.cpp @@ -36,9 +36,9 @@ public: 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.m_blockpos = {0, 0, 0}; for (s16 x = -1; x <= 1; x++) diff --git a/util/test_multiplayer.sh b/util/test_multiplayer.sh index 5c0e6bfaa..ade24b648 100755 --- a/util/test_multiplayer.sh +++ b/util/test_multiplayer.sh @@ -29,7 +29,7 @@ mkdir -p "$worldpath/worldmods" printf '%s\n' >"$testspath/client1.conf" \ 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" \ max_block_send_distance=1 active_block_range=1 \