Browse Source

Clarify Pass:setDepthOffset more;

bjorn 1 year ago
parent
commit
8b9f81ab16
2 changed files with 6 additions and 1 deletions
  1. 1 1
      api/init.lua
  2. 5 0
      api/lovr/graphics/Pass/setDepthOffset.lua

+ 1 - 1
api/init.lua

@@ -20767,7 +20767,7 @@ return {
               description = "Set the depth offset.  This is a constant offset added to the depth value of pixels, as well as a \"sloped\" depth offset that is scaled based on the \"slope\" of the depth at the pixel.\n\nThis can be used to fix Z fighting when rendering decals or other nearly-overlapping objects, and is also useful for shadow biasing when implementing shadow mapping.",
               key = "Pass:setDepthOffset",
               module = "lovr.graphics",
-              notes = "The default depth offset is zero for both values.\n\nThis only applies to triangles, not points or lines.\n\nThe units for these offsets aren't specified very well -- they depend on the format of the depth texture, and the GPU can use them slightly differently for its depth calculations.  However, an `offset` of 1 will roughly correspond to the smallest-possible depth difference (e.g. 2^-16 for a `d16` depth texture).\n\nThe sloped depth scale is multiplied by the slope of the depth of the triangle.  For example, if pixels in the triangle all have the same depth (i.e. the triangle is facing the camera), then the slope of the depth will be zero and the sloped depth offset won't have any effect.  As the triangle starts to face away from the camera, the slope of the depth will increase and the sloped depth offset will begin to apply.  This can also be thought of corresponding to the normal vector of the triangle relative to the camera.",
+              notes = "The default depth offset is zero for both values.\n\nThis only applies to triangles, not points or lines.\n\nThe units for these offsets aren't specified very well -- they depend on the format of the depth texture, and the GPU can use them slightly differently for its depth calculations.  However, an `offset` of 1 will roughly correspond to the smallest-possible depth difference (e.g. 2^-16 for a `d16` depth texture).\n\nThe sloped depth scale is multiplied by the slope of the depth of the triangle.  For example, if pixels in the triangle all have the same depth (i.e. the triangle is facing the camera), then the slope of the depth will be zero and the sloped depth offset won't have any effect.  As the triangle starts to face away from the camera, the slope of the depth will increase and the sloped depth offset will begin to apply.  This can also be thought of corresponding to the normal vector of the triangle relative to the camera.\n\nNote that the offsets can be negative.  With LÖVR's default projection matrix, depth values of zero are far away and one are close up, so positive depth offsets will push depth values \"closer\" to the viewer.  With flipped projection matrices (a depth test of `lequal`), negative depth offsets would be used instead.",
               related = {
                 "Pass:setDepthTest",
                 "Pass:setDepthWrite"

+ 5 - 0
api/lovr/graphics/Pass/setDepthOffset.lua

@@ -43,6 +43,11 @@ return {
     triangle starts to face away from the camera, the slope of the depth will increase and the
     sloped depth offset will begin to apply.  This can also be thought of corresponding to the
     normal vector of the triangle relative to the camera.
+
+    Note that the offsets can be negative.  With LÖVR's default projection matrix, depth values of
+    zero are far away and one are close up, so positive depth offsets will push depth values
+    "closer" to the viewer.  With flipped projection matrices (a depth test of `lequal`), negative
+    depth offsets would be used instead.
   ]],
   related = {
     'Pass:setDepthTest',