mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Mostly deal with problems caused by polygon offset (#15867)
This commit is contained in:
parent
c07499ccfc
commit
42ac5b2f40
3 changed files with 25 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue