mirror of
https://github.com/minetest/minetest.git
synced 2025-03-13 13:52:35 +01:00
Implement polygon offset in GL3 driver
This commit is contained in:
irr
@ -304,11 +304,7 @@ public:
|
||||
|
||||
//! A constant z-buffer offset for a polygon/line/point
|
||||
/** The range of the value is driver specific.
|
||||
On OpenGL you get units which are multiplied by the smallest value that is guaranteed to produce a resolvable offset.
|
||||
On D3D9 you can pass a range between -1 and 1. But you should likely divide it by the range of the depthbuffer.
|
||||
Like dividing by 65535.0 for a 16 bit depthbuffer. Thought it still might produce too large of a bias.
|
||||
Some article (https://aras-p.info/blog/2008/06/12/depth-bias-and-the-power-of-deceiving-yourself/)
|
||||
recommends multiplying by 2.0*4.8e-7 (and strangely on both 16 bit and 24 bit). */
|
||||
On OpenGL you get units which are multiplied by the smallest value that is guaranteed to produce a resolvable offset. */
|
||||
f32 PolygonOffsetDepthBias;
|
||||
|
||||
//! Variable Z-Buffer offset based on the slope of the polygon.
|
||||
|
@ -1313,7 +1313,17 @@ void COpenGL3DriverBase::setBasicRenderStates(const SMaterial &material, const S
|
||||
getGLBlend(srcAlphaFact), getGLBlend(dstAlphaFact));
|
||||
}
|
||||
|
||||
// TODO: Polygon Offset. Not sure if it was left out deliberately or if it won't work with this driver.
|
||||
// Polygon Offset
|
||||
if (resetAllRenderStates ||
|
||||
lastmaterial.PolygonOffsetDepthBias != material.PolygonOffsetDepthBias ||
|
||||
lastmaterial.PolygonOffsetSlopeScale != material.PolygonOffsetSlopeScale) {
|
||||
if (material.PolygonOffsetDepthBias || material.PolygonOffsetSlopeScale) {
|
||||
GL.Enable(GL.POLYGON_OFFSET_FILL);
|
||||
GL.PolygonOffset(material.PolygonOffsetSlopeScale, material.PolygonOffsetDepthBias);
|
||||
} else {
|
||||
GL.Disable(GL.POLYGON_OFFSET_FILL);
|
||||
}
|
||||
}
|
||||
|
||||
if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness)
|
||||
GL.LineWidth(core::clamp(static_cast<GLfloat>(material.Thickness), DimAliasedLine[0], DimAliasedLine[1]));
|
||||
|
Reference in New Issue
Block a user