This ray tracer was built as a course project to explore the fundamentals of physically-based rendering. It implements recursive ray tracing with support for reflections, refraction, and shadows using the classic Phong illumination model. The renderer handles both sphere and polygon primitives, supports point lights and spotlights, and produces images with “realistic” lighting effects including specular highlights and colored reflections.
While many introductory ray tracers only handle opaque surfaces, this implementation includes refraction through transparent materials with proper refractive index calculations and internal reflections. The shadow computation handles translucent objects by accumulating transmission coefficients, allowing light to pass through glass-like surfaces with appropriate attenuation. Materials can be configured with separate coefficients for local lighting, reflection, and transmission, giving control over how surfaces interact with light.
The code is written in pure Java—admittedly not the ideal choice for a computationally intensive ray tracer, but it served as my introduction to the language. The implementation uses an object-oriented design with abstract base classes for geometric objects and a straightforward rendering pipeline: parse scene files, transform everything to camera coordinates, then recursively trace rays through each pixel. The recursive tracing terminates based on both maximum depth and a weight threshold to avoid computing negligible light contributions. It demonstrates the core concepts of ray tracing clearly, even if rendering times are longer than a C++ implementation would be.
You can find the code at https://github.com/faisalqureshi/java-raytracer.