|
Post by agabhi on Nov 24, 2021 4:06:52 GMT
Hi, I was working my way onto chapter 8, but my renderer is strangely giving the below image for the last task of chapter 7. Any inputs are highly appreciated! Thanks for such a great book! I am really enjoying it
|
|
|
Post by inventordave on Nov 24, 2021 9:07:33 GMT
Well, if I remember, I can see the normals being produced are off. That's why the shading on the floor is off. The image is fundamentally ok, but there is an error in the normals being generated that represent the vector perpendicular/orthogonal to the surfaces. Approximately, it looks like the normals moving away from the origin (I assume the green sphere is at the world origin) are being erroneously inverted, sort-of. Eureka, I've just thought, are you using the standard local_normal_at for the Shape base class, instead of using the overriding local_normal_at implementations??
|
|
|
Post by agabhi on Nov 24, 2021 15:41:07 GMT
Woah! you caught the bug like a needle in the haystack. I was scratching my head the entire night. Yes the normals were the problem. Apparently, they were not being transformed correctly. I cant thank you enough! But I am curious, what gave you the idea that the normals are off? Thanks!
|
|
|
Post by inventordave on Nov 25, 2021 3:07:41 GMT
2 things: One is the floor should be flat, but it has a curved gradient that I recognised from ages ago when I was building the raytracer. Essentially, the _local_normal_at was producing a normal that essentially curved according to the (u,v) point on a surface. Tell-tale sign a default/base algorithm is producing the normals.
2nd, I broke my raytracer so that normals emanating from any shapes that were translated off the world origin were being inverted (but not when the shape wasn't translated to off-origin) and it made spheres look flat.
|
|
|
Post by agabhi on Nov 25, 2021 8:25:35 GMT
Gotcha! Thanks again
|
|