Lab hints and tips
Arguably one of the most difficult aspects of the labs is getting your programming environment up and running with the skeleton code. The following details may therefore be helpful:
Windows and Microsoft Visual Studio
A useful guide can be found here by previous DH2323 student Victor Dahlin on conducting a setup in Microsoft Visual Studio. Note that in order to enable cout output to the console, you may decide to set the project to be a console application in the properties menu.
MacOS (with XCode)
A useful guide by previous DH2323 student Andreas Kramer can be found here.
MacOS (without XCode)
Previous DH2323 student Mikael Hedin recommends the following:
Install fink (http://www.finkproject.org/)
fink install sdl
Include in your Makefile: CXXFLAGS=$(shell sdl-config --libs) $(shell sdl-config --cflags)
General hints and tips
There are some misprints in the Lab 3 documentation (the hopefully, you found easy to spot!):
1. Eqn. (3) and (4) on page 2 should refer to W/2 instead of W2 and H/2 instead of H2, respectively.
2. In section 5 on page 11, it repeatedly mentions the inverse "1=z" - it should be "1/z"
3. On page 14, the reflectance element of the Vertex struct should be represented a vec3 and not vec2 as printed.
Issues with triangle borders (or gaps) being drawn may relate to missing out the drawing of pixels in one of the loops related to triangle filling operations. Check the starting and finishing conditions of those loops.
On page 14, the Light power of 1.1f * vec3(1,1,1) is not enough to give clear illumination. Try the value from the previous lab of 14.1f * vec3(1,1,1), especially if you are not getting good results for the illumination questions at the end of the lab.
Per vertex illumination is implemented in the vertex shader using eq. 10 and 11. The normal vectors of vertices are identical to those of triangles in this scene.
Per pixel illumination involves 3D position stored in the pixel structure. Do not interpolate the original 3D positions linearly, interpolate the transformed position (which is multiplied by inverse z value).
Be careful of the following:
Accidentally converting floats to integers: Make sure your floats are being evaluated as such, and not being converted to integers. E.g. be careful of using "zinv = 1/vtx.z" instead of the correct "zinv = 1.0f/vtx.z"
If you are having segmentation fauls, you need to implement some form of bounds checking i.e. if it is possible for a vertex of a triangle be placed outside of the view, it would access the depth buffer out of bounds resulting in a segmentation fault.