I am currently implementing a ray tracer, which supports reflection and refraction. I have the following types of rays:
- camera rays
- shadow rays
- reflection rays
- refraction rays
I have the following types of materials:
- diffuse (opaque, do not reflect)
- purely reflective (opaque, but can reflect)
- reflective and refractive (semi-transparent objects such as bodies of water, which can reflect part of the light ray and refract the rest).
For which combinations of ray type and material type of object being hit should I perform backface culling, when determining the hit point of a ray on a triangle?
EDIT: From what I stated above, it might seem like my renderer is physically accurate, but it really isn't all that much. Here are some implementation details I failed to mention:
- I calculate the surface and vertex normals in runtime, when parsing the scene. I don't read them from the scene.
- By
backface culling
, I implied the check if the dot product of the incident ray and the surface normal is greater than or equal to zero. Right now, as long as it's not a shadow ray and the dot product is greater than or equal to zero, I return that there is no intersection. - The different types of rays are used mainly for debugging purposes so far. The shadow rays are an exception and I use them as stated in the previous point.
- the non-reflective diffuse material is used to represent a material, which absorbs light. When a ray intersects an object of such a material, I calculate the contribution of each light.
- the reflective material causes the incident ray to be reflected. The final color is the color, returned by the reflected ray, multiplied by the albedo of the reflective material, in order to avoid total reflection (perfectly mirrored surface).
- the refractive material causes either a reflection ray, or a reflection and a refraction ray to be traced (based on Snell's law) and the final color is calculated using the
fresnel
formula.