diff --git a/res/presets/weather/rain.json b/res/presets/weather/rain.json index 18b58f57..184a80f0 100644 --- a/res/presets/weather/rain.json +++ b/res/presets/weather/rain.json @@ -13,11 +13,11 @@ "particles:rain_splash_2" ] }, - "min_opacity": 0.8 + "min_opacity": 0.8, + "max_intensity": 0.5 }, - "fog_opacity": 0.8, - "fog_dencity": 2.0, + "fog_opacity": 0.5, + "fog_dencity": 1.7, "fog_curve": 0.5, - "clouds": 0.5, - "thunder_rate": 0.1 + "clouds": 0.9 } diff --git a/res/presets/weather/thunder.json b/res/presets/weather/thunder.json new file mode 100644 index 00000000..d2a107f9 --- /dev/null +++ b/res/presets/weather/thunder.json @@ -0,0 +1,23 @@ +{ + "fall": { + "vspeed": 2.0, + "texture": "misc/rain", + "noise": "ambient/rain", + "splash": { + "lifetime": 0.2, + "spawn_interval": 0.0, + "size": [0.2, 0.2, 0.2], + "frames": [ + "particles:rain_splash_0", + "particles:rain_splash_1", + "particles:rain_splash_2" + ] + }, + "min_opacity": 0.8 + }, + "fog_opacity": 0.8, + "fog_dencity": 2.0, + "fog_curve": 0.5, + "clouds": 0.7, + "thunder_rate": 0.1 +} diff --git a/src/graphics/render/Decorator.cpp b/src/graphics/render/Decorator.cpp index 188b7936..0a68348e 100644 --- a/src/graphics/render/Decorator.cpp +++ b/src/graphics/render/Decorator.cpp @@ -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, diff --git a/src/graphics/render/WorldRenderer.cpp b/src/graphics/render/WorldRenderer.cpp index 602ad158..b9d51a24 100644 --- a/src/graphics/render/WorldRenderer.cpp +++ b/src/graphics/render/WorldRenderer.cpp @@ -203,9 +203,10 @@ void WorldRenderer::renderLevel( std::array 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; diff --git a/src/presets/WeatherPreset.cpp b/src/presets/WeatherPreset.cpp index 6077d1e7..6ae0bae7 100644 --- a/src/presets/WeatherPreset.cpp +++ b/src/presets/WeatherPreset.cpp @@ -13,6 +13,7 @@ dv::value WeatherPreset::serialize() const { froot["noise"] = fall.noise; froot["min_opacity"] = fall.minOpacity; froot["max_opacity"] = fall.maxOpacity; + froot["max_intensity"] = fall.maxIntensity; froot["opaque"] = fall.opaque; if (fall.splash) { froot["splash"] = fall.splash->serialize(); @@ -38,6 +39,7 @@ void WeatherPreset::deserialize(const dv::value& src) { froot.at("noise").get(fall.noise); froot.at("min_opacity").get(fall.minOpacity); froot.at("max_opacity").get(fall.maxOpacity); + froot.at("max_intensity").get(fall.maxIntensity); froot.at("opaque").get(fall.opaque); if (froot.has("splash")) { diff --git a/src/presets/WeatherPreset.hpp b/src/presets/WeatherPreset.hpp index 4d1966c2..e4e76402 100644 --- a/src/presets/WeatherPreset.hpp +++ b/src/presets/WeatherPreset.hpp @@ -22,6 +22,7 @@ struct WeatherPreset : Serializable { /// @example if 0.8 then opacity range is 0.8-1.0 for 0.0-1.0 intensity float minOpacity = 0.0f; float maxOpacity = 1.0f; + float maxIntensity = 1.0f; /// @brief Clip texture by alpha channel bool opaque = false; /// @brief Fall splash