From 36edc3f161de03e3c5e8b507d2d6699f0d728ab9 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 28 Nov 2024 10:38:51 +0100 Subject: [PATCH] Add 10-bit texture format and setting to chose PP color depth (and move some settings to the advanced category) --- builtin/settingtypes.txt | 47 ++++++++++++++++++++++-------------- irr/include/IImage.h | 2 ++ irr/include/SColor.h | 9 ++++++- irr/src/OpenGL3/Driver.cpp | 1 + irr/src/OpenGLES2/Driver.cpp | 1 + src/client/render/plain.cpp | 5 +++- src/defaultsettings.cpp | 3 +++ 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index d23704694..b10f776ac 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -77,8 +77,11 @@ # Sections are marked by a single line in the format: [Section Name] # Sub-section are marked by adding * in front of the section name: [*Sub-section] # Sub-sub-sections have two * etc. -# There shouldn't be too much settings per category; settings that shouldn't be -# modified by the "average user" should be in (sub-)categories called "Advanced". +# There shouldn't be too many settings per category. +# +# The top-level categories "Advanced", "Client and Server" and "Mapgen" are +# handled specially and its contents only shown when a checkbox is checked. +# They contain settings not intended for the "average user". [Controls] @@ -471,6 +474,7 @@ performance_tradeoffs (Tradeoffs for performance) bool false # Adds particles when digging a node. enable_particles (Digging particles) bool true + [**Waving Nodes] # Set to true to enable waving leaves. @@ -534,12 +538,6 @@ shadow_map_texture_size (Shadow map texture size) int 2048 128 8192 # 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: 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. @@ -553,14 +551,6 @@ shadow_filters (Shadow filter quality) enum 1 0,1,2 # Requires: enable_dynamic_shadows, opengl shadow_map_color (Colored shadows) bool false -# Spread a complete update of shadow map over given number of frames. -# Higher values might make shadows laggy, lower values -# will consume more resources. -# Minimum value: 1; maximum value: 16 -# -# 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 @@ -1830,6 +1820,9 @@ ignore_world_load_errors (Ignore world errors) bool false [**Graphics] +# Enables debug and error-checking in the OpenGL driver. +opengl_debug (OpenGL debug) bool false + # Path to shader directory. If no path is defined, default location will be used. shader_path (Shader path) path @@ -1901,8 +1894,26 @@ texture_min_size (Base texture size) int 64 1 32768 # Systems with a low-end GPU (or no GPU) would benefit from smaller values. client_mesh_chunk (Client Mesh Chunksize) int 1 1 16 -# Enables debug and error-checking in the OpenGL driver. -opengl_debug (OpenGL debug) bool false +# Decide the color depth of the texture used for the post-processing pipeline. +# Reducing this can improve performance, but might cause some effects (e.g. bloom) +# to not work. +# +# Requires: enable_post_processing +post_processing_texture_bits (Color depth for post-processing texture) enum 16 8,10,16 + +# Enable Poisson disk filtering. +# On true uses Poisson disk to make "soft shadows". Otherwise uses PCF filtering. +# +# Requires: enable_dynamic_shadows, opengl +shadow_poisson_filter (Poisson filtering) bool true + +# Spread a complete update of shadow map over given number of frames. +# Higher values might make shadows laggy, lower values +# will consume more resources. +# Minimum value: 1; maximum value: 16 +# +# Requires: enable_dynamic_shadows, opengl +shadow_update_frames (Map shadows update frames) int 8 1 16 # Set to true to render debugging breakdown of the bloom effect. # In debug mode, the screen is split into 4 quadrants: diff --git a/irr/include/IImage.h b/irr/include/IImage.h index 47349ed1a..a303201a9 100644 --- a/irr/include/IImage.h +++ b/irr/include/IImage.h @@ -342,6 +342,8 @@ public: return 16; case ECF_R16G16: return 32; + case ECF_A2R10G10B10: + return 32; case ECF_R16F: return 16; case ECF_G16R16F: diff --git a/irr/include/SColor.h b/irr/include/SColor.h index 41bca1a8c..0845b31f7 100644 --- a/irr/include/SColor.h +++ b/irr/include/SColor.h @@ -72,6 +72,9 @@ enum ECOLOR_FORMAT //! 32 bit format using 16 bits for the red and green channels. ECF_R16G16, + //! 32 bit format using 10 bits for R, G, B and 2 for alpha. + ECF_A2R10G10B10, + /** Depth and stencil formats. */ //! 16 bit format using 16 bits for depth. @@ -91,7 +94,7 @@ enum ECOLOR_FORMAT }; //! Names for ECOLOR_FORMAT types -const c8 *const ColorFormatNames[ECF_UNKNOWN + 2] = { +const c8 *const ColorFormatNames[] = { "A1R5G5B5", "R5G6B5", "R8G8B8", @@ -106,6 +109,7 @@ const c8 *const ColorFormatNames[ECF_UNKNOWN + 2] = { "R8G8", "R16", "R16G16", + "A2R10G10B10", "D16", "D24", "D32", @@ -114,6 +118,9 @@ const c8 *const ColorFormatNames[ECF_UNKNOWN + 2] = { 0, }; +static_assert(sizeof(ColorFormatNames) / sizeof(ColorFormatNames[0]) + == ECF_UNKNOWN + 2, "name table size mismatch"); + //! Creates a 16 bit A1R5G5B5 color inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a = 0xFF) { diff --git a/irr/src/OpenGL3/Driver.cpp b/irr/src/OpenGL3/Driver.cpp index b397846aa..5277c4dde 100644 --- a/irr/src/OpenGL3/Driver.cpp +++ b/irr/src/OpenGL3/Driver.cpp @@ -62,6 +62,7 @@ void COpenGL3Driver::initFeatures() TextureFormats[ECF_R8G8] = {GL_RG8, GL_RG, GL_UNSIGNED_BYTE}; TextureFormats[ECF_R16] = {GL_R16, GL_RED, GL_UNSIGNED_SHORT}; TextureFormats[ECF_R16G16] = {GL_RG16, GL_RG, GL_UNSIGNED_SHORT}; + TextureFormats[ECF_A2R10G10B10] = {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}; TextureFormats[ECF_D16] = {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; TextureFormats[ECF_D24] = {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; TextureFormats[ECF_D32] = {GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; // WARNING: may not be renderable (?!) diff --git a/irr/src/OpenGLES2/Driver.cpp b/irr/src/OpenGLES2/Driver.cpp index 3c034522c..32bf0aee0 100644 --- a/irr/src/OpenGLES2/Driver.cpp +++ b/irr/src/OpenGLES2/Driver.cpp @@ -59,6 +59,7 @@ void COpenGLES2Driver::initFeatures() TextureFormats[ECF_A32B32G32R32F] = {GL_RGBA32F, GL_RGBA, GL_FLOAT}; TextureFormats[ECF_R8] = {GL_R8, GL_RED, GL_UNSIGNED_BYTE}; TextureFormats[ECF_R8G8] = {GL_RG8, GL_RG, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_A2R10G10B10] = {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}; TextureFormats[ECF_D16] = {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; TextureFormats[ECF_D24] = {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}; diff --git a/src/client/render/plain.cpp b/src/client/render/plain.cpp index fd3e0b9ba..c24ba8837 100644 --- a/src/client/render/plain.cpp +++ b/src/client/render/plain.cpp @@ -155,8 +155,11 @@ void populatePlainPipeline(RenderPipeline *pipeline, Client *client) video::ECOLOR_FORMAT selectColorFormat(video::IVideoDriver *driver) { - if (driver->queryTextureFormat(video::ECF_A16B16G16R16F)) + u32 bits = g_settings->getU32("post_processing_texture_bits"); + if (bits >= 16 && driver->queryTextureFormat(video::ECF_A16B16G16R16F)) return video::ECF_A16B16G16R16F; + if (bits >= 10 && driver->queryTextureFormat(video::ECF_A2R10G10B10)) + return video::ECF_A2R10G10B10; return video::ECF_A8R8G8B8; } diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index e6b26bd4a..600058b5c 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -311,6 +311,7 @@ void set_default_settings() // Effects settings->setDefault("enable_post_processing", "true"); + settings->setDefault("post_processing_texture_bits", "16"); settings->setDefault("directional_colored_fog", "true"); settings->setDefault("inventory_items_animations", "false"); settings->setDefault("mip_map", "false"); @@ -567,6 +568,8 @@ void set_default_settings() settings->setDefault("active_block_range", "2"); settings->setDefault("viewing_range", "50"); settings->setDefault("leaves_style", "simple"); + // Note: OpenGL ES 2.0 is not guaranteed to provide depth textures, + // which we would need for PP. settings->setDefault("enable_post_processing", "false"); settings->setDefault("debanding", "false"); settings->setDefault("curl_verify_cert", "false");