You are on page 1of 2

Rasterization is the technique of taking an image described in a vector graphics format and transform it

into a set of pixels for output on a screen. Through this technique you can be able to draw vector images.
To realize this operation have must to activate the display pixels with specific colors to draw the image
requested. The image below will to explain better how work the screen rasterization.

the function destined to execute the point rasterization.

void putPixel(int xWidth, int yHeight, std::vector<int>& myRGBA)

for (size_t i = 0; i < 4; i++)

FBptr[xWidth*4+i + yHeight*4*IMAGE_WIDTH] = myRGBA.at(i);

The function above describes:

1. xWidth is the position of the pixel related the screen width.

2. yHeight is the position of the pixel related the screen height.

3.myRGBA is the color vector related the pixel.

you create an image by looping over all pixels in the image, tracing a ray for each one of these pixels, and
then finding out if these rays intersect any of the objects in the scene. In other words, the algorithm
requires two main loops. The outer loop, iterates over the pixel in the image and the inner loop iterates
over the objects in the scene:

for (each pixel in image) {

Ray R = computeRayPassingThroughPixel(x,y);

float tclosest = INFINITY;

Triangle triangleClosest = NULL;

for (each triangle in scene) {

float thit;
if (intersect(R, object, thit)) {

if (thit < closest) {

triangleClosest = triangle;

if (triangleClosest) {

imageAtPixel(x,y) = triangleColorAtHitPoint(triangle, tclosest);

Note that in this example, the objects are actually considered to be made of triangles (and triangles
only). Rather than iterating other the objects, we just consider the objects as a pool of triangles and
iterate other the triangles instead.

You might also like