add fog_curve parameter & update shaders

This commit is contained in:
MihailRis
2025-02-26 04:49:45 +03:00
parent d7f20e7388
commit e6ea4fe37e
8 changed files with 29 additions and 27 deletions
+6 -17
View File
@@ -103,21 +103,7 @@ WorldRenderer::WorldRenderer(
);
weather = {};
auto& fall = weather.fall;
fall.vspeed = 2.0f;
fall.texture = "misc/rain";
fall.noise = "ambient/rain";
ParticlesPreset rainSplash;
rainSplash.frames = {
"particles:rain_splash_0",
"particles:rain_splash_1",
"particles:rain_splash_2"
};
rainSplash.lifetime = 0.2f;
rainSplash.spawnInterval = 0.0f;
rainSplash.size = {0.2f, 0.2f, 0.2f};
fall.splash = std::move(rainSplash);
weather.deserialize(io::read_json("res:presets/weather/rain.json"));
}
WorldRenderer::~WorldRenderer() = default;
@@ -138,6 +124,7 @@ void WorldRenderer::setupWorldShader(
shader.uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
shader.uniform1f("u_weatherFogOpacity", weather.fogOpacity * weather.intensity);
shader.uniform1f("u_weatherFogDencity", weather.fogDencity);
shader.uniform1f("u_weatherFogCurve", weather.fogCurve);
shader.uniform1f("u_dayTime", level.getWorld()->getInfo().daytime);
shader.uniform2f("u_lightDir", skybox->getLightDir());
shader.uniform3f("u_cameraPos", camera.position);
@@ -216,8 +203,10 @@ void WorldRenderer::renderLevel(
entityShader.uniform1i("u_alphaClip", false);
float zero = weather.fall.minOpacity;
entityShader.uniform1f("u_opacity", (weather.intensity * (1.0f - zero)) + zero);
precipitation->render(camera, pause ? 0.0f : delta, weather);
weather.intensity = -glm::cos(timer * 0.2f) * 0.5f + 0.5f;
if (weather.intensity > 1.e-3f && !weather.fall.texture.empty()) {
precipitation->render(camera, pause ? 0.0f : delta, weather);
}
//weather.intensity = -glm::cos(timer * 0.2f) * 0.5f + 0.5f;
skybox->unbind();
}
+2
View File
@@ -18,6 +18,7 @@ dv::value WeatherPreset::serialize() const {
root["fog_opacity"] = fogOpacity;
root["fog_dencity"] = fogDencity;
root["fog_curve"] = fogCurve;
root["clouds"] = clouds;
return root;
@@ -40,5 +41,6 @@ void WeatherPreset::deserialize(const dv::value& src) {
}
src.at("fog_opacity").get(fogOpacity);
src.at("fog_dencity").get(fogDencity);
src.at("fog_curve").get(fogCurve);
src.at("clouds").get(clouds);
}
+4 -1
View File
@@ -31,10 +31,13 @@ struct WeatherPreset : Serializable {
/// @brief Weather fog depth multiplier
float fogDencity = 2.0f;
/// @brief Weather fog curve
float fogCurve = 0.5f;
float clouds = 0.5f;
/// @brief Weather effects intensity
float intensity = 0.9f;
float intensity = 1.0f;
dv::value serialize() const override;
void deserialize(const dv::value& src) override;