mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-08 06:50:22 -04:00
fog clipping
The frustum now respect the maximum fog distance. It should roughly match the previous far plane (though it is a lot more precise than before). It will improve performance a lot when being submerged in fluids or have blindness effect. Maybe it does fix some skin/entity renderer issues in the distance
This commit is contained in:
parent
b6b106ef83
commit
41880b0ada
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user