add weather intensity (WIP)

This commit is contained in:
MihailRis
2025-02-26 02:24:16 +03:00
parent 830e05733f
commit fe503d1192
5 changed files with 38 additions and 6 deletions
+13 -3
View File
@@ -136,8 +136,8 @@ void WorldRenderer::setupWorldShader(
shader.uniform1f("u_gamma", settings.graphics.gamma.get());
shader.uniform1f("u_fogFactor", fogFactor);
shader.uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
shader.uniform1f("u_weatherFogOpacity", 0.8f);
shader.uniform1f("u_weatherFogDencity", 2.0f);
shader.uniform1f("u_weatherFogOpacity", weather.fogOpacity * weather.intensity);
shader.uniform1f("u_weatherFogDencity", weather.fogDencity);
shader.uniform1f("u_dayTime", level.getWorld()->getInfo().daytime);
shader.uniform2f("u_lightDir", skybox->getLightDir());
shader.uniform3f("u_cameraPos", camera.position);
@@ -183,6 +183,7 @@ void WorldRenderer::renderLevel(
}
entityShader.uniform1i("u_alphaClip", true);
entityShader.uniform1f("u_opacity", 1.0f);
level.entities->render(
assets,
*modelBatch,
@@ -213,7 +214,10 @@ void WorldRenderer::renderLevel(
setupWorldShader(entityShader, camera, settings, fogFactor);
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;
skybox->unbind();
}
@@ -344,7 +348,13 @@ void WorldRenderer::draw(
const auto& settings = engine.getSettings();
const auto& worldInfo = world->getInfo();
skybox->refresh(pctx, worldInfo.daytime, 1.0f + worldInfo.fog * 2.0f, 4);
skybox->refresh(
pctx,
worldInfo.daytime,
1.0f +
glm::max(worldInfo.fog, weather.clouds * glm::sqrt(weather.intensity) * 0.5f) * 2.0f,
4
);
const auto& assets = *engine.getAssets();
auto& linesShader = assets.require<Shader>("lines");