From 5d4e67fdb112f1f75b4720fbbf0e14ba4e3dd441 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 27 Dec 2023 11:38:39 +0300 Subject: [PATCH] Fog update --- res/shaders/main.glslv | 4 ++-- src/frontend/WorldRenderer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/shaders/main.glslv b/res/shaders/main.glslv index 5bed5eea2..bfbce04ff 100644 --- a/res/shaders/main.glslv +++ b/res/shaders/main.glslv @@ -24,7 +24,7 @@ uniform float u_torchlightDistance; void main(){ - vec2 pos2d = (u_model * vec4(v_position, 1.0)).xz-u_cameraPos.xz; + vec3 pos3d = (u_model * vec4(v_position, 1.0)).xyz-u_cameraPos.xyz; vec4 modelpos = u_model * vec4(v_position, 1.0); vec4 viewmodelpos = u_view * modelpos; vec4 decomp_light = decompress_light(v_light); @@ -41,6 +41,6 @@ void main(){ skyLightColor = min(vec3(1.0), skyLightColor*SKY_LIGHT_MUL); a_color.rgb = max(a_color.rgb, skyLightColor.rgb*decomp_light.a); - a_distance = length(viewmodelpos); + a_distance = length(u_view * u_model * vec4(pos3d.x, pos3d.y*0.2, pos3d.z, 0.0)); gl_Position = u_proj * viewmodelpos; } diff --git a/src/frontend/WorldRenderer.cpp b/src/frontend/WorldRenderer.cpp index 5a6fc8129..4d343e184 100644 --- a/src/frontend/WorldRenderer.cpp +++ b/src/frontend/WorldRenderer.cpp @@ -128,7 +128,7 @@ void WorldRenderer::drawChunks(Chunks* chunks, void WorldRenderer::draw(const GfxContext& pctx, Camera* camera){ EngineSettings& settings = engine->getSettings(); skybox->refresh(level->world->daytime, - fmax(1.0f, 10.0f/(settings.chunks.loadDistance-2))+fog*2.0f, 4); + 1.0f+fog*2.0f, 4); const Content* content = level->content; const ContentIndices* contentIds = content->indices;