17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-31 00:50:29 +01:00

Draw the cab probe with all the lights of the cab

This commit is contained in:
2026-10-29 20:05:03 +01:00
parent 8bd41f431d
commit 96100f1155
14 changed files with 143 additions and 89 deletions

View File

@@ -6320,16 +6320,15 @@ void opengl46_renderer::Render_cab_probe()
glm::vec3 extent{0.f};
if ((vehicle != nullptr) && (false == m_locallights.cab_bounds(vehicle->mdKabina, m_geometry, center, extent)))
vehicle = nullptr;
// the brightest light of the cab lights the probe when it's a light of the frame
auto const *principal{(vehicle != nullptr) && (m_locallights.cab_lamp_vehicle() == vehicle) ? m_locallights.cab_principal() : nullptr};
auto const *lamp{principal != nullptr ? &principal->source : nullptr};
if (false == m_cabprobe.update_wanted(vehicle, (vehicle != nullptr ? vehicle->mdKabina : nullptr), center, extent, lamp, m_framestamp))
// the lights of the cab light the probe when they're lights of the frame
std::vector<gfx::local_lights::cab_light> const nolights;
auto const &lights{(vehicle != nullptr) && (m_locallights.cab_lamp_vehicle() == vehicle) ? m_locallights.cab_lights() : nolights};
if (false == m_cabprobe.update_wanted(vehicle, (vehicle != nullptr ? vehicle->mdKabina : nullptr), center, extent, lights, m_framestamp))
return;
glDebug("render cab probe");
// the light with its shadow map, when the map holds the shadows of the light where it is
auto const slot{principal != nullptr ? m_localshadows.cab_slot_of(vehicle, *principal) : -1};
m_cabprobe.setup_drawing(scene_ubs, lamp, (principal != nullptr ? principal->local : glm::vec3{0.f}), (slot >= 0), (slot >= 0 ? m_localshadows.weights(static_cast<std::size_t>(slot)) : glm::vec4{0.f}));
// the lights with their shadow maps, where the maps hold their shadows
m_cabprobe.setup_drawing(scene_ubs, lights, m_localshadows, vehicle);
// the sun coming in through the windows, as the shading of the last frame got it
m_cabprobe.setup_sun(scene_ubs, vehicle, -m_sunlight.direction, glm::vec3{light_data.lights[0].color} * light_data.lights[0].intensity, m_colorpass.pass_camera.position());
scene_ubo->update(scene_ubs);