mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 00:45:29 +01:00
Rain windscreen: the glass fills up to full in any rain, more slowly in a lighter one
The game now counts the rain the glass meets (more at speed) and how wet the glass is (scene_ubs.rain_state: it fills with the rain and dries when the rain stops), and the rain fallen when each blade was at the end of its sweep (wiper_rain_out/return). The glass with rain gets as many drops, droplets, rivulets and as much haze as the heaviest rain gives, scaled by how wet it is; where a blade went over it they come back with the rain fallen since. A lighter rain only takes longer: 95% full in 10 s of the heaviest rain standing still, 20 s at cloud cover 1.5, 2.5x as fast at 100 km/h; half dry in 3 minutes standing still. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
This commit is contained in:
@@ -1136,7 +1136,8 @@ void vulkan14_renderer::render_scene()
|
||||
// the water on the windscreens of the cab: a step of its simulation once a frame, before the passes which draw the glasses
|
||||
scene.water.update(Timer::GetDeltaTime());
|
||||
// the drops and the rivulets of the glasses with rain, for the time the block of the scene gets (scene_ubs.time)
|
||||
scene.water.update_rain_cells(static_cast<float>(Timer::GetTime()), glm::saturate(Global.Overcast - 1.f));
|
||||
// (the drops a cell may hold: as many as the glass is wet, a little more, since it's the wetness of the frame before)
|
||||
scene.water.update_rain_cells(static_cast<float>(Timer::GetTime()), (m_glasswet > 0.001) ? static_cast<float>(std::min(m_glasswet + 0.01, 1.0)) : 0.f);
|
||||
if (scene.targets.size() < m_viewports.size())
|
||||
{
|
||||
scene.targets.resize(m_viewports.size());
|
||||
@@ -1582,6 +1583,8 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
scene_ubs.wiper_timer_return = glm::vec4{-1000.};
|
||||
scene_ubs.wiper_bugs_out = glm::vec4{-1.};
|
||||
scene_ubs.wiper_bugs_return = glm::vec4{-1.};
|
||||
scene_ubs.wiper_rain_out = glm::vec4{-1.};
|
||||
scene_ubs.wiper_rain_return = glm::vec4{-1.};
|
||||
m_wiperbugs = 0.0;
|
||||
}
|
||||
// the insects the vehicle meets (mat_bugs_windscreen): none below 20 km/h, above it the more the faster, counted in seconds of
|
||||
@@ -1589,6 +1592,23 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
if (owner != nullptr)
|
||||
m_wiperbugs += Timer::GetDeltaTime() * std::max(std::abs(owner->MoverParameters->V) * 3.6 - 20.0, 0.0) / 80.0;
|
||||
scene_ubs.rain_wind.w = static_cast<float>(m_wiperbugs);
|
||||
// the rain the glass meets (mat_rain_windscreen): counted in seconds of the heaviest rain standing still, more at speed (the
|
||||
// glass runs into it). the glass fills with it up to as many drops as it gets (a lighter rain only fills it more slowly), and
|
||||
// dries when it stops (by half in dry_halflife standing still, faster at speed)
|
||||
{
|
||||
constexpr double fill_rate{0.3}; // per second of the heaviest rain: 95% full in 10 s (20 s at cloud cover 1.5)
|
||||
constexpr double fill_speed{1.5}; // at 100 km/h and more the glass meets x (1 + fill_speed) as much rain
|
||||
constexpr double dry_halflife{180.0}; // seconds standing still
|
||||
auto const dt{Timer::GetDeltaTime()};
|
||||
auto const speed{(owner != nullptr) ? std::min(std::abs(owner->MoverParameters->V) * 3.6 / 100.0, 1.0) : 0.0};
|
||||
auto const meet{static_cast<double>(percipitation_intensity) * (1.0 + fill_speed * speed)};
|
||||
m_wiperrain += dt * meet;
|
||||
if (percipitation_intensity > 0.f)
|
||||
m_glasswet += (1.0 - m_glasswet) * (1.0 - std::exp(-fill_rate * dt * meet));
|
||||
else
|
||||
m_glasswet *= std::exp(-dt * std::log(2.0) / dry_halflife * (1.0 + 2.0 * speed));
|
||||
scene_ubs.rain_state = glm::vec4{static_cast<float>(m_wiperrain), static_cast<float>(m_glasswet), static_cast<float>(fill_rate), 0.f};
|
||||
}
|
||||
if (owner != nullptr)
|
||||
{
|
||||
auto const cabactive{owner->MoverParameters->CabActive != 0 ? owner->MoverParameters->CabActive : 1};
|
||||
@@ -1606,11 +1626,13 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
{
|
||||
scene_ubs.wiper_timer_out[i] = scene_ubs.time;
|
||||
scene_ubs.wiper_bugs_out[i] = static_cast<float>(m_wiperbugs);
|
||||
scene_ubs.wiper_rain_out[i] = static_cast<float>(m_wiperrain);
|
||||
}
|
||||
if (owner->dWiperPos[index] > .975)
|
||||
{
|
||||
scene_ubs.wiper_timer_return[i] = scene_ubs.time;
|
||||
scene_ubs.wiper_bugs_return[i] = static_cast<float>(m_wiperbugs);
|
||||
scene_ubs.wiper_rain_return[i] = static_cast<float>(m_wiperrain);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1620,6 +1642,8 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
scene_ubs.wiper_timer_return[i] = -1000.;
|
||||
scene_ubs.wiper_bugs_out[i] = -1.;
|
||||
scene_ubs.wiper_bugs_return[i] = -1.;
|
||||
scene_ubs.wiper_rain_out[i] = -1.;
|
||||
scene_ubs.wiper_rain_return[i] = -1.;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user