Glass Bubble
By Maya Lei→I updated the ray tracer to include refraction calculations, along with the already implemented reflection calculations. This can be seen in the rendered piece as the hollow glass sphere/bubble, which refracts light; that is, objects behind it are visible and slightly deformed as light bends through the sphere.
This involved the following changes to the code:
- Including a transparency constant (kt) and index of refraction (ior) in the Material struct.
- Including a refract function to calculate the transmitted direction of light rays in accordance with Snell’s law (angles of transmitted light) and Fresnel equations (intensity).
- Updating the Blinn Phong shading function to distinguish glass materials and opaque materials so glass objects don’t cast shadows (i.e., they don’t block light).
- Updating the raycolor function to incorporate the new refract function alongside the reflect function so light can be reflected and refracted for different material objects.
Acknowledgements
Code references
https://stackoverflow.com/questions/26087106/refraction-in-raytracing
