一个路径追踪小程序,利用了 CPU 多线程或 CUDA 加速计算。项目最初参考了《GAMES101: 现代计算机图形学入门》的作业7,有大幅度的调整。
学习笔记保存于知乎专栏。
A simple Monte Carlo path tracer based on assignment 7 of GAMES101 originally, accelerated by C++ multithreading or CUDA.
- 基于路径追踪(path tracing)算法的绘制方程定积分迭代求解方法,包括:
- 使用蒙特卡洛方法(Monte Carlo method)计算辐射亮度(radiance)的数学期望;
- 重要性抽样(importance sampling),给定光线入射方向和表面法线方向,根据 BSDF 对光线出射方向进行重要性抽样;
- 多重重要性抽样(multiple importance sampling):
- 按发光物体表面积直接采样光源;
- 按 BSDF 采样光源;
- 俄罗斯轮盘赌算法(Russian roulette)控制路径追踪深度;
- 微表面模型(microfacet model)定义的电介质(dielectric)材质,模仿 mitsuba 相应的材质;
- example:
- 薄电介质(thin dielectric)材质,模仿 mitsuba 相应的材质;
- example: thin Dielectric
- example: thin Dielectric
- 微表面模型(microfacet model)定义的导体(conductor)材质,模仿 mitsuba 相应的材质;
- 塑料(plastic)材质,模仿 mitsuba 相应的材质;
- example:
- 朗伯模型(Lambert's model)定义的平滑漫反射(smooth diffuse)材质;
- example: Dragon
- example: Dragon
- Oren–Nayar 反射模型(Oren–Nayar reflectance model)定义的粗糙漫反射(rough diffuse)材质;
- 各向同性相函数(Isotropic Phase Function)描述的参与介质,模仿 mitsuba 相应的材质;
- example: volumetric-caustic
- example: volumetric-caustic
- 亨尼-格林斯坦相函数(Henyey-Greenstein Phase Function)描述的参与介质,模仿 mitsuba 相应的材质;
- 使用 Kulla 和 Conty 提出的方法,尝试补上微表面模型没有建模的,微表面之间的多重散射;
- 环境映射(environment mapping)
- 凹凸映射(bump mapping)
Following features are only available in archived
version.
项目使用 vcpkg 进行 C++ 库管理。
automatically import from extern
folder:
ENABLE_WATERTIGHT_TRIANGLES
: Specifies whether or not enable Woop's watertight ray/triangle intersection algorithm.ENABLE_CUDA
: Specifies whether or not enable GPU-accelerated computing.- compile as C++ project and donnot need CUDA SDK if disable.
ENABLE_CUDA_DEBUG
: Specifies whether or not GPU debugging information is generated by the CUDA compiler- no effect if disable GPU-accelerated computing.
ENABLE_VIEWER
: Specifies whether or not enable real-time viewer.- no effect if disable GPU-accelerated computing.
Command Format: [-c/--cpu/-g/--gpu/-p/--preview] --input/-i 'config path' [--output/-o 'file path] [--width/-w 'value'] [--height/-h 'value'] [--spp/-s 'value']
Program Option:
--cpu
or-c
: use CPU for offline rendering.- if not specify specify CPU/CUDA/preview, use CPU.
--gpu
or-g
: use CUDA for offline rendering,- no effect if disbale CUDA when compiling.
- if not specify specify CPU/CUDA/preview, use CPU.
--preview
or-p
: use CUDA for real-time rendering,- no effect if disbale CUDA when compiling.
- if not specify specify CPU/CUDA/preview, use CPU.
--input
or-i
: read config from mitsuba format xml file.--output
or-o
: output path for rendering result.- only PNG format, default: 'result.png'.
- press 's' key to save when real-time previewing.
--width
or-w
: specify the width of rendering picture.--height
or-h
: specify the height of rendering picture.--spp
or-s
: specify the number of samples per pixel.