Skip to content

Ray Tracing for Sensor Simulation using Parallel Functional Programming

License

Notifications You must be signed in to change notification settings

bryal/msc-futhark-ray-tracer

Repository files navigation

Sensor simulator ray-tracer

A spectral path tracer (Monte Carlo integration, physically based, multiple importance sampling) that can simulate both vision and LIDAR, implemented in the GPGPU purely functional array programming language Futhark.

prism-dispersion.png

Dependencies

Regardless of platform, you need to install both Futhark and Rust (and a C compiler). Futhatk is used for the main implementation, and all code that runs on the GPU, while Rust and C are used for some host-side code, like loading object files and showing an SDL2 window.

SDL2

On Linux, statically compiled SDL2 is included in ./deps/SDL2/.

On Windows you’ll have to install SDL2 yourself. Using MSYS2 (mingw) is recommended (yay pacman!). You may have to update your environment variables so that the linker can find the installed libraries.

OpenCL

You’ll need both the libraries and headers for compilation, and drivers with support at runtime.

On Linux, simply install the appropriate package (something like “opencl-dev”) to get the development library. Depending on your distribution and hardware, your drivers may be OpenCL ready out of the box. Otherwise you must install packages that provide an OpenCL runtime (and an ICD loader?).

On Windows, get an OpenCL SDK (preferably a “light” version) from your GPU vendor – for AMD, you can find it here. With regards to runtime, you should be good to go as long as you’ve installed the normal GPU drivers for your system.

Build

Simply run make. If it doesn’t work, try poking around in the Makefile. You may need to change CC=clang to CC=gcc for example.

Run

On Linux, run with ./main. On Windows, use just main.exe instead.

$ ./main -o assets/CornellBox-Original.obj
Using OpenCL device: Ellesmere
Use -d or -i to change this.
no of triangles: 2188

Controls

For the interactive demo:

w, a, s, d, x, z
Translation.
Arrow keys
Rotation.
1, 2
Increase / decrease resolution.
q, e
Decrease / increase samples per (virtual) pixel.
SPACE
Toggle accumulation.
n, m
Disable / enable accumulation.
i, k
Increase / decrease aperture size.
o, l
Increase / decrease focal distance.
t
Toggle LIDAR sensor.
8, 9, 0
Self-transmitter: flash / scanning / none.
p
Toggle sky.

Attributions

Much of the windowing code in the interactive demo is based on lys, owned by DIKU and licensed under the ISC license (see ./demo-interactive/LYS-LICENSE).

Our LBVH implementation takes a lot of inspiration from the one in here by Athas.

License

This project is released under the AGPL, version 3 or later. See ./LICENSE.

Notice

Copyright (C) 2020 Ari von Nordenskjöld & Johan Johansson

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

About

Ray Tracing for Sensor Simulation using Parallel Functional Programming

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published