This is the documentation for Enlighten.
module Triangle Rasteriser
2D triangle rasterizer
A triangle is defined by three sets of floating-point coordinates A pixel is defined as the product of two half-open sets [x,x+1)*[y,y+1) Thus any point is specifically inside one pixel
The aim of this rasterizer is to produce a VERY GOOD rasterization which is suitable for multiple purposes; thus, speed is less of a factor. Formally, instead of producing the set of pixels whose centers lie within the triangle, we produce a set of pixels which overlap the triangle AT ALL and, for each pixel, we produce a set of vertices which define the convex intersection of the pixel square and the triangle. This allows us to calculate the "correct" centroid-sampled position, calculate atlas masks, etc.
To ensure proper seaming between adjacent triangles, all edges are scan-converted from top to bottom.
Note: pixel coordinates are in usual "screen space" i.e. all coordinates positive, (0,0) is top-left
Classes
Name | Description |
|---|---|
stores a fragment of a triangle i.e. a triangle clipped to a pixel box | |
records details of the input triangle | |
stores a rasterization vertex, including barycentric coordinates |
Functions
Name | Description |
|---|---|
get signed area of fragment polygon; it's flipped if area < 0 | |
Gets the barycentric coords of the given point (x, y). | |
get barycentric coordinates of a point in the pixel | |
get centroid of fragment polygon (average of vertex positions) | |
is a given point in the fragment polygon? | |
RasterizeTriangle(float, float, float, float, float, float, RasterizationClient, void *) | rasterize a triangle |
rasterize a triangle regardless of winding order | |
Constructor. | |
Constructors. | |
Constructors. |
Variables
Name | Description |
|---|---|
float m_dX2 | x2-x1, y2-y1 |
float m_dX3 | x3-x1, y3-y1 |
float m_dY2 | x2-x1, y2-y1 |
float m_dY3 | x3-x1, y3-y1 |
Geo::u32 m_NumPts | number of points in fragment polygon |
const RastVert * m_Points | fragment polygon points; coordinates are in [0,1]x[0,1] i.e. |
const RastTri * m_Tri | reference to triangle that owns this fragment |
float m_U | Barycentric coordinates. |
float m_V | Barycentric coordinates. |
float m_X | Vertex position. |
Geo::s32 m_X | integer coordinates of (top-left of) pixel |
float m_X1 | x1, y1 |
float m_Y | Vertex position. |
Geo::s32 m_Y | integer coordinates of (top-left of) pixel |
float m_Y1 | x1, y1 |