18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-24 13:09:16 +01:00

fix(render): the free camera blurs with its own movement in the OpenGL 4.6 and Vulkan renderers

This commit is contained in:
2026-11-23 20:55:50 +01:00
parent d4f22061ee
commit 51c76da927
10 changed files with 164 additions and 4 deletions

View File

@@ -1584,9 +1584,15 @@ 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())
auto const motionblur{Global.gfx_postfx_motionblur_enabled && targets.motion &&
(m_vehiclesmoved || ((Global.pCamera.m_owner != nullptr) && (Global.pCamera.m_owner->get_future_movement() != glm::dvec3{0.0})))};
(m_vehiclesmoved || (freecameramovement != glm::vec3{0.f}) ||
((Global.pCamera.m_owner != nullptr) && (Global.pCamera.m_owner->get_future_movement() != glm::dvec3{0.0})))};
setup_matrices();
m_renderpass.draw_stats = {};
@@ -1602,6 +1608,12 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
glm::mat4 mv = OpenGLMatrices.data(GL_MODELVIEW);
future = glm::translate(mv, -glm::vec3(vehicle->get_future_movement())) * glm::inverse(mv);
}
else if (freecameramovement != glm::vec3{0.f})
{
// with the temporal anti-aliasing the velocities to the last frame hold the movement of the camera already
glm::mat4 mv = OpenGLMatrices.data(GL_MODELVIEW);
future = glm::translate(mv, -freecameramovement) * glm::inverse(mv);
}
// the light clusters of the viewport (the buffers of the grid are taken by each viewport in turn), and the lights of the pass
auto const clusters{Global.gfx_lights_clustered || Global.gfx_lights_clusterheatmap};

View File

@@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/.
#include "rendering/common/shadowfit.h"
#include "rendering/common/gpuparticles.h"
#include "rendering/common/temporalaa.h"
#include "rendering/common/freecameramotion.h"
#include "rendering/common/screenreflections.h"
#include "rendering/particles.h"
#include "model/material.h"
@@ -566,6 +567,8 @@ class vulkan14_renderer : public gfx_renderer, public gfx::scene_walk
bool m_vehiclesmoved{true};
// the temporal anti-aliasing of the main viewport (gfx.antialiasing taa), whose jitter and history dlss takes too
gfx::temporal_aa m_taa;
// the movement of the camera with no vehicle of its own in the main view, for the motion blur
gfx::free_camera_motion m_freecamera;
// dlss of the main viewport (gfx.antialiasing dlss): the size the scene is drawn at and the window it's upscaled to, planned at
// the start (0: dlss is off); the next frame starts its history anew
glm::ivec2 m_dlssrender{0};