Big Pixel Project

ECS 175
Big Pixel Project
Due 10 PM Wds April 19

Basic Assignment

This project is intended to introduce rasterization, barycentric coordinates, and linear interpolation across triangles.

We will grade the project by trying it on some test inputs. If your program does Steps 1 and 2, below, with no problems on all our test inputs, that will be a B. If you also do Step 3, that will be an A.

Here are some C functions which implement a software framebuffer, consisting of a 50x50 array of pixels. To make the pixels easy to see, they are drawn as little squares (or "big pixels"). To color a pixel, you should call the function colorPixel.

  • bigPix.c
  • lowlevel.c
  • lowlevel.h
  • Makefile

    The code includes a function readInput which can be used to read in triangle vertices from the standard input. To read the file input (in Unix), call the program like this

    bigPix < input

    Please ignore the comment before the readInput function that says "Change this function to read input from a file". I have deleted it.

    Step 1 - Draw triangles

    The basic project is to use the colorPixel function to draw a rasterized version of any triangle. Your output images should consist entirely of big pixels, drawn by calling colorPixel. You can use the outline for triangle drawing in Section 3.6 in the book; barycentric coordinates are covered in Section 2.11, and we used the 2D geometry in Section 2.5.2. The file input1 contains an example of two triangles you ought to be able to display. We will also test it on other triangles, so make up some test inputs of your own and check that it works. What are the difficult "corner cases"?

    Step 2 - Interpolate colors

    Add RGB colors to the vertices in the input file, read them in, and change your code to interpolate the colors across the triangles, using barycentric coordinates. The file input2 contains an example of a colored triangl you should be able to display.

    Step 3 - Texture mapping

    Keeping your current color-interolating program, make a new copy bigPixTex which does texture mapping instead of color interpolation. This way we can check both versions. Change your program bigPixTex to read in an image (you can use the code from last time) and then implement texture mapping. The texture coordinates (s,t) should go from 0.0-1.0, no matter what the size of the image is. So our texture mapping test files will look like input3.

    Your texture-mapped polygons will be so pixelated (because of the big pixels) as to be completely unrecognizable. Decrease the pixel size and increase the number of pixels (for instance, use 250 pixels of size 2x2) so that we can actually see the image.

    Additional Notes

    You may NOT use OpenGL calls which draw polygons to draw the triangle!

    You can convert the code to C++ if you want; the Makefile should work for C++ as well.

    Turning in the project

    Turn in the project using handin. Hand in your source code, a Makefile for the Linux machines in 67 Kemper, an executable that runs on the machines in 67 Kemper, an input image file if you did texture mapping, and a brief README file saying what you implemented. Make sure your name appears on all of the source files and prominently in the text file.

    We will test the program by trying it on a variety of input files, which we will run by typing

    bigPix < input2
    bigPixTex < input3

    so please do not change the name of the executable, or make it read from a file instead of stdin, etc. Thanks!