Contents
How to do perspective correct interpolation in Excel?
Perspective correct interpolation of an attribute would vary linearly in the clip coordinates (and by extension, world coordinates). For that we need to get the barycentric coordinates of the fragment in clip space.
Can You interpolate a triangle over the interior?
Given an attribute (f0, f1, f2) on the vertices of the triangle, we can now interpolate it over the interior: This is a linear function of P, therefore it is the unique linear interpolant over the given triangle. The math also works in either 2D or 3D. So let’s say we fill a projected 2D triangle on the screen.
How does Perspective Division on clip coordinates work?
Perspective division on clip coordinates yields normalized device coordinates, followed by a viewport transformation (see section 13.6.1) to convert these coordinates into window coordinates. But then keeps the 1 / gl_Position.w as the last component of gl_FragCoord: This transform is bijective, so no depth information is lost.
How are vertex attributes divided in perspective correct interpolation?
If we decide to use perspective correct interpolation, then the vertex attribute values are divided by the z-coordinate of the vertex they are associated to (lines 48-50). The following image shows on the left, an image computed without perspective correct interpolation, an image with (middle) and the content of the z-buffer (as a greyscale image.
Is there nonlinear interpolation for view space Z?
However, computing view-space Z requires nonlinear interpolation (it is a rational function based on my results). Is nonlinear interpolation performed in hardware to get perspective correct Z, or equivalently linear interpolation is performed on 1 Z but a division is required to get view-space Z anyways?
Is the interpolation formula for UV texture mapping correct?
Then I turn the u v indexes into one index in order to fetch the correct pixel from the image data (which is a 1 dimensional px array): The interpolation formula is correct considering the consistency of the texture (including the straight stripes).