600.357/600.457 Assignment 3
Handed out: Oct 31
Due: Nov 19, 4:00pm. -- EXTENDED TO NOV 21, 4pm
457 students,
turn in your assignment here
357 students,
turn in your assignment here
As usual, a Makefile/project file, documented source and a README file must be included.
Note: 20% of your grade will be depend on the design, readability and
documentation of your program.
We will push regular OpenGL further away. Implement clipping and rasterization outside
of OpenGL. Use a Z-buffer to determine visibility. You will now produce the final image
and simply send your image to the window. One way to do this is via OpenGL's
glDrawPixels Call. Implement:
- gllViewPort (This tells you the window size)
- gllBegin{GL_TRIANGLES}
- gllEnd (This is where the real rasterization will occur. You may also finish the rasterization of a triangle as soon as you get the third vertex.)
- gllNormal3f (Just store the normal when specified -- to be used for lighting)
- gllVertex3f (Transform and Store it until the triangle is fully specified)
- gllShadeModel(Smooth or Flat? --
for smooth use interpolation, for flat the whole triangle gets the last vertex's color)
- gllFinish (This is where the application tells the library to put the
memory frame-buffer on screen.)
In addition implement default transparency. Assume GL_BLEND is always enabled
and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) is set.
Color now has four components and all four must be computed --
use the fourth component, alpha, to encode transparency.
Note that we do not need gllSetMatrix any more.
457 students are required to implement anti-aliasing. Add an extra function:
gllAntiAliasMode(float baseSize, int filter[], int filterSize)
The function takes the size, in pixel-units, of the filter, i.e., the
filter footprint. It also expects that actual filter table which will
be used for filtering (weighted averaging) the image. In other words,
The image will have to be super-sampled (in both X and Y dimensions) by
filterSize/baseSize.
For your testing pleasure, some functions are shown below (these work well
with a supersampling of 4x4 (i.e, baseSize = 2).
| Box Filter | Bartlett Filter | Gaussian Filter |
| 1 1 1 1 1 1 1
| | 1 1 1 1 1 1 1
| | 1 1 1 1 1 1 1
| | 1 1 1 1 1 1 1
| | 1 1 1 1 1 1 1
| | 1 1 1 1 1 1 1
| | 1 1 1 1 1 1 1
| |
| 1 | 2 | 3 | 4 | 3 | 2 | 1 |
| 2 | 4 | 6 | 8 | 6 | 4 | 2 |
| 3 | 6 | 9 | 12 | 9 | 6 | 3 |
| 4 | 8 | 12 | 16 | 12 | 8 | 4 |
| 3 | 6 | 9 | 12 | 9 | 6 | 3 |
| 2 | 4 | 6 | 8 | 6 | 4 | 2 |
| 1 | 2 | 3 | 4 | 3 | 2 | 1 |
|
| 1 | 4 | 8 | 10 | 8 | 4 | 1 |
| 4 | 12 | 25 | 29 | 25 | 12 | 4 |
| 8 | 25 | 49 | 58 | 49 | 25 | 8 |
| 10 | 9 | 58 | 67 | 58 | 29 | 10 |
| 8 | 25 | 49 | 58 | 49 | 25 | 8 |
| 4 | 12 | 25 | 29 | 25 | 12 | 4 |
| 1 | 4 | 8 | 10 | 8 | 4 | 1 |
|
To test the effectiveness of your algorithm, you can increase the window
size (or save the image in a file and increase the window size in a
thirdparty viewer). See if the jaggies get blurred.
Hints
Note that it is the responsibility of the application program to specify the transparent polygons
after all polygons behind them (back to front order).
We can reuse the tester and header.
If you do not want to use your implementation of the transformations, do the following:
#define GLXFORM
Get matrices from GL and use gluProject to obtain screen space vertex positions
Implement gllColor. Use it to directly assign vertex colors to be interpolated.
-- The URL of this page is: http://www.cs.jhu.edu/~subodh/457/asn3.html --