diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/camera/MatrixHandler.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/camera/MatrixHandler.kt index 69a96df53..fd30f5a18 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/camera/MatrixHandler.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/camera/MatrixHandler.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020-2023 Moritz Zwerger + * Copyright (C) 2020-2024 Moritz Zwerger * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -95,7 +95,12 @@ class MatrixHandler( } private fun calculateProjectionMatrix(fov: Float, screenDimensions: Vec2 = context.window.sizef) { - projectionMatrix = GLM.perspective(fov.rad, screenDimensions.x / screenDimensions.y, NEAR_PLANE, FAR_PLANE) + val fog = camera.fogManager.state + var far = FAR_PLANE + if (fog.enabled) { + far = fog.end * (1.0f / 0.7f) + 2.0f // y axis is weighted differently + } + projectionMatrix = GLM.perspective(fov.rad, screenDimensions.x / screenDimensions.y, NEAR_PLANE, maxOf(far, 5.0f)) } fun init() { diff --git a/src/main/resources/assets/minosoft/rendering/shader/includes/fog.glsl b/src/main/resources/assets/minosoft/rendering/shader/includes/fog.glsl index 6e88607eb..ef49a6473 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/includes/fog.glsl +++ b/src/main/resources/assets/minosoft/rendering/shader/includes/fog.glsl @@ -42,7 +42,7 @@ float fog_alpha_from_distance(float distance2) { float fog_calculate_distance() { vec3 distance = finFragmentPosition.xyz - uCameraPosition.xyz; - distance.y *= 0.7f;// increase possible distance on y axis + distance.y *= 0.7f;// increase possible distance on y axis; if you change this, also update fog clipping in MatrixHandler.kt return dot(distance, distance); }