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, the grass racing under it no longer strobes in rings (#441)
The motion blur took the movement of the vehicle the camera sits in and nothing else, so in freefly (and the debug camera) the world got no blur from the camera at all. Low over grass the texture under the camera then moved tens of pixels a frame and strobed: rings around the camera, at the distances its pattern repeats, stronger with shift and ctrl, gone above about 20 m, worst on a 165 Hz screen. * the camera with no vehicle of its own blurs the world with its movement since the frame before, as a vehicle does with get_future_movement(); a jump of 50 m or more (a camera preset) is no movement * that movement is held to half a metre a frame: the blur takes the scene where the camera will be, and a camera faster than that passes the ground at the bottom of the screen within a frame, where its motion turned over into a bright band. with the shutter of the blur it still smears metres * the blur shader skips samples off the picture instead of reading its edge row again and again
This commit is contained in:
@@ -988,6 +988,31 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
auto const *vehicle = Global.pCamera.m_owner;
|
||||
glm::mat4 mv = OpenGLMatrices.data(GL_MODELVIEW);
|
||||
future = glm::translate(mv, -glm::vec3(vehicle->get_future_movement())) * glm::inverse(mv);
|
||||
m_freecameraposition.reset();
|
||||
}
|
||||
else if (vp.main)
|
||||
{
|
||||
// the free camera (freefly, debug camera) blurs the world with its own movement, as a vehicle does with its:
|
||||
// without it the ground racing under a low camera strobes in rings at the distances its texture repeats.
|
||||
// the movement of the frame before stands for the one to come; a jump (a camera preset) is no movement
|
||||
auto const position{Global.pCamera.Pos};
|
||||
if (m_freecameraposition)
|
||||
{
|
||||
auto movement{glm::vec3(position - *m_freecameraposition)};
|
||||
auto const length{glm::length(movement)};
|
||||
if (length < 50.f)
|
||||
{
|
||||
// the blur takes the scene where the camera will be: a fast camera (shift, ctrl) moves past the ground
|
||||
// at the bottom of the screen within a frame, it ends up behind it there and its motion turns over
|
||||
// into a bright band. half a metre a frame still blurs metres with the shutter of the motion blur
|
||||
auto const maxmovement{0.5f};
|
||||
if (length > maxmovement)
|
||||
movement *= maxmovement / length;
|
||||
glm::mat4 mv = OpenGLMatrices.data(GL_MODELVIEW);
|
||||
future = glm::translate(mv, -movement) * glm::inverse(mv);
|
||||
}
|
||||
}
|
||||
m_freecameraposition = position;
|
||||
}
|
||||
|
||||
Update_Lights( simulation::Lights );
|
||||
|
||||
Reference in New Issue
Block a user