dilevin / computer-graphics-ray-tracing

Computer Graphics Assignment about Ray Tracing
1 stars 5 forks source link

Everything looks good - except it's too bright. #46

Closed NPTP closed 4 years ago

NPTP commented 4 years ago

Hi, I've got everything looking fairly solid, except every image is just too bright. Here are some examples.

My sphere-packing: image

Solution sphere-packing: image

My bunny: image

Solution bunny: image

As you can see (and it's like this for other images as well), everything looks correct except the overall brightness.

I am not adding the ambient light inside of a loop (only once per call to blinn_phong_shading()). I am scaling ambient by ka and the constant ia=01. I am scaling Lambertian by using kd I max(0, n.dot(l)). I am scaling specular by ks I (max(0, n.dot(h))^p (where p is the phong exponent). The recursive reflections appear to be working correctly and they are being scaled by the km coefficients of the object that was hit.

I'm totally stumped! Any ideas?

Thank you!

darren-moore commented 4 years ago
NPTP commented 4 years ago

Hey Darren, thanks for your feedback. I was rendering mirror.json again on one machine while debugging on another (took a while!) The output showed the mirror being much brighter than the solution image, while the walls/planes looked close to the solution. This lead me to go back to what I'm doing with my reflections, and indeed, I was not properly initializing the rays that get reflected out from a hit, so that the summed values returned from recursive calls would be artificially inflated/brighter. Now after a quick fix, things look great. (I had put that normalization sanity check all over the place though in the process haha)