# Perspective correct interpolation z-buffer

Computer Graphics Asked by lightxbulb on August 27, 2021

While I was deriving expressions for perspective-correct linear interpolation on triangles, I reached the conclusion that the interpolation may be kept linear only if view-space $$Z$$ is available. 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 $$frac{1}{Z}$$ but a division is required to get view-space $$Z$$ anyways? As far as I get it there is no way around that – a division is required per-pixel to get perspective-correct Z values – is that correct?

Yes, that's correct. Perspective-correct interpolation works by (for some quantity $$u$$ to be interpolated) calculating $$u/z$$ and $$1/z$$ at each vertex, linearly interpolating those values in screen space, then calculating $$u = (u/z) / (1/z)$$ at each sample point. This is done by the GPU hardware behind the scenes.

Correct answer by Nathan Reed on August 27, 2021

## Related Questions

### Is there an algorithm to bold an outline font?

2  Asked on December 23, 2021

### alternative to spherical harmonics to model radiance aproximation, optimized for real-time evaluation

0  Asked on December 14, 2021

### Transfer the texture between two different sets of uv

1  Asked on December 9, 2021

### How to retrieve data from Compute Shader to CPU?

0  Asked on November 15, 2021 by ethan-ma

### unwanted patterns in simplex noise

1  Asked on November 13, 2021 by sam-apostel

### Procedural generation of biological models

1  Asked on November 13, 2021 by daniel-cooke

### What method is used for baking grayscale curvature maps

1  Asked on November 10, 2021 by jummit

### Why are texture coordinates often called UVs?

2  Asked on August 27, 2021 by samanthaj

### Dynamic Ray-Triangle Intersection

1  Asked on August 27, 2021 by cemklkn

### Reducing artificial rings in mean curvature of mesh

1  Asked on August 27, 2021

### Fast and exact Geodesics on meshes, Backtracking confusion

1  Asked on August 27, 2021

### How to scale signed distance field fonts properly?

1  Asked on August 27, 2021 by endanke

### The ploygon width parallel to the x axis as a function of the y ordonate?

0  Asked on August 27, 2021 by hafid-boukhoulda

### Find the formulas of the middle point algorithm for drawing the parabola?

0  Asked on August 27, 2021 by mrjab

### Crystal ball rotation – I don’t get why the code works

0  Asked on August 27, 2021 by user13665

### Draw Line on Arbitrary Surface

0  Asked on August 27, 2021 by valentin-molina

### How to raytrace Bezier surfaces?

5  Asked on August 27, 2021 by luser-droog