Skip to content

Magro28/javaRayTracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

javaRayTracer

In this project I coded a little ray tracer in good old plain Java. Is it fast? God no. Java is really not the best language for a resource hungry raytracer but I just wanted to refresh my Java skills a bit and learn about raytracing. Can it be optimized? Yes of course, especially multithreading or using a GPU should bring a lot of performance but this is for another time.
Final Rendering!
The final rendering of the picture above (600x400 pixels) with 50 samples by pixel antialiasing took 8 minutes. Double the size took already almost 1 hour.
If you like to render your own image check out the WorldGenerator class which I used for the scene building.

Dependencies

Only apache.commons.math3 for the Vector3D class. Was too lazy to code all the vector math myself. 😅

Features

Objects

It only supports spheres for now

Antialising

Antialising is implemented and can be adjusted by samples per pixel.
Antialising!

Diffuse materials

Diffuse materials are supported which modulate light with their own base color. It reflects child rays of light in random directions with the true lambertian reflection method.
Diffuse Material!

Metal materials

Metal materials are implemented with a new scattered reflection method. Their fuzziness can be parameterized.
Metal Material!

Dielectric materials

Dielectric materials represent things like glass, water or crystals. When they are hit by light, the ray is randomly splitted into a reflected or a refracted ray. The refraction is implemented in a method which describes Snell's Law. Reflectance is calculated by Schlicks approaximation.
Dielectric Material!

Positional camera

The camera is positional with standard look-from, look-at and up parameters and can be adjusted with field of view and zooming. With aperture and distToFocus settings you can control the depth of field.
Positional Camera!

Reference

As a reference I used this nice book about raytracing: https://raytracing.github.io/books/RayTracingInOneWeekend.html

About

A small raytracer implemented in Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages