theory - 3d graphics: Rasterizing triangles -
this theoretical question.
let's want draw triangle on screen. if supply vertex shader 3 points in 3d, convert them 3 points in 2d, in window coordinates, or screen coordinates. 3 pixel coordinates on monitor or display.
how, here, graphics pipeline go filling in triangle, based on 3 points? guess this:
bound triangle box determining upper , lower bounds x , y so:
use bresenham's line algorithm draw 3 edges of triangle 3 different colors. cannot use regular color buffer step.
do every row of pixels in box: start leftmost pixel (in whereever stored results of step 2), go right until hit edge. now, keep going right, coloring pixels in (running fragment shader), , writing regular color buffer, until hit different line (hitting different colored pixel in whereever results of step 2 stored). stop , go next line.
draw edges fragment shader in regular color buffer.
this seems complicated , inefficient solution. how done?
have @ scanline algorithm. it's moving horizontal line top bottom, calculating 2 intersections of scanline triangle, drawing line between these 2 points.
Comments
Post a Comment