fix weather interpolation & add 'fall.max_intensity' property

This commit is contained in:
MihailRis
2025-03-02 10:38:30 +03:00
parent 7fc226f70f
commit 8640730520
6 changed files with 40 additions and 10 deletions
+3 -2
View File
@@ -115,7 +115,8 @@ void Decorator::updateRandom(
return;
}
}
if (dst2 < 128 && random.randFloat() < glm::pow(weather.intensity, 2.0f) && rainSplash.has_value()) {
float intensity = weather.intensity * weather.fall.maxIntensity;
if (dst2 < 128 && random.randFloat() < glm::pow(intensity, 2.0f) && rainSplash.has_value()) {
auto treg = util::get_texture_region(
assets, "particles:rain_splash_0", ""
);
@@ -137,7 +138,7 @@ void Decorator::updateRandom(
sound,
pos,
false,
weather.intensity * weather.intensity,
intensity * intensity,
1.0f,
false,
audio::PRIORITY_LOW,
+6 -3
View File
@@ -203,9 +203,10 @@ void WorldRenderer::renderLevel(
std::array<const WeatherPreset*, 2> weatherInstances {&weather.a, &weather.b};
for (const auto& weather : weatherInstances) {
float maxIntensity = weather->fall.maxIntensity;
float zero = weather->fall.minOpacity;
float one = weather->fall.maxOpacity;
float t = (weather->intensity * (one - zero)) + zero;
float t = (weather->intensity * (one - zero)) * maxIntensity + zero;
entityShader.uniform1i("u_alphaClip", weather->fall.opaque);
entityShader.uniform1f("u_opacity", weather->fall.opaque ? t * t : t);
if (weather->intensity > 1.e-3f && !weather->fall.texture.empty()) {
@@ -342,8 +343,10 @@ void WorldRenderer::draw(
const auto& settings = engine.getSettings();
const auto& worldInfo = world->getInfo();
float clouds = weather.b.clouds * glm::sqrt(weather.t) +
weather.a.clouds * glm::sqrt(1.0f - weather.t);
float sqrtT = glm::sqrt(weather.t);
float clouds = weather.b.clouds * sqrtT +
weather.a.clouds * (1.0f - sqrtT);
clouds = glm::max(worldInfo.fog, clouds);
float mie = 1.0f + glm::max(worldInfo.fog, clouds * 0.5f) * 2.0f;