Putting it All Together: Method 1
using Screen Space to NDC mapping
Kenny Hoff
6/17/97
We can now put together the simplest parts of the derivation to form
a complete rasterization pipeline for the sphere:
-
In order to be able to reuse the calculations as described in the scan-conversion
and depth-evaluation sections, we must do both operations in screen or
pixel space. This means that the depth values we obtain will also be in
screen space as an offset to z=0 in screen space (this simplifies the previously
described depth evaluation because c becomes zero; sphere assumed to be
centered at (a,b,0) in screen space); however, we need the depth values
in NDC space as an offset from the NDC depth of the sphere's center. The
depth values in screen space will be in the range [0,PixelRadius]. We can
convert this to offsets in NDC space (range [-1,1]) by performing the inverse
of the viewport scaling originally applied to the (x,y) components of the
NDC coords: NDCdepthOffset = PixelDepthOffset / AverageScreenDimension
-
Subtract the NDC depth offset from the sphere's center in NDC space to
obtain the actual NDC Z-value (remember NDC goes from -1 to 1 in Z with
positive values being farther away). We then have to perform the depth-range
scaling and then the fixed point scaling to obtain the actual Z-value to
be compared and written with.