This commit is contained in:
MihailRis 2025-03-10 14:51:59 +03:00
parent bf5a5b243f
commit a1860ff668
4 changed files with 24 additions and 6 deletions

View File

@ -116,7 +116,8 @@ void Decorator::updateRandom(
}
}
float intensity = weather.intensity * weather.fall.maxIntensity;
if (dst2 < 128 && random.randFloat() < glm::pow(intensity, 2.0f) && rainSplash.has_value()) {
if (rainSplash.has_value() && dst2 < 128 &&
random.randFloat() < glm::pow(intensity, 2.0f)) {
auto treg = util::get_texture_region(
assets, "particles:rain_splash_0", ""
);
@ -239,13 +240,11 @@ void Decorator::updateTextNotes() {
}
void Decorator::updateRandomSounds(float delta, const Weather& weather) {
float thunderRate = weather.a.thunderRate * weather.a.intensity +
weather.b.thunderRate * weather.b.intensity;
thunderTimer += delta;
util::PseudoRandom random(rand());
if (thunderTimer >= 1.0f) {
thunderTimer = 0.0f;
if (random.randFloat() < thunderRate) {
if (random.randFloat() < weather.thunderRate()) {
audio::play(
assets.get<audio::Sound>("ambient/thunder"),
glm::vec3(),

View File

@ -388,7 +388,7 @@ void WorldRenderer::draw(
renderBlockOverlay(wctx);
}
// Rendering fullscreen quad with
// Rendering fullscreen quad
auto screenShader = assets.get<Shader>("screen");
screenShader->use();
screenShader->uniform1f("u_timer", timer);

View File

@ -10,21 +10,34 @@ struct WeatherPreset : Serializable {
struct {
/// @brief Precipitation texture
std::string texture;
/// @brief Fall sound
std::string noise;
/// @brief Vertical speed
float vspeed = 1.0f;
/// @brief Max horizontal speed
float hspeed = 0.1f;
/// @brief UV scaling
float scale = 0.1f;
/// @brief Fall opacity interpreted as zero.
/// @example if 0.8 then opacity range is 0.8-1.0 for 0.0-1.0 intensity
/// @example if 0.8 then opacity range is 0.8-max for 0.0-1.0 intensity
float minOpacity = 0.0f;
/// @brief Fall opacity interpreted as one.
/// @example if 0.8 then opacity range is min-0.8 for 0.0-1.0 intensity
float maxOpacity = 1.0f;
/// @brief Max fall intencity
/// (influences opacity, noise volume and splashes frequency)
float maxIntensity = 1.0f;
/// @brief Clip texture by alpha channel
bool opaque = false;
/// @brief Fall splash
std::optional<ParticlesPreset> splash;
} fall {};
@ -38,8 +51,10 @@ struct WeatherPreset : Serializable {
/// @brief Weather fog curve
float fogCurve = 1.0f;
/// @brief Clouds opacity
float clouds = 0.0f;
/// @brief Thunder rate in range 0.0-1.0 (1.0 is 100% - every second)
float thunderRate = 0.0f;
/// @brief Weather effects intensity

View File

@ -41,6 +41,10 @@ struct Weather : Serializable {
return b.fogCurve * t + a.fogCurve * (1.0f - t);
}
float thunderRate() const {
return b.thunderRate * t + a.thunderRate * (1.0f - t);
}
dv::value serialize() const override {
return dv::object({
{"a", a.serialize()},