From ba44b0c0d5a1d4476680960d95bbe070c3eca38b Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Sat, 14 Nov 2026 14:30:51 +0100 Subject: [PATCH 1/5] Draw the glare of a FreeSpotLight after its point The glare of a light point is drawn without the depth test, conditioned on the occlusion query of the point. That query was issued only after the glare and is kept on the TSubModel, which every instance of a model shares, so the glare of one lamp used what the query saw for whichever instance drew that submodel last (earlier in the frame or in the last frame): glares showed through walls and blinked while the camera moved. The point (with its query) is now drawn first and the glare after it, so the conditional render of the opengl renderer uses the query of this very point of this instance in this frame. The glare is drawn only when the point was, which already held, as both need the viewer inside the visibility cone. The vulkan renderer keeps using the results of the last frame. --- rendering/common/scenewalk.cpp | 83 +++++++++++++++++----------------- rendering/common/scenewalk.h | 3 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/rendering/common/scenewalk.cpp b/rendering/common/scenewalk.cpp index 63aa3ce47..ced5318af 100644 --- a/rendering/common/scenewalk.cpp +++ b/rendering/common/scenewalk.cpp @@ -3218,48 +3218,8 @@ void scene_walk::Render_Alpha(TSubModel *Submodel) // a point light (FalloffAngle 360) is seen all around auto const pointlight{Submodel->fCosFalloffAngle <= -1.f}; - if (Global.fLuminance < Submodel->fLight || Global.Overcast > 1.0f) - { - if (pointlight || (Submodel->fCosViewAngle > Submodel->fCosFalloffAngle)) - { - // only bother if the viewer is inside the visibility cone - // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness' - auto glarelevel{std::clamp(std::max(0.6f - Global.fLuminance, // reduce the glare in bright daylight - Global.Overcast - 1.f), // ensure some glare in rainy/foggy conditions - 0.f, 1.f)}; - // view angle attenuation - float const anglefactor{pointlight ? 1.f : std::clamp((Submodel->fCosViewAngle - Submodel->fCosFalloffAngle) / (Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle), 0.f, 1.f)}; - - glarelevel *= anglefactor; - - if (glarelevel > 0.0f) - { - walk_glare(true); - - ::glPushMatrix(); - ::glLoadIdentity(); // macierz jedynkowa - ::glTranslatef(lightcenter.x, lightcenter.y, lightcenter.z); // początek układu zostaje bez zmian - ::glRotated(std::atan2(lightcenter.x, lightcenter.z) * 180.0 / M_PI, 0.0, 1.0, 0.0); // jedynie obracamy w pionie o kąt - - auto const lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override - Submodel->f4Diffuse : - Submodel->DiffuseOverride); - - walk_program( walk_shader::billboard ); - walk_texture(0, m_glaretexture); - model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * glarelevel); - - // main draw call - // drawn where the light itself was seen in the last frame (an occlusion query of the opengl renderer) - walk_glare_draw(Submodel, m_billboardgeometry); - - walk_glare(false); - - ::glPopMatrix(); - } - } - } - + // the glare is drawn after the point, where the occlusion query of this very point (of this instance, in this frame) saw it + auto pointdrawn{false}; if (pointlight || (Submodel->fCosViewAngle > Submodel->fCosFalloffAngle)) { // kąt większy niż maksymalny stożek swiatła @@ -3316,11 +3276,50 @@ void scene_walk::Render_Alpha(TSubModel *Submodel) walk_draw(Submodel->m_geometry.handle); walk_light_query(Submodel, false); + pointdrawn = true; // post-draw reset model_ubs.emission = 0.0f; model_ubs.fog_density = 1.0f / m_fogrange; + ::glPopMatrix(); + } + } + // the point is drawn only inside its visibility cone, so the glare is too + if (pointdrawn && (Global.fLuminance < Submodel->fLight || Global.Overcast > 1.0f)) + { + // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness' + auto glarelevel{std::clamp(std::max(0.6f - Global.fLuminance, // reduce the glare in bright daylight + Global.Overcast - 1.f), // ensure some glare in rainy/foggy conditions + 0.f, 1.f)}; + // view angle attenuation + float const anglefactor{pointlight ? 1.f : std::clamp((Submodel->fCosViewAngle - Submodel->fCosFalloffAngle) / (Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle), 0.f, 1.f)}; + + glarelevel *= anglefactor; + + if (glarelevel > 0.0f) + { + walk_glare(true); + + ::glPushMatrix(); + ::glLoadIdentity(); // macierz jedynkowa + ::glTranslatef(lightcenter.x, lightcenter.y, lightcenter.z); // początek układu zostaje bez zmian + ::glRotated(std::atan2(lightcenter.x, lightcenter.z) * 180.0 / M_PI, 0.0, 1.0, 0.0); // jedynie obracamy w pionie o kąt + + auto const lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override + Submodel->f4Diffuse : + Submodel->DiffuseOverride); + + walk_program( walk_shader::billboard ); + walk_texture(0, m_glaretexture); + model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * glarelevel); + + // main draw call + // drawn where the point of the light was seen just above (an occlusion query of the opengl renderer) + walk_glare_draw(Submodel, m_billboardgeometry); + + walk_glare(false); + ::glPopMatrix(); } } diff --git a/rendering/common/scenewalk.h b/rendering/common/scenewalk.h index 91a708c8d..ac22f7d99 100644 --- a/rendering/common/scenewalk.h +++ b/rendering/common/scenewalk.h @@ -266,7 +266,8 @@ class scene_walk virtual void walk_timbers_expand(std::vector const &Origins, std::vector const &Ranges) {} virtual void walk_cull_face(bool const Enabled) = 0; // the glare of a lamp: drawn without the depth test, added to what is there; drawn only where the point of the light was - // seen (walk_light_query() of the last frame, when the backend has it) + // seen (walk_light_query() of this point drawn just before it, when the backend has it: the opengl renderer uses + // the query at once, the vulkan renderer the result of the last frame) virtual void walk_glare(bool const Enabled) = 0; virtual void walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) = 0; virtual void walk_light_query(TSubModel *Submodel, bool const Begin) = 0; From 2dd53bc97beae51ec8abf8475492a8d7f7f925c4 Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Sat, 14 Nov 2026 17:46:40 +0100 Subject: [PATCH 2/5] Make the glare of a FreeSpotLight as bright as the part of its point seen The glare was drawn whole or not at all, depending on whether any sample of the light point passed the depth test. The point is a few pixels wide, so where it sits at the edge of something in front of it (the hood of the lamp, a mast, a wire) the large glare switched on and off as the camera moved and the signal seemed to flash. The opengl renderer now counts the samples of the point which are seen and, drawing the point once more without the depth test and without colour, all of its samples. The gpu writes both counts into a small storage buffer (GLARE_SSBO_BINDING) and billboard.frag scales the glare by their ratio, so a partly hidden lamp gets a fainter glare instead of a flashing one. The conditional render still leaves out the glare of a point not seen at all. The vulkan renderer is unchanged. --- gl/glsl_common.cpp | 1 + gl/ubo.h | 4 +++ rendering/common/scenewalk.cpp | 1 + rendering/common/scenewalk.h | 6 ++++- rendering/opengl46/opengl46renderer.cpp | 35 ++++++++++++++++++++++++- rendering/opengl46/opengl46renderer.h | 8 ++++++ shaders/ogl46/billboard.frag | 12 +++++++++ shaders/ogl46/common.glsl | 1 + 8 files changed, 66 insertions(+), 2 deletions(-) diff --git a/gl/glsl_common.cpp b/gl/glsl_common.cpp index f6f3df06d..9a5c9a895 100644 --- a/gl/glsl_common.cpp +++ b/gl/glsl_common.cpp @@ -110,6 +110,7 @@ void gl::glsl_common_setup() "#define SKY_OCCLUSION_HEIGHT_TEX " + std::to_string(SKY_OCCLUSION_HEIGHT_TEX) + "\n" + "#define SKY_OCCLUSION_TEX " + std::to_string(SKY_OCCLUSION_TEX) + "\n" + "#define CAB_PROBE_SSBO_BINDING " + std::to_string(CAB_PROBE_SSBO_BINDING) + "\n" + + "#define GLARE_SSBO_BINDING " + std::to_string(GLARE_SSBO_BINDING) + "\n" + "#define CAB_PROBE_SH_SIZE " + std::to_string(CAB_PROBE_SH_SIZE) + "\n" + "#define CAB_PROBE_SH_GROUP_SIZE " + std::to_string(CAB_PROBE_SH_GROUP_SIZE) + "\n" + "#define WEATHER_UBO_BINDING " + std::to_string(WEATHER_UBO_BINDING) + "\n" + diff --git a/gl/ubo.h b/gl/ubo.h index c933cf523..83a6ac71d 100644 --- a/gl/ubo.h +++ b/gl/ubo.h @@ -446,6 +446,10 @@ namespace gl }; // binding point of the opengl renderer, bound with the colour passes const GLuint CAB_PROBE_SSBO_BINDING = 17; + // layout std430: the samples of the point of a lamp its occlusion queries counted, written there by the gpu (GLSL: glare_ssbo, + // read by billboard.frag): seen, which passed the depth test, and all, drawn without it. binding point of the opengl renderer, + // bound with the glare of a lamp + const GLuint GLARE_SSBO_BINDING = 18; // the face of the level of the probe the spherical harmonics are taken from, at most, and the work group of cabprobe_sh.comp const size_t CAB_PROBE_SH_SIZE = 16; // the face of the level of the probe CAB_PROBE_MASK_TEX is a copy of, at most diff --git a/rendering/common/scenewalk.cpp b/rendering/common/scenewalk.cpp index ced5318af..d75bb40ca 100644 --- a/rendering/common/scenewalk.cpp +++ b/rendering/common/scenewalk.cpp @@ -3276,6 +3276,7 @@ void scene_walk::Render_Alpha(TSubModel *Submodel) walk_draw(Submodel->m_geometry.handle); walk_light_query(Submodel, false); + walk_light_reference(Submodel->m_geometry.handle); pointdrawn = true; // post-draw reset diff --git a/rendering/common/scenewalk.h b/rendering/common/scenewalk.h index ac22f7d99..697e1ae68 100644 --- a/rendering/common/scenewalk.h +++ b/rendering/common/scenewalk.h @@ -267,10 +267,14 @@ class scene_walk virtual void walk_cull_face(bool const Enabled) = 0; // the glare of a lamp: drawn without the depth test, added to what is there; drawn only where the point of the light was // seen (walk_light_query() of this point drawn just before it, when the backend has it: the opengl renderer uses - // the query at once, the vulkan renderer the result of the last frame) + // the query at once and makes the glare as bright as the part of the point seen, the vulkan renderer uses the result of the + // last frame) virtual void walk_glare(bool const Enabled) = 0; virtual void walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) = 0; virtual void walk_light_query(TSubModel *Submodel, bool const Begin) = 0; + // the point of the light drawn once more right after walk_light_query(), unseen and whole, for the backend which makes the + // glare as bright as the part of the point seen (the opengl renderer); by default nothing + virtual void walk_light_reference(gfx::geometry_handle const &Geometry) {} // what the backend may draw itself (the gpu culling of the opengl renderer); by default the walk draws everything // the start of the walk of a region virtual void walk_region_begin() {} diff --git a/rendering/opengl46/opengl46renderer.cpp b/rendering/opengl46/opengl46renderer.cpp index 4e45137a5..e6a2854c6 100644 --- a/rendering/opengl46/opengl46renderer.cpp +++ b/rendering/opengl46/opengl46renderer.cpp @@ -5058,6 +5058,11 @@ void opengl46_renderer::walk_glare(bool const Enabled) void opengl46_renderer::walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) { + // billboard.frag scales the glare by the part of the point seen, when the samples were counted for it + auto const parameter{model_ubs.param[1].w}; + model_ubs.param[1].w = (m_glaresamples ? 1.f : 0.f); + if (m_glaresamples) + m_glaressbo->bind_base(); if (Submodel->occlusion_query) { glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT); draw(Geometry); @@ -5065,6 +5070,8 @@ void opengl46_renderer::walk_glare_draw(TSubModel *Submodel, gfx::geometry_handl } else draw(Geometry); + model_ubs.param[1].w = parameter; + m_glaresamples = false; } void opengl46_renderer::walk_light_query(TSubModel *Submodel, bool const Begin) @@ -5072,14 +5079,40 @@ void opengl46_renderer::walk_light_query(TSubModel *Submodel, bool const Begin) if (false == gl::vao::use_vao) return; if (Begin) { + m_glaresamples = false; if (!Submodel->occlusion_query) - Submodel->occlusion_query.emplace(gl::query::ANY_SAMPLES_PASSED); + Submodel->occlusion_query.emplace(gl::query::SAMPLES_PASSED); Submodel->occlusion_query->begin(); + m_glarequerysubmodel = Submodel; } else Submodel->occlusion_query->end(); } +void opengl46_renderer::walk_light_reference(gfx::geometry_handle const &Geometry) +{ + if ((false == gl::vao::use_vao) || (m_glarequerysubmodel == nullptr) || (false == m_glarequerysubmodel->occlusion_query.has_value())) + return; + auto const &seen{*m_glarequerysubmodel->occlusion_query}; + m_glarequerysubmodel = nullptr; + if (!m_glarequery) + m_glarequery.emplace(gl::query::SAMPLES_PASSED); + if (!m_glaressbo) + m_glaressbo = std::make_unique(static_cast(2 * sizeof(GLuint)), gl::GLARE_SSBO_BINDING); + // the whole point, unseen: what the samples seen are compared with + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + glDisable(GL_DEPTH_TEST); + m_glarequery->begin(); + draw(Geometry); + m_glarequery->end(); + glEnable(GL_DEPTH_TEST); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + // the gpu writes the counts when they're done, no wait here + glGetQueryBufferObjectuiv(seen, *m_glaressbo, GL_QUERY_RESULT, 0); + glGetQueryBufferObjectuiv(*m_glarequery, *m_glaressbo, GL_QUERY_RESULT, static_cast(sizeof(GLuint))); + m_glaresamples = true; +} + void opengl46_renderer::walk_region_begin() { // the gpu culling runs along the first color pass of the main viewport of a frame, and the passes of the cascades of the diff --git a/rendering/opengl46/opengl46renderer.h b/rendering/opengl46/opengl46renderer.h index a49c8dd5a..fa46ef3c0 100644 --- a/rendering/opengl46/opengl46renderer.h +++ b/rendering/opengl46/opengl46renderer.h @@ -228,6 +228,7 @@ class opengl46_renderer : public gfx_renderer, public gfx::scene_walk { void walk_glare(bool const Enabled) override; void walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) override; void walk_light_query(TSubModel *Submodel, bool const Begin) override; + void walk_light_reference(gfx::geometry_handle const &Geometry) override; // the gpu culling of the instances, models and sleepers, the depth pass of the whole scene void walk_region_begin() override; void walk_editor_cursor() override; @@ -848,6 +849,13 @@ class opengl46_renderer : public gfx_renderer, public gfx::scene_walk { unsigned int m_editor_overlay_revision{0}; std::unique_ptr m_freespot_shader; std::unique_ptr m_billboard_shader; + // the glare of a lamp as bright as the part of its point seen: the submodel of the point whose query is under way + // (walk_light_query()), the samples of the point drawn without the depth test (walk_light_reference()), the samples counted + // for the point (seen and all) written there by the gpu, and whether they were for the glare which follows + TSubModel *m_glarequerysubmodel { nullptr }; + std::optional m_glarequery; + std::unique_ptr m_glaressbo; + bool m_glaresamples { false }; std::unique_ptr m_celestial_shader; std::unique_ptr m_hiddenarea_shader; std::unique_ptr m_copy_shader; diff --git a/shaders/ogl46/billboard.frag b/shaders/ogl46/billboard.frag index 42f3e64d3..1182d06dd 100644 --- a/shaders/ogl46/billboard.frag +++ b/shaders/ogl46/billboard.frag @@ -11,9 +11,21 @@ layout(binding = 0) uniform sampler2D tex1; layout(location = 0) out vec4 out_color; layout(location = 1) out vec4 out_motion; +// the samples of the point of the lamp its occlusion queries counted (the opengl renderer, with param[1].w 1): the glare is as +// bright as the part of the point which is seen +layout(std430, binding = GLARE_SSBO_BINDING) readonly buffer glare_ssbo +{ + uint glare_seen; + uint glare_all; +}; + void main() { vec4 tex_color = texture(tex1, f_coord); + if (param[1].w > 0.5f) + { + tex_color.a *= (glare_all > 0u ? clamp(float(glare_seen) / float(glare_all), 0.0f, 1.0f) : 0.0f); + } if (POSTFX_ENABLED) { out_color = tex_color * param[0]; diff --git a/shaders/ogl46/common.glsl b/shaders/ogl46/common.glsl index 9c0a2ada4..7fbaca131 100644 --- a/shaders/ogl46/common.glsl +++ b/shaders/ogl46/common.glsl @@ -119,6 +119,7 @@ #define SKY_OCCLUSION_TEX 30 #define CAB_PROBE_MASK_TEX 31 #define CAB_PROBE_SSBO_BINDING 17 +#define GLARE_SSBO_BINDING 18 #define CAB_PROBE_SH_SIZE 16 #define CAB_PROBE_SH_GROUP_SIZE 64 #define WEATHER_UBO_BINDING 5 From e3584e706bc1c2ed97b9ac2ea0f34f39813e27d1 Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Sun, 15 Nov 2026 17:05:11 +0100 Subject: [PATCH 3/5] Glare of light points: the glare in a function of its own, the define of its buffer with std::format Render_Glare draws the glare around a light point, so Render_Alpha keeps its nesting. The define of GLARE_SSBO_BINDING is appended with std::format after the chain of the common defines, the luminance is cast to float explicitly (the same value) and the empty default of walk_light_reference says why it's empty. --- gl/glsl_common.cpp | 5 ++- rendering/common/scenewalk.cpp | 73 ++++++++++++++++++---------------- rendering/common/scenewalk.h | 7 +++- 3 files changed, 49 insertions(+), 36 deletions(-) diff --git a/gl/glsl_common.cpp b/gl/glsl_common.cpp index 9a5c9a895..ad82b36f1 100644 --- a/gl/glsl_common.cpp +++ b/gl/glsl_common.cpp @@ -2,6 +2,8 @@ #include "glsl_common.h" #include "rendering/common/shadersource.h" +#include + std::string gl::glsl_common; void gl::glsl_common_setup() @@ -110,7 +112,6 @@ void gl::glsl_common_setup() "#define SKY_OCCLUSION_HEIGHT_TEX " + std::to_string(SKY_OCCLUSION_HEIGHT_TEX) + "\n" + "#define SKY_OCCLUSION_TEX " + std::to_string(SKY_OCCLUSION_TEX) + "\n" + "#define CAB_PROBE_SSBO_BINDING " + std::to_string(CAB_PROBE_SSBO_BINDING) + "\n" + - "#define GLARE_SSBO_BINDING " + std::to_string(GLARE_SSBO_BINDING) + "\n" + "#define CAB_PROBE_SH_SIZE " + std::to_string(CAB_PROBE_SH_SIZE) + "\n" + "#define CAB_PROBE_SH_GROUP_SIZE " + std::to_string(CAB_PROBE_SH_GROUP_SIZE) + "\n" + "#define WEATHER_UBO_BINDING " + std::to_string(WEATHER_UBO_BINDING) + "\n" + @@ -119,6 +120,8 @@ void gl::glsl_common_setup() "#define FOG_HORIZON_SAMPLES " + std::to_string(FOG_HORIZON_SAMPLES) + "\n" + "#define WEATHER_GROUP_SIZE " + std::to_string(WEATHER_GROUP_SIZE) + "\n" + "#define FOG_VOLUME_BIAS " + std::to_string(FOG_VOLUME_BIAS) + "\n"; + // the counts of the samples of the light points seen, which their glares are made as bright as + glsl_common += std::format("#define GLARE_SSBO_BINDING {}\n", GLARE_SSBO_BINDING); } std::string gl::glsl_settings_defines() diff --git a/rendering/common/scenewalk.cpp b/rendering/common/scenewalk.cpp index d75bb40ca..a7f7322fb 100644 --- a/rendering/common/scenewalk.cpp +++ b/rendering/common/scenewalk.cpp @@ -3110,6 +3110,44 @@ void scene_walk::Render_Alpha_text(TSubModel *Submodel) } } +void scene_walk::Render_Glare(TSubModel *Submodel, glm::vec4 const &Lightcenter, bool const Pointlight) +{ + // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness' + auto glarelevel{std::clamp(std::max(static_cast(0.6f - Global.fLuminance), // reduce the glare in bright daylight + Global.Overcast - 1.f), // ensure some glare in rainy/foggy conditions + 0.f, 1.f)}; + // view angle attenuation + float const anglefactor{Pointlight ? 1.f : std::clamp((Submodel->fCosViewAngle - Submodel->fCosFalloffAngle) / (Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle), 0.f, 1.f)}; + + glarelevel *= anglefactor; + + if (glarelevel > 0.0f) + { + walk_glare(true); + + ::glPushMatrix(); + ::glLoadIdentity(); // macierz jedynkowa + ::glTranslatef(Lightcenter.x, Lightcenter.y, Lightcenter.z); // początek układu zostaje bez zmian + ::glRotated(std::atan2(Lightcenter.x, Lightcenter.z) * 180.0 / M_PI, 0.0, 1.0, 0.0); // jedynie obracamy w pionie o kąt + + auto const lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override + Submodel->f4Diffuse : + Submodel->DiffuseOverride); + + walk_program( walk_shader::billboard ); + walk_texture(0, m_glaretexture); + model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * glarelevel); + + // main draw call + // drawn where the point of the light was seen just above (an occlusion query of the opengl renderer) + walk_glare_draw(Submodel, m_billboardgeometry); + + walk_glare(false); + + ::glPopMatrix(); + } +} + void scene_walk::Render_Alpha(TSubModel *Submodel) { // renderowanie przezroczystych przez DL @@ -3289,40 +3327,7 @@ void scene_walk::Render_Alpha(TSubModel *Submodel) // the point is drawn only inside its visibility cone, so the glare is too if (pointdrawn && (Global.fLuminance < Submodel->fLight || Global.Overcast > 1.0f)) { - // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness' - auto glarelevel{std::clamp(std::max(0.6f - Global.fLuminance, // reduce the glare in bright daylight - Global.Overcast - 1.f), // ensure some glare in rainy/foggy conditions - 0.f, 1.f)}; - // view angle attenuation - float const anglefactor{pointlight ? 1.f : std::clamp((Submodel->fCosViewAngle - Submodel->fCosFalloffAngle) / (Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle), 0.f, 1.f)}; - - glarelevel *= anglefactor; - - if (glarelevel > 0.0f) - { - walk_glare(true); - - ::glPushMatrix(); - ::glLoadIdentity(); // macierz jedynkowa - ::glTranslatef(lightcenter.x, lightcenter.y, lightcenter.z); // początek układu zostaje bez zmian - ::glRotated(std::atan2(lightcenter.x, lightcenter.z) * 180.0 / M_PI, 0.0, 1.0, 0.0); // jedynie obracamy w pionie o kąt - - auto const lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override - Submodel->f4Diffuse : - Submodel->DiffuseOverride); - - walk_program( walk_shader::billboard ); - walk_texture(0, m_glaretexture); - model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * glarelevel); - - // main draw call - // drawn where the point of the light was seen just above (an occlusion query of the opengl renderer) - walk_glare_draw(Submodel, m_billboardgeometry); - - walk_glare(false); - - ::glPopMatrix(); - } + Render_Glare(Submodel, lightcenter, pointlight); } } diff --git a/rendering/common/scenewalk.h b/rendering/common/scenewalk.h index 697e1ae68..b71eafa12 100644 --- a/rendering/common/scenewalk.h +++ b/rendering/common/scenewalk.h @@ -274,7 +274,10 @@ class scene_walk virtual void walk_light_query(TSubModel *Submodel, bool const Begin) = 0; // the point of the light drawn once more right after walk_light_query(), unseen and whole, for the backend which makes the // glare as bright as the part of the point seen (the opengl renderer); by default nothing - virtual void walk_light_reference(gfx::geometry_handle const &Geometry) {} + virtual void walk_light_reference(gfx::geometry_handle const &Geometry) + { + // a backend which doesn't scale the glare by the part of the point seen has nothing to draw here + } // what the backend may draw itself (the gpu culling of the opengl renderer); by default the walk draws everything // the start of the walk of a region virtual void walk_region_begin() {} @@ -637,6 +640,8 @@ class scene_walk private: static float editor_ortho_reach(); + // the glare around a light point drawn just before, Lightcenter in view space + void Render_Glare(TSubModel *Submodel, glm::vec4 const &Lightcenter, bool Pointlight); }; } // namespace gfx From 0367a04f2242970d6ea858aa176ee9611a9a67bf Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Mon, 16 Nov 2026 16:44:44 +0100 Subject: [PATCH 4/5] Glare of light points: occlusion queries of each light point of each model, read without waiting The glare waited for the occlusion query of its point in the same frame (a conditional render with GL_QUERY_WAIT and the counts written to a buffer for the shader), which drains the gpu at every lamp. Each light point of each model (the submodel and the instance drawn) now has a pair of queries of its own in the main view: the samples of the point which passed the depth test, and all of them drawn once more without it. Their results are read once the gpu has them, without waiting, and the glare is as bright as the part of the point seen by them, a frame or two late. A point not drawn for more than two frames starts over unseen, so a glare doesn't show through what came in front of it meanwhile. The walk, the shaders and the vulkan renderer are as they were. --- gl/glsl_common.cpp | 4 - gl/ubo.h | 4 - rendering/common/scenewalk.cpp | 89 ++++++++-------- rendering/common/scenewalk.h | 12 +-- rendering/opengl46/opengl46renderer.cpp | 136 ++++++++++++++++-------- rendering/opengl46/opengl46renderer.h | 43 ++++++-- shaders/ogl46/billboard.frag | 12 --- shaders/ogl46/common.glsl | 1 - 8 files changed, 170 insertions(+), 131 deletions(-) diff --git a/gl/glsl_common.cpp b/gl/glsl_common.cpp index ad82b36f1..f6f3df06d 100644 --- a/gl/glsl_common.cpp +++ b/gl/glsl_common.cpp @@ -2,8 +2,6 @@ #include "glsl_common.h" #include "rendering/common/shadersource.h" -#include - std::string gl::glsl_common; void gl::glsl_common_setup() @@ -120,8 +118,6 @@ void gl::glsl_common_setup() "#define FOG_HORIZON_SAMPLES " + std::to_string(FOG_HORIZON_SAMPLES) + "\n" + "#define WEATHER_GROUP_SIZE " + std::to_string(WEATHER_GROUP_SIZE) + "\n" + "#define FOG_VOLUME_BIAS " + std::to_string(FOG_VOLUME_BIAS) + "\n"; - // the counts of the samples of the light points seen, which their glares are made as bright as - glsl_common += std::format("#define GLARE_SSBO_BINDING {}\n", GLARE_SSBO_BINDING); } std::string gl::glsl_settings_defines() diff --git a/gl/ubo.h b/gl/ubo.h index 83a6ac71d..c933cf523 100644 --- a/gl/ubo.h +++ b/gl/ubo.h @@ -446,10 +446,6 @@ namespace gl }; // binding point of the opengl renderer, bound with the colour passes const GLuint CAB_PROBE_SSBO_BINDING = 17; - // layout std430: the samples of the point of a lamp its occlusion queries counted, written there by the gpu (GLSL: glare_ssbo, - // read by billboard.frag): seen, which passed the depth test, and all, drawn without it. binding point of the opengl renderer, - // bound with the glare of a lamp - const GLuint GLARE_SSBO_BINDING = 18; // the face of the level of the probe the spherical harmonics are taken from, at most, and the work group of cabprobe_sh.comp const size_t CAB_PROBE_SH_SIZE = 16; // the face of the level of the probe CAB_PROBE_MASK_TEX is a copy of, at most diff --git a/rendering/common/scenewalk.cpp b/rendering/common/scenewalk.cpp index a7f7322fb..63aa3ce47 100644 --- a/rendering/common/scenewalk.cpp +++ b/rendering/common/scenewalk.cpp @@ -3110,44 +3110,6 @@ void scene_walk::Render_Alpha_text(TSubModel *Submodel) } } -void scene_walk::Render_Glare(TSubModel *Submodel, glm::vec4 const &Lightcenter, bool const Pointlight) -{ - // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness' - auto glarelevel{std::clamp(std::max(static_cast(0.6f - Global.fLuminance), // reduce the glare in bright daylight - Global.Overcast - 1.f), // ensure some glare in rainy/foggy conditions - 0.f, 1.f)}; - // view angle attenuation - float const anglefactor{Pointlight ? 1.f : std::clamp((Submodel->fCosViewAngle - Submodel->fCosFalloffAngle) / (Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle), 0.f, 1.f)}; - - glarelevel *= anglefactor; - - if (glarelevel > 0.0f) - { - walk_glare(true); - - ::glPushMatrix(); - ::glLoadIdentity(); // macierz jedynkowa - ::glTranslatef(Lightcenter.x, Lightcenter.y, Lightcenter.z); // początek układu zostaje bez zmian - ::glRotated(std::atan2(Lightcenter.x, Lightcenter.z) * 180.0 / M_PI, 0.0, 1.0, 0.0); // jedynie obracamy w pionie o kąt - - auto const lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override - Submodel->f4Diffuse : - Submodel->DiffuseOverride); - - walk_program( walk_shader::billboard ); - walk_texture(0, m_glaretexture); - model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * glarelevel); - - // main draw call - // drawn where the point of the light was seen just above (an occlusion query of the opengl renderer) - walk_glare_draw(Submodel, m_billboardgeometry); - - walk_glare(false); - - ::glPopMatrix(); - } -} - void scene_walk::Render_Alpha(TSubModel *Submodel) { // renderowanie przezroczystych przez DL @@ -3256,8 +3218,48 @@ void scene_walk::Render_Alpha(TSubModel *Submodel) // a point light (FalloffAngle 360) is seen all around auto const pointlight{Submodel->fCosFalloffAngle <= -1.f}; - // the glare is drawn after the point, where the occlusion query of this very point (of this instance, in this frame) saw it - auto pointdrawn{false}; + if (Global.fLuminance < Submodel->fLight || Global.Overcast > 1.0f) + { + if (pointlight || (Submodel->fCosViewAngle > Submodel->fCosFalloffAngle)) + { + // only bother if the viewer is inside the visibility cone + // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness' + auto glarelevel{std::clamp(std::max(0.6f - Global.fLuminance, // reduce the glare in bright daylight + Global.Overcast - 1.f), // ensure some glare in rainy/foggy conditions + 0.f, 1.f)}; + // view angle attenuation + float const anglefactor{pointlight ? 1.f : std::clamp((Submodel->fCosViewAngle - Submodel->fCosFalloffAngle) / (Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle), 0.f, 1.f)}; + + glarelevel *= anglefactor; + + if (glarelevel > 0.0f) + { + walk_glare(true); + + ::glPushMatrix(); + ::glLoadIdentity(); // macierz jedynkowa + ::glTranslatef(lightcenter.x, lightcenter.y, lightcenter.z); // początek układu zostaje bez zmian + ::glRotated(std::atan2(lightcenter.x, lightcenter.z) * 180.0 / M_PI, 0.0, 1.0, 0.0); // jedynie obracamy w pionie o kąt + + auto const lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override + Submodel->f4Diffuse : + Submodel->DiffuseOverride); + + walk_program( walk_shader::billboard ); + walk_texture(0, m_glaretexture); + model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * glarelevel); + + // main draw call + // drawn where the light itself was seen in the last frame (an occlusion query of the opengl renderer) + walk_glare_draw(Submodel, m_billboardgeometry); + + walk_glare(false); + + ::glPopMatrix(); + } + } + } + if (pointlight || (Submodel->fCosViewAngle > Submodel->fCosFalloffAngle)) { // kąt większy niż maksymalny stożek swiatła @@ -3314,8 +3316,6 @@ void scene_walk::Render_Alpha(TSubModel *Submodel) walk_draw(Submodel->m_geometry.handle); walk_light_query(Submodel, false); - walk_light_reference(Submodel->m_geometry.handle); - pointdrawn = true; // post-draw reset model_ubs.emission = 0.0f; @@ -3324,11 +3324,6 @@ void scene_walk::Render_Alpha(TSubModel *Submodel) ::glPopMatrix(); } } - // the point is drawn only inside its visibility cone, so the glare is too - if (pointdrawn && (Global.fLuminance < Submodel->fLight || Global.Overcast > 1.0f)) - { - Render_Glare(Submodel, lightcenter, pointlight); - } } if (Submodel->Child != nullptr) diff --git a/rendering/common/scenewalk.h b/rendering/common/scenewalk.h index b71eafa12..91a708c8d 100644 --- a/rendering/common/scenewalk.h +++ b/rendering/common/scenewalk.h @@ -266,18 +266,10 @@ class scene_walk virtual void walk_timbers_expand(std::vector const &Origins, std::vector const &Ranges) {} virtual void walk_cull_face(bool const Enabled) = 0; // the glare of a lamp: drawn without the depth test, added to what is there; drawn only where the point of the light was - // seen (walk_light_query() of this point drawn just before it, when the backend has it: the opengl renderer uses - // the query at once and makes the glare as bright as the part of the point seen, the vulkan renderer uses the result of the - // last frame) + // seen (walk_light_query() of the last frame, when the backend has it) virtual void walk_glare(bool const Enabled) = 0; virtual void walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) = 0; virtual void walk_light_query(TSubModel *Submodel, bool const Begin) = 0; - // the point of the light drawn once more right after walk_light_query(), unseen and whole, for the backend which makes the - // glare as bright as the part of the point seen (the opengl renderer); by default nothing - virtual void walk_light_reference(gfx::geometry_handle const &Geometry) - { - // a backend which doesn't scale the glare by the part of the point seen has nothing to draw here - } // what the backend may draw itself (the gpu culling of the opengl renderer); by default the walk draws everything // the start of the walk of a region virtual void walk_region_begin() {} @@ -640,8 +632,6 @@ class scene_walk private: static float editor_ortho_reach(); - // the glare around a light point drawn just before, Lightcenter in view space - void Render_Glare(TSubModel *Submodel, glm::vec4 const &Lightcenter, bool Pointlight); }; } // namespace gfx diff --git a/rendering/opengl46/opengl46renderer.cpp b/rendering/opengl46/opengl46renderer.cpp index e6a2854c6..6c36ec921 100644 --- a/rendering/opengl46/opengl46renderer.cpp +++ b/rendering/opengl46/opengl46renderer.cpp @@ -5056,61 +5056,109 @@ void opengl46_renderer::walk_glare(bool const Enabled) } } +// the frames a result of the glare queries is good for: a point not drawn for longer may have something else in front of it now +constexpr unsigned int GLARE_RESULT_FRAMES{2}; +// the frames after which the entries of points no longer drawn are dropped +constexpr unsigned int GLARE_KEEP_FRAMES{600}; + +opengl46_renderer::glare_visibility *opengl46_renderer::glare_entry(TSubModel const *Submodel, bool const Create) +{ + glare_key const key{Submodel, TSubModel::iInstance}; + if (false == Create) + { + auto const lookup{m_glares.find(key)}; + return (lookup != m_glares.end() ? &lookup->second : nullptr); + } + if (m_framestamp - m_glarepruned > GLARE_KEEP_FRAMES) + { + m_glarepruned = m_framestamp; + auto const framestamp{m_framestamp}; + // a query whose result nobody reads any more is deleted along + std::erase_if(m_glares, [framestamp](auto const &Entry) { return framestamp - Entry.second.frame > GLARE_KEEP_FRAMES; }); + } + return &m_glares.try_emplace(key).first->second; +} + +void opengl46_renderer::glare_read(glare_visibility &Entry) +{ + // the results once the gpu has both of them, nothing waits for them + auto const seen{Entry.seen.result()}; + if (false == seen.has_value()) + { + return; + } + auto const all{Entry.all.result()}; + if (false == all.has_value()) + { + return; + } + Entry.pending = false; + Entry.share = (*all > 0 ? std::clamp(static_cast(*seen) / static_cast(*all), 0.f, 1.f) : 0.f); +} + void opengl46_renderer::walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) { - // billboard.frag scales the glare by the part of the point seen, when the samples were counted for it - auto const parameter{model_ubs.param[1].w}; - model_ubs.param[1].w = (m_glaresamples ? 1.f : 0.f); - if (m_glaresamples) - m_glaressbo->bind_base(); - if (Submodel->occlusion_query) { - glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT); + if (false == gl::vao::use_vao) + { draw(Geometry); - glEndConditionalRender(); + return; } - else - draw(Geometry); - model_ubs.param[1].w = parameter; - m_glaresamples = false; + // as bright as the part of the point seen in the main view, by the results of an earlier frame; none for a point not seen + // lately + auto const *entry{glare_entry(Submodel, false)}; + if ((entry == nullptr) || (m_framestamp - entry->frame > GLARE_RESULT_FRAMES) || (entry->share <= 0.f)) + { + return; + } + auto const opacity{model_ubs.param[0].w}; + model_ubs.param[0].w = opacity * entry->share; + draw(Geometry); + model_ubs.param[0].w = opacity; } void opengl46_renderer::walk_light_query(TSubModel *Submodel, bool const Begin) { - if (false == gl::vao::use_vao) + if ((false == gl::vao::use_vao) || (m_renderpass.draw_mode != rendermode::color) || (m_current_viewport == nullptr) || (false == m_current_viewport->main)) + { return; - if (Begin) { - m_glaresamples = false; - if (!Submodel->occlusion_query) - Submodel->occlusion_query.emplace(gl::query::SAMPLES_PASSED); - Submodel->occlusion_query->begin(); - m_glarequerysubmodel = Submodel; } - else - Submodel->occlusion_query->end(); -} - -void opengl46_renderer::walk_light_reference(gfx::geometry_handle const &Geometry) -{ - if ((false == gl::vao::use_vao) || (m_glarequerysubmodel == nullptr) || (false == m_glarequerysubmodel->occlusion_query.has_value())) + if (false == Begin) + { + if (m_glarequery == nullptr) + { + return; + } + m_glarequery->seen.end(); + // the whole point, unseen: what the samples seen are compared with + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + glDisable(GL_DEPTH_TEST); + m_glarequery->all.begin(); + draw(Submodel->m_geometry.handle); + m_glarequery->all.end(); + glEnable(GL_DEPTH_TEST); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + m_glarequery->pending = true; + m_glarequery = nullptr; return; - auto const &seen{*m_glarequerysubmodel->occlusion_query}; - m_glarequerysubmodel = nullptr; - if (!m_glarequery) - m_glarequery.emplace(gl::query::SAMPLES_PASSED); - if (!m_glaressbo) - m_glaressbo = std::make_unique(static_cast(2 * sizeof(GLuint)), gl::GLARE_SSBO_BINDING); - // the whole point, unseen: what the samples seen are compared with - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - glDisable(GL_DEPTH_TEST); - m_glarequery->begin(); - draw(Geometry); - m_glarequery->end(); - glEnable(GL_DEPTH_TEST); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - // the gpu writes the counts when they're done, no wait here - glGetQueryBufferObjectuiv(seen, *m_glaressbo, GL_QUERY_RESULT, 0); - glGetQueryBufferObjectuiv(*m_glarequery, *m_glaressbo, GL_QUERY_RESULT, static_cast(sizeof(GLuint))); - m_glaresamples = true; + } + auto &entry{*glare_entry(Submodel, true)}; + if (m_framestamp - entry.frame > GLARE_RESULT_FRAMES) + { + // not drawn lately: what it saw then is no good, it starts over unseen + entry.share = 0.f; + entry.pending = false; + } + entry.frame = m_framestamp; + if (entry.pending) + { + glare_read(entry); + } + if (false == entry.pending) + { + // new queries once the results of the last ones are read + entry.seen.begin(); + m_glarequery = &entry; + } } void opengl46_renderer::walk_region_begin() diff --git a/rendering/opengl46/opengl46renderer.h b/rendering/opengl46/opengl46renderer.h index fa46ef3c0..588761868 100644 --- a/rendering/opengl46/opengl46renderer.h +++ b/rendering/opengl46/opengl46renderer.h @@ -53,6 +53,10 @@ http://mozilla.org/MPL/2.0/. #include "rendering/common/temporalaa.h" #include "rendering/common/screenreflections.h" +#include +#include +#include + // bare-bones render controller, in lack of anything better yet class opengl46_renderer : public gfx_renderer, public gfx::scene_walk { public: @@ -228,7 +232,6 @@ class opengl46_renderer : public gfx_renderer, public gfx::scene_walk { void walk_glare(bool const Enabled) override; void walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) override; void walk_light_query(TSubModel *Submodel, bool const Begin) override; - void walk_light_reference(gfx::geometry_handle const &Geometry) override; // the gpu culling of the instances, models and sleepers, the depth pass of the whole scene void walk_region_begin() override; void walk_editor_cursor() override; @@ -849,13 +852,37 @@ class opengl46_renderer : public gfx_renderer, public gfx::scene_walk { unsigned int m_editor_overlay_revision{0}; std::unique_ptr m_freespot_shader; std::unique_ptr m_billboard_shader; - // the glare of a lamp as bright as the part of its point seen: the submodel of the point whose query is under way - // (walk_light_query()), the samples of the point drawn without the depth test (walk_light_reference()), the samples counted - // for the point (seen and all) written there by the gpu, and whether they were for the glare which follows - TSubModel *m_glarequerysubmodel { nullptr }; - std::optional m_glarequery; - std::unique_ptr m_glaressbo; - bool m_glaresamples { false }; + // the glare of a light point is as bright as the part of its point seen in the main view, counted by a pair of occlusion + // queries of its own for each light point of each model (the submodel and the instance drawn, TSubModel::iInstance): the + // samples which passed the depth test and all of them. the results are read once the gpu has them, without waiting, so the + // glare follows its point a frame or two late + struct glare_key + { + TSubModel const *submodel{nullptr}; + std::uintptr_t instance{0}; + bool operator==(glare_key const &) const = default; + }; + struct glare_key_hash + { + std::size_t operator()(glare_key const &Key) const + { + return std::hash{}(Key.submodel) ^ (std::hash{}(Key.instance) * 31u); + } + }; + struct glare_visibility + { + gl::query seen{gl::query::SAMPLES_PASSED}; + gl::query all{gl::query::SAMPLES_PASSED}; + bool pending{false}; // the queries were issued and their results aren't read yet + float share{0.f}; // the part of the point seen, by the last results read + unsigned int frame{0}; // the frame the point was last drawn in the main view + }; + // the visibility of the point the walk draws, for the queries around it (walk_light_query()) + glare_visibility *glare_entry(TSubModel const *Submodel, bool Create); + static void glare_read(glare_visibility &Entry); + std::unordered_map m_glares; + glare_visibility *m_glarequery{nullptr}; // the entry whose queries are under way + unsigned int m_glarepruned{0}; // the frame the entries of points no longer drawn were last dropped std::unique_ptr m_celestial_shader; std::unique_ptr m_hiddenarea_shader; std::unique_ptr m_copy_shader; diff --git a/shaders/ogl46/billboard.frag b/shaders/ogl46/billboard.frag index 1182d06dd..42f3e64d3 100644 --- a/shaders/ogl46/billboard.frag +++ b/shaders/ogl46/billboard.frag @@ -11,21 +11,9 @@ layout(binding = 0) uniform sampler2D tex1; layout(location = 0) out vec4 out_color; layout(location = 1) out vec4 out_motion; -// the samples of the point of the lamp its occlusion queries counted (the opengl renderer, with param[1].w 1): the glare is as -// bright as the part of the point which is seen -layout(std430, binding = GLARE_SSBO_BINDING) readonly buffer glare_ssbo -{ - uint glare_seen; - uint glare_all; -}; - void main() { vec4 tex_color = texture(tex1, f_coord); - if (param[1].w > 0.5f) - { - tex_color.a *= (glare_all > 0u ? clamp(float(glare_seen) / float(glare_all), 0.0f, 1.0f) : 0.0f); - } if (POSTFX_ENABLED) { out_color = tex_color * param[0]; diff --git a/shaders/ogl46/common.glsl b/shaders/ogl46/common.glsl index 7fbaca131..9c0a2ada4 100644 --- a/shaders/ogl46/common.glsl +++ b/shaders/ogl46/common.glsl @@ -119,7 +119,6 @@ #define SKY_OCCLUSION_TEX 30 #define CAB_PROBE_MASK_TEX 31 #define CAB_PROBE_SSBO_BINDING 17 -#define GLARE_SSBO_BINDING 18 #define CAB_PROBE_SH_SIZE 16 #define CAB_PROBE_SH_GROUP_SIZE 64 #define WEATHER_UBO_BINDING 5 From 0b94534b83d921fa678a5d7c4092478d8a85d61c Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Fri, 27 Nov 2026 23:41:26 +0100 Subject: [PATCH 5/5] Drop the occlusion query of a submodel, nothing uses it any more The glare of a light point has its own queries for each instance in the renderer now. --- model/Model3d.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/model/Model3d.h b/model/Model3d.h index 9be9a4f0f..f7a09dc03 100644 --- a/model/Model3d.h +++ b/model/Model3d.h @@ -13,7 +13,6 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Float3d.h" #include "rendering/geometrybank.h" #include "model/material.h" -#include "gl/query.h" #include @@ -265,7 +264,6 @@ public: void ReplaceMaterial(const std::string &name); float MaxY( float4x4 const &m ); std::shared_ptr> screen_touch_list; // for python screen touching - std::optional occlusion_query; glm::mat4 future_transform; void deserialize(std::istream&);