Skip to content

A simple Monte Carlo path tracer based on assignment 7 of GAMES101 originally, accelerated by C++ multithreading or CUDA.

Notifications You must be signed in to change notification settings

zhiwei-c/Monte-Carlo-Path-Tracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

蒙特卡洛路径追踪(Monte-Carlo-Path-Tracing)

banner

一个路径追踪小程序,利用了 CPU 多线程或 CUDA 加速计算。项目最初参考了《GAMES101: 现代计算机图形学入门》的作业7,有大幅度的调整。

学习笔记保存于知乎专栏

A simple Monte Carlo path tracer based on assignment 7 of GAMES101 originally, accelerated by C++ multithreading or CUDA.

1 Features

1.1 Integrators

  • 基于路径追踪(path tracing)算法的绘制方程定积分迭代求解方法,包括:
    • 使用蒙特卡洛方法(Monte Carlo method)计算辐射亮度(radiance)的数学期望;
    • 重要性抽样(importance sampling),给定光线入射方向和表面法线方向,根据 BSDF 对光线出射方向进行重要性抽样;
    • 多重重要性抽样(multiple importance sampling):
      • 按发光物体表面积直接采样光源;
      • 按 BSDF 采样光源;
    • 俄罗斯轮盘赌算法(Russian roulette)控制路径追踪深度;

1.2 表面散射模型(Surface Scattering Models)

1.3 参与介质(Participating Media)

1.4 其它

1.4.1 历史存档项目(Archived)特有的功能

Following features are only available in archived version.

2 Building & Compiling

2.1 Dependencies

项目使用 vcpkg 进行 C++ 库管理。

automatically import from extern folder:

2.2 CMake Option

  • 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.

2.3 Usage

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.

3 Gallery

cornell box

3.2 Box

box

lte-orb, rough glass

lte-orb, silver

dining room

classroom

4 References

About

A simple Monte Carlo path tracer based on assignment 7 of GAMES101 originally, accelerated by C++ multithreading or CUDA.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published