Difference between revisions of "Project3SP15"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
Line 13: Line 13:
 
We provide [[rasterizer.cpp|base code]] for you which displays a software frame buffer on the screen. Your task is to rasterize your scene into this frame buffer. In this assignment you are not allowed to use any OpenGL calls which aren't already in the base code. Instead, use your vector and matrix classes from assignment #1 and add your own rasterization routines.
 
We provide [[rasterizer.cpp|base code]] for you which displays a software frame buffer on the screen. Your task is to rasterize your scene into this frame buffer. In this assignment you are not allowed to use any OpenGL calls which aren't already in the base code. Instead, use your vector and matrix classes from assignment #1 and add your own rasterization routines.
  
<!--
+
==1. Rendering vertices==
==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-proj3.cpp|house geometry]] from homework assignment 2 as your geometry.
+
In the first step of building your own rasterizer you need to project the vertices of the 3D models from assignment 2 to the correct locations in the output image (frame buffer).
  
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 (<tt>window_width</tt> and <tt>window_height</tt>) and call it from the <tt>reshape</tt> 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. (<b>5 points</b>)
+
You should use the same model, camera and projection matrices as in assignment 2, so that you can use the rendering results from it to verify that your software rasterizer works correctly. We recommend that you start with your code from assignment 2 and copy-paste code from rasterizer.cpp where you need it. Support the 'e' key to switch between your rendering engines, OpenGL from the previous assignment and your new software rasterizer.
  
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>)
+
Add a viewport matrix (D) to your code, and implement a method to create D based on the window size (<tt>window_width</tt> and <tt>window_height</tt>) and call it from the <tt>GLUT reshape</tt> function. Your program must correctly adjust projection and viewport matrix, as well as frame buffer size when the user changes the window size, just like in your previous assignment.
  
To make sure 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 the image. (<b>10 points</b>) As a reminder, here are the values again:
+
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 3D model. 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>.
 
+
* Aspect ratio: window dependent (<tt>window_width</tt>/<tt>window_height</tt>)
+
* Vertical field of view: 60 degrees
+
* Near, far clip planes: 1, 100
+
* Center of projection: -10, 40, 40
+
* Look at point: -5, 0, 0
+
* Up vector 0, 1, 0
+
  
 +
<!--
 
==2. Rasterization and z-buffering==
 
==2. Rasterization and z-buffering==
  

Revision as of 08:34, 11 April 2015

Contents

Project 3: Software Rasterizer

In this project you will need to write your own software rasterizer. We provide some code that will allow you to integrate your rasterizer with OpenGL.

The project is due on Friday, April 17th, 2015 at 1pm. You need to present your results in the CSE basement labs as usual, grading starts at 12:15pm.

The homework discussion for this project will be on Monday, April 13th.

0. Getting started

Base Code

We provide base code for you which displays a software frame buffer on the screen. Your task is to rasterize your scene into this frame buffer. In this assignment you are not allowed to use any OpenGL calls which aren't already in the base code. Instead, use your vector and matrix classes from assignment #1 and add your own rasterization routines.

1. Rendering vertices

In the first step of building your own rasterizer you need to project the vertices of the 3D models from assignment 2 to the correct locations in the output image (frame buffer).

You should use the same model, camera and projection matrices as in assignment 2, so that you can use the rendering results from it to verify that your software rasterizer works correctly. We recommend that you start with your code from assignment 2 and copy-paste code from rasterizer.cpp where you need it. Support the 'e' key to switch between your rendering engines, OpenGL from the previous assignment and your new software rasterizer.

Add a viewport matrix (D) to your code, and implement a method to create D based on the window size (window_width and window_height) and call it from the GLUT reshape function. Your program must correctly adjust projection and viewport matrix, as well as frame buffer size when the user changes the window size, just like in your previous assignment.

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 3D model. 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.