mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-26 21:35:28 +01:00
Mostly deal with problems caused by polygon offset (#15867)
This commit is contained in:
@@ -21,11 +21,16 @@ void TileLayer::applyMaterialOptions(video::SMaterial &material, int layer) cons
|
||||
/*
|
||||
* The second layer is for overlays, but uses the same vertex positions
|
||||
* as the first, which easily leads to Z-fighting.
|
||||
* To fix this we can offset the polygons in the direction of the camera.
|
||||
* To fix this we offset the polygons of the *first layer* away from the camera.
|
||||
* This only affects the depth buffer and leads to no visual gaps in geometry.
|
||||
*
|
||||
* However, doing so intrudes the "Z space" of the overlay of the next node
|
||||
* so that leads to inconsistent Z-sorting again. :(
|
||||
* HACK: For lack of a better approach we restrict this to cases where
|
||||
* an overlay is actually present.
|
||||
*/
|
||||
if (layer == 1) {
|
||||
material.PolygonOffsetSlopeScale = -1;
|
||||
material.PolygonOffsetDepthBias = -1;
|
||||
if (need_polygon_offset) {
|
||||
material.PolygonOffsetSlopeScale = 1;
|
||||
material.PolygonOffsetDepthBias = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user