Skip to content

rasterisation

Zhou edited this page Apr 5, 2016 · 5 revisions

###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:

  1. Input three vertices a, b, and c in screen space.
  2. Translate their coordinates from [-1, 1] to [0, image-width/height].
  3. Find Y_min and Y_max among the three Y coordinates.
  4. Find two line equations E_1 to E_2 for edge ab and ac.
    The line equation is:
  5. 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.

RETURN TO PIPELINE

RETURN TO LETS-SET-OFF
RETURN TO INDEX

Clone this wiki locally