This project aims to build a real-time ray tracer in Java, accelerated on heterogeneous hardware using TornadoVM.
The project uses JavaFX to obtain a canvas for a graphical context to draw on and to build an interactive graphical user interface, while the entire rendering process consists of manual calculation of the colors of the pixels through tracing rays, applying the Blinn-Phong shading model and sampling soft shadows.
The embarrassingly parallel property of ray tracing allows for concurrent computation of each individual pixel color, achieving up to 930x performance increase on an Nvidia RTX2060 GPU against the default sequential Java execution on an Intel i7-8550u CPU.
- Clone the project:
git clone https://github.com/Vinhixus/TornadoVM-Ray-Tracer.git
- Install dependencies:
- Install TornadoVM. The following example builds TornadoVM with OpenJDK 11 and OpenCL:
git clone https://github.com/beehive-lab/TornadoVM.git
cd TornadoVM
./scripts/tornadoVMInstaller.sh --jdk11 --opencl
source source.sh
cd ..
If you cannot build TornadoVM with the installer, try the manual installation .
- Download the JavaFX SDK for your system from: JavaFX downloads. You will need the path of the JavaFX SDK for Step 3.
Note that TornadoVM-Ray-Tracer has been tested with JavaFX version 18.
- Set up the environment and store the variables in a file (e.g.
sources.env
):
cd TornadoVM-Ray-Tracer
vim sources.env
export TORNADO_RAY_TRACER_ROOT="${PWD}"
export PATH="${PATH}:${TORNADO_RAY_TRACER_ROOT=}/bin"
export JAVAFX_SDK=<path to JavaFX>/javafx-sdk-18/
export TORNADO_ROOT=<path to TornadoVM>
export PATH="${PATH}:${TORNADO_ROOT}/bin/bin/"
export TORNADO_SDK=${TORNADO_ROOT}/bin/sdk
export JAVA_HOME=${TORNADO_ROOT}/TornadoVM-OpenJDK11/jdk-11.0.13+8
Load the environment:
source sources.env
- Build TornadoVM-Ray-Tracer:
mvn clean install
- Run TornadoVM-Ray-Tracer:
With GUI:
tornadovm-ray-tracer
Without GUI in benchmarking mode:
tornadovm-ray-tracer benchmark
LinkedIn: vinh-pham-van
Email: [email protected]
Christos Kotselidis: Supervisor & TornadoVM Project Leader
Juan Fumero: TornadoVM Lead Architect
Thanos Stratikopoulos: TornadoVM Senior Solutions Architect
Maria Xekalaki: TornadoVM Principal Software Engineer
Florin Blanaru: TornadoVM Senior Software Engineer