Perspective-Correct Attribute Interpolation

Use reciprocal homogeneous depth when interpolating a surface attribute across a projected triangle.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Screen-space weights reflect the projected triangle
  2. A projection is linear before its final division

Screen-space weights reflect the projected triangle

Suppose two projected endpoints have homogeneous divisors \(w_0=1,w_1=2\) and scalar attributes zero and one. A screen midpoint has weights \((1/2,1/2)\). Interpolate attribute over \(w\) and reciprocal \(w\), then divide. The numerator is \(1/4\) and denominator \(3/4\), giving \(1/3\) instead of the simple screen average \(1/2\). A triangle uses the same ratio with three screen-space barycentric weights.

A projection is linear before its final division

Pre-division attribute relationships therefore need correction after positions have been divided. Attributes meant to vary linearly in screen space use a separate convention. Camera-plane crossings require clipping under the renderer’s coordinate contract. Barycentric coordinates supply ordinary affine weights. Pinhole projection gives the depth-dependent division producing the change.[1][2]

References

  1. Matt Pharr, Wenzel Jakob and Greg Humphreys, Physically Based Rendering ↩
  2. Richard Szeliski, Computer Vision: Algorithms and Applications ↩