Scoop du Jour: Barycentric Quad Rasterization on a Cone

  by C.G. Scoop
Sept., 2022

In August, the Journal of Computer Graphics Techniques published Barycentric Quad Rasterization. A few days later, Paul Haeberli asked whether the barycentric method, which reduces distortion and discontinuity in a texture-mapped sphere, would also improve the rendering of a cone?

In particular, at the tip of a cone, as at a pole of a sphere, a quad has a degenerate edge defined by two coincident points (see Figure 6 of the paper). With triangle rasterization, one of the points is ignored (see Figure 7). For the sphere, the two points differ in uv-coordinates and thus triangle rasterization produces a texture discontinuity. For the cone, the two points also differ in surface normal, producing a shading discontinuity as well.

The discontinuities in texture can be overcome by avoiding the Mercator projection used for a sphere and, instead, employing a conical projection as the texture source (that is, a circle whose circumference corresponds to the base of the cone and whose center corresponds to the tip). The discontinuities in shading, however, cannot be overcome with triangles or quad-splits.


The cone example revealed a bug in the pixel shader (Listing 2). In subroutine BarycentricWeights, the following assignment fails if A is zero:
    t[i] = (r[i]*r[(i+1)%4]-D)/A;

It should be replaced with:
    t[i] = abs(A) < 1.e-6? 0 : (r[i]*r[(i+1)%4]-D)/A;

This correction removes the need for double precision in the subroutines BarycentricWeights and UV (thus, p. 73, “Double precision is used ... artifacts” is incorrect).