Giter Club home page Giter Club logo

monte-carlo-path-tracing's Introduction

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

banner

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

A RayTracer, accelerated by C++ multithreading or CUDA.

1 CPU vs. CUDA

  • CPU : AMD Ryzen 7 6800H with Radeon Graphics
  • GPU : NVIDIA GeForce RTX 3060 Laptop GPU
  • Config : cornell-box
CPU CUDA
耗时 1 min 49 sec 330 ms 55 sec 58 ms
绘制结果 result_cpu result_cuda

2 当前项目(Main)实现的功能

2.1 积分器(Integrators)

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

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

2.3 其它

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

Following features are available only in archived project.

3.1 积分器(Integrators)

3.2 参与介质(Participating Media)

4 Usage and Dependencies

4.1 Dependencies

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

necessary :

if enable real-time viewer:

4.2 CMake Option

  • ENABLE_CUDA : Specifies whether or not enable GPU-accelerated computing.
    • compile as C++ project and donnot need CUDA SDK if disable.
  • ENABLE_VIEWER : Specifies whether or not enable real-time viewer.
    • no effect if disable GPU-accelerated computing.

4.3 Usage

Command Format: [--cpu/--gpu/--preview] [--bvh 'bvh type'] [--input 'config path'] [--output 'file path]

Program Option:

  • --cpu: use CPU for offline rendering. if not specify specify CPU/CUDA/preview, use CPU.
  • --gpu: use CUDA for offline rendering, no effect if disbale CUDA when compiling. if not specify specify CPU/CUDA/preview, use CPU.
  • --preview: use CUDA for real-time rendering, no effect if disbale CUDA when compiling. if not specify specify CPU/CUDA/preview, use CPU.
  • --bvh: bvh type for ray tracing, available: [linear, normal], default: 'linear'.
  • --input: read config from mitsuba format xml file, load default config if empty, default: empty.
  • --output: output path for rendering result, only PNG format, default: 'result.png'.
    • press 's' key to save when real-time previewing.

5 References

6 Gallery

Results from 'develop' branch.

  • conductor conductor
  • rough conductor, without energy compensation rough conductor, without energy compensation
  • isotropic rough conductor, without energy compensation isotropic rough conductor, without energy compensation
  • dielectric dielectric
  • rough dielectric, without energy compensation rough dielectric, without energy compensation
  • isotropic rough dielectric, without energy compensation isotropic rough dielectric, without energy compensation
  • thin dielectric thin dielectric
  • plastic plastic
  • rough plastic rough plastic
  • lte-orb, rough glass, without energy compensation lte-orb, rough glass, without energy compensation
  • lte-orb, silver, without energy compensation lte-orb, silver, without energy compensation
  • box box
  • dragon dragon
  • classroom classroom
  • dining room dining room

monte-carlo-path-tracing's People

Contributors

zhiwei-c avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.