Home

Awesome

Java Ray Tracer for TornadoVM

Demo

Description

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.

Installation

  1. Clone the project:
git clone https://github.com/Vinhixus/TornadoVM-Ray-Tracer.git
  1. Install dependencies:
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 .

Note that TornadoVM-Ray-Tracer has been tested with JavaFX version 18.

  1. 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
  1. Build TornadoVM-Ray-Tracer:
mvn clean install
  1. Run TornadoVM-Ray-Tracer:

With GUI:

tornadovm-ray-tracer

Without GUI in benchmarking mode:

tornadovm-ray-tracer benchmark

Author

Vinh Pham Van

LinkedIn: vinh-pham-van
Email: phamvvinh1998@gmail.com

With special thanks to:

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

Licenses

License