Module raster

Module raster 

Source
Expand description

Translation of vector shapes into discrete pixels in the framebuffer.

Rasterization proceeds by turning a primitive such as a triagle into a sequence of scanlines, each corresponding to a horizontal span of pixels covered by the primitive on a given line. The scanlines, in turn, are converted into a series of fragments that represent potentially drawn pixels.

If depth testing (z-buffering) is enabled, the fragments are then tested against the current depth value in their position. For each fragment that passes the depth test, a color is computed by the fragment shader and written into the framebuffer. Fragments that fail the test are discarded.

Structs§

Frag
A fragment, or a single “pixel” in a rasterized primitive.
Scanline
A horizontal, 1-pixel-thick “slice” of a primitive being rasterized.
ScanlineIter
Iterator emitting scanlines, linearly interpolating values between the left and right endpoints as it goes.

Functions§

line
Rasterizes a one-pixel-thick line between two vertices.
scan
Returns an iterator that emits a scanline for each line from y0 to y1, interpolating varyings from l0 to l1 on the left and from r0 to r1 on the right side.
tri_fill
Rasterizes a filled triangle defined by three vertices.

Type Aliases§

ScreenPt
Point in screen space. x and y are viewport pixel coordinates, z is depth.
Varyings
Values to interpolate across a rasterized primitive.