coldhex d6cb7536a2 nv2a: Depth buffer precision improvements and polygon offset slope factor
1. Use barycentric coordinates to interpolate depth values. Linux, Mesa
and AMD Radeon RX 6600 with Vulkan driver currently has quite poor
interpolation precision, which results in artifacts in at least Chronicles
of Riddick. Intel integrated UHD 770 has much better precision, for
example. This commit handles depth interpolation manually. Also note that
the previous w-buffer interpolation used gl_FragCoord.w which can't produce
all w-values, e.g. 1.0f/16777046.0f equals 1.0f/16777047.0f with 32-bit
floats. This also uses depth value differences in interpolation which has
the desired property that a triangle with the same z-value on all vertices
will result in exactly that same z-value when interpolated. At least the
game Shenmue II sky rendering relies on this.

2. Computes polygon depth bias slope for both z-buffering and w-buffering.
These are computed by taking the max and abs of partial derivatives of
either of the functions z=z(x,y) or w=w(x,y), where x,y,z,w are
screen-space coordinates. This matches Xbox hardware for z-buffering where
the partial derivatives are constants over any fixed triangle. However,
for w-buffering the partial derivatives vary over any fixed triangle, but
Xbox appears to compute just a single depth slope at the first visible
pixel (where "first" means something like first in top-left order) and uses
that over the whole triangle. This commit computes the slope per-pixel.
The way to compute the partial derivatives is by using the chain-rule, e.g.
dw/dx = -w^2 * d(1/w)/dx. This is useful since 1/w is linear in
screen-space and therefore d(1/w)/dx is constant over any fixed triangle.
But, as mentioned, finding out the w-value for the first visible pixel
of a triangle is difficult in OpenGL/Vulkan and is not done here. Instead
we calculate depth slope per-pixel.
2025-10-24 15:31:28 -04:00
2025-02-15 13:59:10 -07:00
2025-01-03 22:30:04 -07:00
2025-01-03 22:30:04 -07:00
2025-02-15 13:59:10 -07:00
2025-07-02 21:42:02 -07:00
2025-02-15 13:59:10 -07:00
2025-02-15 13:59:10 -07:00
2024-08-13 19:01:42 +02:00
2025-01-06 23:05:53 -07:00
2024-12-17 14:26:42 +03:00
2024-07-22 09:38:16 +01:00
2025-02-15 13:59:10 -07:00
2025-02-15 13:59:10 -07:00
2025-10-15 21:17:27 -04:00
2025-07-02 21:42:02 -07:00
2024-12-31 01:37:05 -07:00
2025-03-27 23:33:40 -07:00
2025-01-03 22:30:04 -07:00
2025-01-03 22:30:04 -07:00
2024-10-07 16:41:58 +02:00
2025-01-09 15:48:27 -07:00
2025-06-03 19:36:08 -07:00
2025-02-15 13:59:10 -07:00
2025-01-03 22:30:04 -07:00
2024-12-31 01:37:05 -07:00
2024-12-31 01:37:05 -07:00
S
Description
Original Xbox Emulator for Windows, macOS, and Linux (Active Development)
Readme 673 MiB
Languages
C 82.3%
C++ 6.9%
Python 3.5%
Dylan 2.7%
Shell 1.5%
Other 2.9%