fix weather interpolation & add 'fall.max_intensity' property
This commit is contained in:
parent
7fc226f70f
commit
8640730520
@ -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
|
||||
}
|
||||
|
||||
23
res/presets/weather/thunder.json
Normal file
23
res/presets/weather/thunder.json
Normal file
@ -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
|
||||
}
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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")) {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user