18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-05 16:55:32 +01:00

Merge branch 'feat/world-sphere-up' into feat/world-sphere-particles

This commit is contained in:
maj00r
2026-12-03 14:44:27 +01:00
+24 -9
View File
@@ -538,6 +538,26 @@ bool make_targets(vk14::allocator &Memory, vk14::deletion_queue &Deletions, std:
return true;
}
// the sky and the weather take the sun in the local axes of the body at the camera; its light shades the world, whose axes those are
// only on the plane: on a curved body the direction is turned to the world
glm::vec3 sunlight_in_world(glm::vec3 const &Direction, glm::dvec3 const &Camera)
{
auto const &body{world_geometry::current_body()};
if (false == body.curved())
return Direction;
return glm::vec3{glm::transpose(world_geometry::local_frame(body, Camera)) * glm::dvec3{Direction}};
}
// the sun, the moon and the stars are in the local axes of the body at the camera: on a curved body the view of the world is turned
// to them
glm::mat4 view_in_local_axes(glm::mat4 const &Modelview, glm::dvec3 const &Camera)
{
auto const &body{world_geometry::current_body()};
if (false == body.curved())
return Modelview;
return Modelview * glm::mat4{glm::mat3{glm::transpose(world_geometry::local_frame(body, Camera))}};
}
} // namespace
// the frame
@@ -839,10 +859,8 @@ bool vulkan14_renderer::Render()
ctx.passes.end_async();
m_commands = ctx.commands;
}
// the sky and the weather above take the sun in the local axes of the body at the camera; its light shades the world, whose
// axes those are only on the plane
if (auto const &body{world_geometry::current_body()}; body.curved())
m_sunlight.direction = glm::vec3{glm::transpose(world_geometry::local_frame(body, Global.pCamera.Pos)) * glm::dvec3{m_sunlight.direction}};
// the sky and the weather above take the sun in the local axes of the body at the camera
m_sunlight.direction = sunlight_in_world(m_sunlight.direction, Global.pCamera.Pos);
// lamps of models and vehicles around the camera and the cab lamp, for the views of the frame to take into their light buffers
if ((false == Global.gfx_skiprendering) && (simulation::Region != nullptr))
{
@@ -2833,11 +2851,8 @@ void vulkan14_renderer::render_environment(world_environment *Environment)
::glPopMatrix();
}
// the sun, the moon and the stars are in the local axes of the body at the camera: on a curved body the view of the world is
// turned to them
glm::mat4 modelview{OpenGLMatrices.data(GL_MODELVIEW)};
if (auto const &body{world_geometry::current_body()}; body.curved())
modelview *= glm::mat4{glm::mat3{glm::transpose(world_geometry::local_frame(body, m_renderpass.pass_camera.position()))}};
// the sun, the moon and the stars are in the local axes of the body at the camera
glm::mat4 const modelview{view_in_local_axes(OpenGLMatrices.data(GL_MODELVIEW), m_renderpass.pass_camera.position())};
// stars of the catalogue, turned by the sidereal time; the fog and the clouds go over them
render_stars(modelview);
// the bodies give their colour premultiplied, and as alpha how much of the sky behind them they hide (celestial.frag)