From af61de77773b8cbb37fbd888c77421cf63173dd2 Mon Sep 17 00:00:00 2001 From: grorp Date: Tue, 12 Nov 2024 10:52:20 +0100 Subject: [PATCH] Minor rendering code fixes (#15399) * Fix line numbers in shader errors * Fix uninitialized variables in shadow code --- src/client/shader.cpp | 9 ++++----- src/client/shadows/dynamicshadowsrender.cpp | 5 +++-- src/client/shadows/dynamicshadowsrender.h | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/shader.cpp b/src/client/shader.cpp index a227eb37a..778e17d2d 100644 --- a/src/client/shader.cpp +++ b/src/client/shader.cpp @@ -730,19 +730,18 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, shaders_header << "#define VOLUMETRIC_LIGHT 1\n"; } - shaders_header << "#line 0\n"; // reset the line counter for meaningful diagnostics - std::string common_header = shaders_header.str(); + const char *final_header = "#line 0\n"; // reset the line counter for meaningful diagnostics std::string vertex_shader = m_sourcecache.getOrLoad(name, "opengl_vertex.glsl"); std::string fragment_shader = m_sourcecache.getOrLoad(name, "opengl_fragment.glsl"); std::string geometry_shader = m_sourcecache.getOrLoad(name, "opengl_geometry.glsl"); - vertex_shader = common_header + vertex_header + vertex_shader; - fragment_shader = common_header + fragment_header + fragment_shader; + vertex_shader = common_header + vertex_header + final_header + vertex_shader; + fragment_shader = common_header + fragment_header + final_header + fragment_shader; const char *geometry_shader_ptr = nullptr; // optional if (!geometry_shader.empty()) { - geometry_shader = common_header + geometry_header + geometry_shader; + geometry_shader = common_header + geometry_header + final_header + geometry_shader; geometry_shader_ptr = geometry_shader.c_str(); } diff --git a/src/client/shadows/dynamicshadowsrender.cpp b/src/client/shadows/dynamicshadowsrender.cpp index 909e2761e..466903cbc 100644 --- a/src/client/shadows/dynamicshadowsrender.cpp +++ b/src/client/shadows/dynamicshadowsrender.cpp @@ -21,8 +21,9 @@ ShadowRenderer::ShadowRenderer(IrrlichtDevice *device, Client *client) : m_smgr(device->getSceneManager()), m_driver(device->getVideoDriver()), - m_client(client), m_current_frame(0), - m_perspective_bias_xy(0.8), m_perspective_bias_z(0.5) + m_client(client), m_shadow_strength(0.0f), m_shadow_tint(255, 0, 0, 0), + m_time_day(0.0f), m_force_update_shadow_map(false), m_current_frame(0), + m_perspective_bias_xy(0.8f), m_perspective_bias_z(0.5f) { (void) m_client; diff --git a/src/client/shadows/dynamicshadowsrender.h b/src/client/shadows/dynamicshadowsrender.h index 5395c90b3..a12ba01e4 100644 --- a/src/client/shadows/dynamicshadowsrender.h +++ b/src/client/shadows/dynamicshadowsrender.h @@ -118,11 +118,11 @@ private: std::vector m_shadow_node_array; float m_shadow_strength; - video::SColor m_shadow_tint{ 255, 0, 0, 0 }; + video::SColor m_shadow_tint; float m_shadow_strength_gamma; float m_shadow_map_max_distance; float m_shadow_map_texture_size; - float m_time_day{0.0f}; + float m_time_day; int m_shadow_samples; bool m_shadow_map_texture_32bit; bool m_shadows_enabled; @@ -130,7 +130,7 @@ private: bool m_shadow_map_colored; bool m_force_update_shadow_map; u8 m_map_shadow_update_frames; /* Use this number of frames to update map shaodw */ - u8 m_current_frame{0}; /* Current frame */ + u8 m_current_frame; /* Current frame */ f32 m_perspective_bias_xy; f32 m_perspective_bias_z;