A tiny path tracer accelerated by OpenMP & CUDA.
- Global illumination rendering with path tracing.
- Parallel rendering with OpenMP (on CPU) and CUDA (on nvidia GPU).
- Complex triangle mesh model from Wavefront OBJ with MTL texture, accelerated by BVH.
- Lambertian, metal, dielectric, and glossy (Cook-Torrance GGX) BxDFs.
- Alpha texture mapping, and bump texture with height map.
- Area light, point light, distant light, and environmental lighting.
Basic Usage
Firstly, clone the repo recursively to your local environment.
git clone --recursive https://github.com/li-plus/tinypt.git && cd tinypt
# or
git clone https://github.com/li-plus/tinypt.git && cd tinypt && git submodule update --init
Install compilation dependencies and download necessary scene resources.
sudo apt install gcc g++ cmake make libeigen3-dev libopencv-dev libgflags-dev libgoogle-glog-dev python3-dev python3-pip
bash resource/get_resource.sh
Build the project.
cmake -B build .
cmake --build build -j
Render an example scene with two spheres in a box, which is taken from smallpt.
./bin/pt -device cuda -num_samples 1000 -save_path scene.png -scene cornell_sphere
Python API
Python binding is also available for TinyPT. To build and install the Python package for development, run:
cd python/
python3 setup.py develop
Run a Python example.
python3 examples/main.py --device cuda --num-samples 1000 --save-path scene.png --scene cornell_sphere
To build the wheel for distribution, run:
python3 setup.py bdist_wheel
Docker
For those who do not have root privilege, we offer an alternative to build & run TinyPT within a docker container. For GPU support, nvidia-docker should be further installed.
cd docker
docker build . -t tinypt:latest --build-arg CUDA=1
bash run.sh tinypt:latest
Following scenes are credited to smallpt and McGuire Computer Graphics Archive.