Show version

Version created by Christopher Peters 2015-09-11 15:03

Show < previous | next >
Compare < previous | next >

Lab hints and tips

Methodology

1) Do selective unit testing. Don't implement a lot of code and then expect it to work. Divide and conquer: if a computer can do it, why can't you?

2) Use a pen and paper to solve problem subsets first. Mathematics programming is more than maths and programming combined. You are trying to solve both issues at once when you move directly to the computer. First solve and understand the math using pen and paper. Then solve the programming issues.

3) Be critical of instructions. Usually, they are inaccurate. A symptom of not doing step 2), implementing equations without trying to understand them first is a good recipe for many hours of wasted time

Lab setup

Arguably one of the most difficult aspects of the labs is getting your programming environment up and running with the skeleton code. The large number of various operating systems, development environments and versions make it difficult to provide a single solution. The following details may therefore be helpful for setting the labs up on your particular configuration:

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 2013. Note that in order to easily enable cout output to the console, you may need 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)
make

General hints and tips

Lab 3


There are some misprints in the Lab 3 documentation (not difficult to spot, hopefully...):

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.

Hints:
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.

Feedback News