Previous | Next --- Slide 8 of 21
Back to Lecture Thumbnails
hii

How do we decide which blocks to fill? Some blocks are not filled though the line crosses through.

JeenaYin

My guess is that it is filling the blocks based on whether the 'center' of the block is inside of the triangle?

churchill

Maybe it's doing the same thing we saw in lecture 1, where it fills a block if the line goes through a diamond in the center of the block?

motoole2

Indeed! This is related to how GPUs rasterize lines, and touched upon this here.

A-star

In the class it was mentioned that GPU can do a lot of simple tasks in parallel and for a problem like triangle fill it can calculate for "every" pixel whether that pixel lies inside the triangle or not and fill it accordingly. Isn't that too much wastage to check every pixel. Instead can we come up with a rectangle that encloses the triangle and only check pixels that lie inside that rectangle?

Doris

What about the pixels on the lines? How can We decide to do with them?

uhhh

I guess pixels on the lines are determined to be within the triangle if the line is considered a "top edge" or "left edge", according to lecture 5, slide 30.

motoole2

@A-star: As mentioned in lecture 5, it would be too much work to checker whether a pixel is inside or outside the triangle. For example, if our triangle were covering just one pixel, it would be pretty big waste of time to check all pixels on the screen. Fortunately, there are more efficient approaches to do just this. The idea of using a bounding box to enclose the triangle and test pixels in the box is a good idea (though it is still slow, since there are a number of pixels within the box that are not contained in the triangle).

@Doris: Here's the link to lecture 5, slide 30 referred to by uhhh.