mirror of
https://github.com/xemu-project/xemu.git
synced 2026-07-11 01:24:41 +02:00
d6cb7536a2acf0dcc41934a627a0d63a5700ec76
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.
…
…
…
…
…
…
…
…
…
Please visit https://xemu.app for more information.
Description
Languages
C
82.3%
C++
6.9%
Python
3.5%
Dylan
2.7%
Shell
1.5%
Other
2.9%