top of page
Search

Week 4: Reflections

  • Writer: Karinne Lorig
    Karinne Lorig
  • Jun 13, 2019
  • 2 min read

Continuing on from last week, my goal for this week was to add multi-sphere support and reflections. After an initial false start with CreateNewMeshInstances, I was able to switch from using Falcor's ModelRenderer to a SceneRenderer, which can render multiple model instances from inside of a scene object.


Supporting that in the Ray Tracer required the creation of a sphere class to simplify keeping track of these models and their characteristics. The sphere class took and expanded upon the hit detection function the RayTracer used to have so it also returned the normal, hit location, and distance from the where the ray was fired, while also encapsulating data about the spheres themselves. The RayTracer, for its part, gained a vector of spheres and a function to add a new one whenever I added a new model instance to the scene

Two spheres rendered by the sphere class

With that done, it was time to move on to reflections. I wanted a system that was more flexible than an object simply being reflective or not. To that end, I used three parameters to control how, if at all, reflections were calculated:

Reflectivity is a percentage of how much color an object takes from its surroundings. An object with a reflectivity of 0 will not consider the objects around it at all, while one with a reflectivity of 1 will use only the colors of things around it.

Diffuseness determines where the reflections are calculated from. An object with 0 diffuseness bounces rays by reflecting the ray that hit it, while an object with 1 diffuseness will use the sphere's normal instead.

Fuzziness determines how much randomness there is in the rays that bounce off the object. The lower the number, the less randomness.

With this set up, I was able to get images like this:

The bottom sphere has a much higher fuzziness than the top one.


Comments


© 2018 by Karinne Lorig

bottom of page