18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 10:46:45 +01:00

Windscreen post pass in every frame: drops and haze also standing still, with any anti-aliasing

The velocity target is always drawn and the motion blur pass always runs;
the motion itself is blurred only when the motion blur is on and something
moves (by 0 otherwise). The rain and bugs windscreens send their drops and
haze through it, so they look the same with MSAA, TAA or none, moving or not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
This commit is contained in:
Claude
2026-11-01 21:15:58 +01:00
parent a80b40e6fd
commit ae82cef216
3 changed files with 19 additions and 22 deletions
+8 -12
View File
@@ -1761,21 +1761,17 @@ void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
if (vp.main && !vp.custom_backbuffer) // TODO: update window sizes also for extra viewports
target_size = Global.fb_size;
// the camera with no vehicle of its own (freefly, the editor) blurs the world with its own movement, as a vehicle does with
// its (rendering/common/freecameramotion.h)
if (vp.main && (Global.pCamera.m_owner != nullptr))
m_freecamera.reset();
auto const freecameramovement{(vp.main && (Global.pCamera.m_owner == nullptr)) ? m_freecamera.next_frame(Global.pCamera.Pos) : glm::vec3{0.f}};
// the motion blur only when something in the view moves: the vehicle of the camera, the camera with no vehicle of its own,
// or a vehicle drawn in the last frame.
// with nothing moving the velocity is zero everywhere, the blur takes a single sample of each pixel and gives back the
// image it was given, so the velocity target, its resolve and the blur are left out and the picture stays the same.
// a vehicle setting off is blurred from its second frame, when its velocity is still far below a pixel
auto const motionblur{
// the motion is blurred only when something in the view moves: the vehicle of the camera, or a vehicle drawn in the last
// frame (a vehicle setting off is blurred from its second frame, when its velocity is still far below a pixel). the pass
// itself runs in every frame: the windscreens (mat_rain_windscreen, mat_bugs_windscreen) ask it in the velocity target for
// the picture in their drops and the haze, also standing still, with the motion blur off and with any anti-aliasing (the
// motion is then blurred by 0)
auto const moving{
Global.gfx_postfx_motionblur_enabled
&& (m_vehiclesmoved
|| (freecameramovement != glm::vec3{0.f})
|| ((Global.pCamera.m_owner != nullptr) && (Global.pCamera.m_owner->get_future_movement() != glm::dvec3{0.0})))};
auto const motionblur{Global.gfx_motion_vectors() && (vp.main_texv != nullptr)};
if (!Global.gfx_skippipeline)
{
@@ -2086,7 +2082,7 @@ if (!Global.gfx_skippipeline)
{
if (taa)
gpupart("motion blur");
model_ubs.param[0].x = m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter);
model_ubs.param[0].x = moving ? m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter) : 0.0;
model_ubo->update(model_ubs);
m_pfx_motionblur->apply({image, vp.main_texv.get(), vp.main_texd.get()}, vp.main2_fb.get());
}
+8 -9
View File
@@ -387,7 +387,8 @@ bool make_targets(vk14::allocator &Memory, vk14::deletion_queue &Deletions, std:
{
ok = ok && make(Targets.motion_image, velocity, sampledcolour, VK_SAMPLE_COUNT_1_BIT, "scene velocity");
}
if (motion && Global.gfx_postfx_motionblur_enabled)
// the pass of the motion blur runs in every frame: the windscreens ask it for their drops and haze (see render_post())
if (motion)
{
ok = ok && make(Targets.blurred, hdr, sampledcolour, VK_SAMPLE_COUNT_1_BIT, "motion blurred", outputextent);
}
@@ -1607,12 +1608,7 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
render_ray_scene(vp);
}
// the camera with no vehicle of its own (freefly, the editor) blurs the world with its own movement, as a vehicle does with its
// (rendering/common/freecameramotion.h)
if (vp.main && (Global.pCamera.m_owner != nullptr))
m_freecamera.reset();
auto const freecameramovement{(vp.main && (Global.pCamera.m_owner == nullptr)) ? m_freecamera.next_frame(Global.pCamera.Pos) : glm::vec3{0.f}};
// the motion blur only when something in the view moves (see opengl46_renderer::Render_pass())
// the motion blurred only when something in the view moves (see opengl46_renderer::Render_pass()); the pass runs anyway
auto const motionblur{Global.gfx_postfx_motionblur_enabled && targets.motion &&
(m_vehiclesmoved || (freecameramovement != glm::vec3{0.f}) ||
((Global.pCamera.m_owner != nullptr) && (Global.pCamera.m_owner->get_future_movement() != glm::dvec3{0.0})))};
@@ -3698,10 +3694,13 @@ void vulkan14_renderer::render_post(std::size_t const Index, bool const Motionbl
store_ssr_history(Index, *hdr);
}
m_ssrframe = false;
if (Motionblur && targets.blurred)
// the pass of the motion blur in every frame: the windscreens (mat_rain_windscreen, mat_bugs_windscreen) ask it in the velocity
// target for the picture in their drops and the haze, also standing still, with the motion blur off and with any anti-aliasing.
// the motion is blurred only with Motionblur (by 0 otherwise)
if (targets.blurred && targets.motion_image)
{
vk14::draw_constants constants;
constants.data[0].x = m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter);
constants.data[0].x = Motionblur ? m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter) : 0.0;
// with the frames generated by dlss each frame drawn is shown for a part of its time: the blur as much shorter (the guide of
// the frame generation)
if (m_generationinputs && m_viewports[Index].main)
+3 -1
View File
@@ -441,7 +441,9 @@ struct global_settings {
bool gfx_bufferstreaming = true;
bool gfx_postfx_motionblur_enabled = true;
// the colour pass writes the velocities of the pixels: for the motion blur, the temporal anti-aliasing or dlss
bool gfx_motion_vectors() const { return gfx_postfx_motionblur_enabled || gfx_taa() || gfx_dlss(); }
// the velocity target is always drawn: the windscreens (mat_rain_windscreen, mat_bugs_windscreen) send the post-processing their
// drops and haze through it, whatever the motion blur and the anti-aliasing (not without the pipeline: no post-processing there)
bool gfx_motion_vectors() const { return ( false == gfx_skippipeline ) || gfx_postfx_motionblur_enabled; }
float gfx_postfx_motionblur_shutter = 0.01f;
GLenum gfx_postfx_motionblur_format = GL_RG16F;
GLenum gfx_format_color = GL_RGB16F;