Difference between revisions of "Project3Fall13"
(→Project 3: Rasterization) |
(→Project 3: Rasterization) |
||
Line 1: | Line 1: | ||
=Project 3: Rasterization= | =Project 3: Rasterization= | ||
− | In this project you will need to implement your own software rasterizer. We provide a code template for the interface between your software rasterizer and OpenGL. | + | In this project you will need to implement your own software rasterizer. This means that you are going to implement the entire graphics pipeline from 3D vertices to filled triangles in a software frame buffer yourself. We provide a code template for the interface between your software rasterizer and OpenGL, which is needed to display the frame buffer on the screen. |
This assignment is due Friday, October 18th. It will be discussed by TA Matteo on Monday, October 14th at 3pm in Center Hall 105. | This assignment is due Friday, October 18th. It will be discussed by TA Matteo on Monday, October 14th at 3pm in Center Hall 105. | ||
Line 9: | Line 9: | ||
We provide [[rasterizer.cpp | a code template]] for you which displays a software frame buffer on the screen. Your task is to rasterize your scene (described below) into this frame buffer. Throughout this assignment <b>do not use any OpenGL routines which aren't already in the base code!</b> Instead, use <b>your own</b> vector and matrix classes from assignment #1 and add your own rasterization code. | We provide [[rasterizer.cpp | a code template]] for you which displays a software frame buffer on the screen. Your task is to rasterize your scene (described below) into this frame buffer. Throughout this assignment <b>do not use any OpenGL routines which aren't already in the base code!</b> Instead, use <b>your own</b> vector and matrix classes from assignment #1 and add your own rasterization code. | ||
− | + | ==1. Rendering Vertices (30 points)== | |
− | + | ||
− | ==1. Rendering | + | |
The goal of the first step towards building your software rasterizer is to project vertices of given geometry to the correct locations in the output image (frame buffer). Use the [[house-proj3.cpp|house geometry]] from homework assignment 2 as your geometry. | The goal of the first step towards building your software rasterizer is to project vertices of given geometry to the correct locations in the output image (frame buffer). Use the [[house-proj3.cpp|house geometry]] from homework assignment 2 as your geometry. | ||
Line 19: | Line 17: | ||
Then write a method to rasterize a vertex. You can use <tt>drawPoint</tt> from the base code to set the values in the frame buffer. Call this method from the draw callback (<tt>display</tt> function in base code) for every vertex in the sample scene. For this part of the assignment, create a method <tt>rasterizeVertex</tt> which projects each vertex of the house to image coordinates and sets the color of the corresponding pixel to white using <tt>drawPoint</tt>. (<b>15 points</b>) | Then write a method to rasterize a vertex. You can use <tt>drawPoint</tt> from the base code to set the values in the frame buffer. Call this method from the draw callback (<tt>display</tt> function in base code) for every vertex in the sample scene. For this part of the assignment, create a method <tt>rasterizeVertex</tt> which projects each vertex of the house to image coordinates and sets the color of the corresponding pixel to white using <tt>drawPoint</tt>. (<b>15 points</b>) | ||
− | To | + | To verify that your implementation is correct, use the same values for camera and projection matrix as in Image 2 of Exercise 1c of homework assignment 2, and compare the result of your rasterized vertices to that image. (<b>10 points</b>) |
− | + | <!-- | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ==2. Rendering Triangles== | |
− | + | Next you will need to implement a triangle rasterizer based on barycentric coordinates as discussed in class. The rasterizer should first compute a bounding box around the triangle, limited to the extent of the triangle. It then needs to step through all pixels of the bounding box and test if they lie within the triangle by computing their barycentric coordinates. | |
− | + | Fill the triangles using linear interpolation of colors using barycentric coordinates, as discussed in class. Implement a z-buffer data structure to resolve visibility when rendering multiple triangles. For z-buffering, you should linearly interpolate z/w and scale it from [0,1] and use it as the value in the z-buffer. | |
− | |||
− | |||
− | + | Use the same camera and projection matrices as in exercise 1. Scores: correct depth display (using z-buffer): <b>15 points</b>; correct linear color interpolation: <b>15 points</b>. | |
− | === | + | ===a) Two-level hierarchy (<b>20 points</b>)=== |
Extend your rasterizer by adding a two-level hierarchy as discussed in class: The main idea is to split each projected triangle's bounding box into <b>n*n</b> smaller tiles of equal size. Before testing each pixel within a tile, the rasterizer determines if the triangle overlaps with the tile. The whole tile can be skipped if this is not the case. Use the house geometry from exercise 1, not the colorful house. (<b>10 points</b>) To demonstrate how the algorithm works, outline the tile boundaries of one triangle in the frame buffer in red. (<b>5 points</b>) | Extend your rasterizer by adding a two-level hierarchy as discussed in class: The main idea is to split each projected triangle's bounding box into <b>n*n</b> smaller tiles of equal size. Before testing each pixel within a tile, the rasterizer determines if the triangle overlaps with the tile. The whole tile can be skipped if this is not the case. Use the house geometry from exercise 1, not the colorful house. (<b>10 points</b>) To demonstrate how the algorithm works, outline the tile boundaries of one triangle in the frame buffer in red. (<b>5 points</b>) |
Revision as of 11:13, 12 October 2013
Project 3: Rasterization
In this project you will need to implement your own software rasterizer. This means that you are going to implement the entire graphics pipeline from 3D vertices to filled triangles in a software frame buffer yourself. We provide a code template for the interface between your software rasterizer and OpenGL, which is needed to display the frame buffer on the screen.
This assignment is due Friday, October 18th. It will be discussed by TA Matteo on Monday, October 14th at 3pm in Center Hall 105.
This assignment is currently under construction. Feel free to start working on it, but it won't be finalized until early afternoon on Oct 12th when this message will have disappeared.
We provide a code template for you which displays a software frame buffer on the screen. Your task is to rasterize your scene (described below) into this frame buffer. Throughout this assignment do not use any OpenGL routines which aren't already in the base code! Instead, use your own vector and matrix classes from assignment #1 and add your own rasterization code.
1. Rendering Vertices (30 points)
The goal of the first step towards building your software rasterizer is to project vertices of given geometry to the correct locations in the output image (frame buffer). Use the house geometry from homework assignment 2 as your geometry.
You can re-use your model (M), camera (C), and projection (P) matrices from the previous assignment. Add a viewport matrix (D). Implement a method to set the viewport matrix based on the window size (window_width and window_height) and call it from the reshape function. Your program must correctly adjust projection and viewport matrix, as well as frame buffer size when the user changes the window size. Correctly means that the house needs to remain centered in the window and get uniformly scaled to match the window size. (5 points)
Then write a method to rasterize a vertex. You can use drawPoint from the base code to set the values in the frame buffer. Call this method from the draw callback (display function in base code) for every vertex in the sample scene. For this part of the assignment, create a method rasterizeVertex which projects each vertex of the house to image coordinates and sets the color of the corresponding pixel to white using drawPoint. (15 points)
To verify that your implementation is correct, use the same values for camera and projection matrix as in Image 2 of Exercise 1c of homework assignment 2, and compare the result of your rasterized vertices to that image. (10 points)