[Cg1] Error in Assignment 5.4

Julius Wolfgang Stephan Kilger s9jukilg at stud.uni-saarland.de
Thu Dec 1 15:04:51 CET 2016


Hello,

While solving the current assignment we found a possible bug in the  
reference-implementation of Ass. 5.4.
The spotlight class is likely missing a normalization of the direction  
vector, resulting in the green spotlight
to behave normal, since the Vector (0.0f, -1.0f, 0.0f) has already a  
length of 1. The red spotlight however
appears brighter than it should and the angle appears to wide.

This is due to the cosine computation, and the intensity computation.  
(both are off by a factor of sqrt(2), wich is the length of (-1.0f,  
-1.0f, 0.0f))
Out tutor confirmed this was a bug in the past which probably crept  
back into the reference implementation this year.

So, to reproduce the reference image, you have to NOT normalize the  
direction vector of the spotlight,
resulting in incorrect distance (and thus intensity) and angle computations.
To fix this error, all that is needed is normalizing the direction of  
the spotlight.
You will not get the reference image this way, but it still is the  
correct code.

Out tutor told us that both versions are acceptable solutions due to  
the error in the reference image,
but the last word in what is the correct solution lies with the tutors.
We hope this tip helps you cut down on debugging time for a bug that  
is not yours ;)

Regards,

Kristina & Julius

PS.:
attached you will find the image we get when running the code we think  
is correct. Keep in mind though that this is no official reference  
image.
Good luck with the current assignment.
https://www.dropbox.com/s/2tsnfxc4fgd5yh3/a4-3.png?dl=0

PPS.:
I tried to send this mail earlier, but the mailing list blocks large  
e-mails, so now I included a dropboxlink to our image file, instead of  
an attachment.



More information about the Cg1 mailing list