-
Notifications
You must be signed in to change notification settings - Fork 50
rasterisation
###RASTERISATION
Suppose we have a ‘sitting’ triangle like the below left picture (by ‘sitting’ I mean flat top/bottom), then rasterization is done in this way:
- Input three vertices a, b, and c in screen space.
- Translate their coordinates from [-1, 1] to [0, image-width/height].
- Find Y_min and Y_max among the three Y coordinates.
- Find two line equations E_1 to E_2 for edge ab and ac.
The line equation is: - For each Y from Y_min to Y_max, find X_min to X_max using the above equations.
In this way, the input triangle is converted to a bunch of scanlines. Specially, if the input triangle is not ‘sitting’ but ‘standing’ like the following picture shows, it will be split into upper and lower sitting triangles so that we can rasterise them in the same way.
There is one last problem that I am not quite sure. That is how I should rasterise a sub-triangle that all of its vertices are in a line, or at one point? Currently I just ignore such triangles but I found out that it does not work well for slim meshes. Such as a bunch of pencils in a penholder as in the following picture.