ElisaLegnani / PhotorealisticRendering

A simple raytracer for generating photorealistic images written in C++
https://elisalegnani.github.io/PhotorealisticRendering/
GNU General Public License v3.0
3 stars 0 forks source link

Fix issue #25: fix sphere rendering #26

Closed ElisaLegnani closed 3 years ago

ElisaLegnani commented 3 years ago

This PR is meant to fix issue #25.

ElisaLegnani commented 3 years ago

Here some tests with diffusive sphere (0.5, 0.5, 0.5) and emittive background (0, 0, 1) and ground (1, 0, 0), with antialiasing applied (number of samples per pixel = 4), to better see the effect.

There must be an approximation problem when calculating the ray intersection with the sphere close to the equatorial line.

ElisaLegnani commented 3 years ago

The issue appears only when scaling the sphere along the x direction! Note: the previuos images where obtained by scaling the sphere along all directions.


scaling along x (0.6)


scaling along y (0.6)


scaling along z (0.6)


no scaling

ElisaLegnani commented 3 years ago

It has nothing to do neither with scaling nor with spheres! Normals of the world's light rays - shapes intersections are not normalized, and they need to be for diffusive BRDF ray scattering.

ElisaLegnani commented 3 years ago

Bug fixed!


scaling along x (0.6)

ElisaLegnani commented 3 years ago

A control on normalization of vectors/normals for ONB creation could be useful!

adelezaini commented 3 years ago

That is a great idea! So anyone who wants to enhance or play with the code is advised if the ONB creation doesn't work as it should.