diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index d13f25695..cffc728d1 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -262,7 +262,7 @@ viewing_range (Viewing range) int 190 20 4000 # Higher values result in a less detailed image. undersampling (Undersampling) int 1 1 8 -[**Graphics Effects] +[**Graphical Effects] # Allows liquids to be translucent. translucent_liquids (Translucent liquids) bool true @@ -468,12 +468,6 @@ enable_raytraced_culling (Enable Raytraced Culling) bool true [*Shaders] -# Shaders allow advanced visual effects and may increase performance on some video -# cards. -# -# Requires: shaders_support -enable_shaders (Shaders) bool true - [**Waving Nodes] # Set to true to enable waving leaves. @@ -1866,6 +1860,11 @@ 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 @@ -1889,6 +1888,7 @@ cloud_radius (Cloud radius) int 12 1 62 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 diff --git a/src/client/shader.cpp b/src/client/shader.cpp index c0a2f109a..d368ccb09 100644 --- a/src/client/shader.cpp +++ b/src/client/shader.cpp @@ -322,6 +322,9 @@ 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; @@ -360,6 +363,12 @@ 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()); } @@ -368,9 +377,11 @@ ShaderSource::~ShaderSource() { MutexAutoLock lock(m_shaderinfo_cache_mutex); + if (!m_enabled) + return; + // Delete materials - video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()-> - getGPUProgrammingServices(); + auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices(); for (ShaderInfo &i : m_shaderinfo_cache) { if (!i.name.empty()) gpu->deleteShaderMaterial(i.material); @@ -499,9 +510,11 @@ void ShaderSource::rebuildShaders() { MutexAutoLock lock(m_shaderinfo_cache_mutex); + if (!m_enabled) + return; + // Delete materials - video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()-> - getGPUProgrammingServices(); + auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices(); for (ShaderInfo &i : m_shaderinfo_cache) { if (!i.name.empty()) { gpu->deleteShaderMaterial(i.material); @@ -548,12 +561,11 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, } shaderinfo.material = shaderinfo.base_material; - bool enable_shaders = g_settings->getBool("enable_shaders"); - if (!enable_shaders) + if (!m_enabled) return shaderinfo; video::IVideoDriver *driver = RenderingEngine::get_video_driver(); - video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices(); + 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."));