【笔记】【GAMES202】Real-time Ray Tracing实时光线追踪

Real-time Ray Tracing实时光线追踪

1. Real-time Ray Tracing实时光线追踪

2018年,NVIDIA发布GeForce RTX系列(Turing架构)

RTX在硬件上可以发射10 Giga rays per second(RT core)

但是在实际应用中只能做到 1 sample per pixel。

1SPP path tracing =

  • 1 rasterization(primary) + (实际用光栅化方法来代替第一条光线)
  • 1ray(primary visibility) +
  • 1ray(secondary bounce)+
  • 1ray(secondary visibility)

image-20220531004928902

1SPP存在极大噪声,RTRT关键部分在于==Denoising降噪== 。

Basic idea

image-20220531005843306

工业界的解决方案中最重要的是Temporal滤波

  • 关键思路:
    • 假设当前帧的前一阵是降噪的,因此可以复用。
    • 使用motion vectors来找到前一帧的对应位置。
    • 用上一帧的结果来计算当前帧结果。

image-20220531010312714

Motion Vector

G-Buffers(Geometry buffer)

在渲染过程中,可以获得一些额外的信息,如每像素的深度、法线、世界坐标等。生成G-buffer是比较容易的,只有屏幕空间信息。

Back Projection

image-20220531010731693

image-20220531011038829

x’就是当前帧像素对应的世界坐标位置对应到上一帧该位置所在的像素。

Temporal accumulation/filtering

image-20220531011719293

在这种1spp的结果下,回顾蒙特卡洛路径追踪,它的结果应该是无偏的,之所以看起来暗,是因为有很多的采样点原本的值是非常大的,但在显示器的clamp下,变成了1(255),因此看起来暗了。

image-20220531011848928 image-20220531012013416 image-20220531012109486

Failure cases

Switching scenes(burn-in period)

切换场景、快速的镜头切换

Walking backwards in a hallway(screen space issue)

镜头中的信息是增加的

Suddenly appearing background(disocclusion)

image-20220531012552050

造成拖尾(Lagging)的结果

More Temporal Failure

image-20220531013222285

image-20220531013349160

Adjustments to Temp. Failure

image-20220531012830984

2. Filtering techniques and implementation

Implementation of filtering

  • 图像低通滤波
    • 消除了高频信号
    • 只关注频域(Spatial domain)
  • 图像+滤波器(filter kernel)->输出图像
  • Gaussian filter
    • 对于任何像素取周围范围的贡献,基于像素和周围的距离

image-20220531142014296

  • Bilateral FIltering
    • 背景
      • Gaussian filtering 出现的问题是整体模糊,包括边缘
      • 但是我们希望边界能够保持高频
      • 边界<->理解为颜色剧烈变化的部分
    • 思路
      • 如何保留边界
      • 如果像素j和i相差特别大,就让j对i的贡献减少
      • 只需要控制kernel

image-20220531144557877

image-20221002143754221

问题:如果噪声本来颜色差异就比较大,无法区分这部分噪声和边界。

Cross / Joint bilateral filtering

  • Gaussian filtering以距离作为标准
  • Bilateral filtering用位置距离、颜色距离作为标准
  • 联合双边滤波采用更多的标准
    • G-buffers
      • Normal,depth,position,object ID,etc
    • G-buffers是没有噪声的。
  • 特别适用于路径追踪的降噪
  • Gaussian函数不是唯一的选择,任何随“距离”衰减的函数都可以,如Exponential(absolute),cosine(clamped)

image-20221002145335668

Implementing Large filters

对于Kernel过大的情况

  • Separate Passes
    • 对于2D Gaussian filter
    • 将它分成水平的pass和竖直的pass(N^2 ->N+N)
    • 2D Gaussian filter kernel is separable
    • $G_{2D}(x,y)=G_{1D}(x) \cdot G_{1D}(y)$

image-20220531152145590

理论上双边滤波不能拆分实现。

  • Progressively Growing Size
    • 用逐步增大filter进行多次滤波
    • 为什么要用逐步增大的filter
      • 去除更低的频率
    • 为什么可以跳过一些samples
      • Sampling= repeating the spectrum

image-20220531152445354

image-20220531153055367

Outlier removal(and temporal clamping)

滤波后结果中还是会有一些特别亮的outlier(本来需要等更多的sample)

  • 在滤波前去除outlier
  • Outlier detection
    • 计算像素neighbor的均值和方差

image-20220531154410403

  • Outlier removal

image-20220531154735195

  • Temporal Clamping

image-20220531155436586

3. Specific filtering approaches for RTRT

Spatiotemporal Variance-Guided Filtering(SVGF)

  • similar to the basic spatio-temporal denoising scheme
  • with some additional variance analysis and tricks

image-20221002154314018

  • Joint Bilateral Filtering

  • 3 factors

    • Depth

      • $w_z=\exp(-\frac{|z(p)-z(q)|}{\sigma_z|\nabla z(p)\cdot(p-q)|+\epsilon})$
      • image-20221002154947127
    • Normal

      • $$
        w_n=\max(0,n(p)\cdot n(q))^{\sigma_n}
        $$
    • Luminance(grayscale color value)

      • $$
        w_l=\exp(-\frac{|l_i(p)-l_i(q)|}{\sigma_l\sqrt{g_{3\times3}(Var(l_i(p)))}+\epsilon})
        $$

      • Variance

        • Calculate spatially in 7x7
        • Also averaged over time using motion vectors
        • Take another 3x3 spatial filter before use

Recurrent AutoEncoder(RAE)

Interactive Reconstruction of Monte Carlo Image Sequences using a Recurrent denoising Auto Encoder

  • A post-processing network that does denoising
  • with the help of G-buffers
  • The network automatically performs temporal accumulation

Key architecture design

  • Auto Encoder(or U-Net) structure

  • Recurrent convolutional block

image-20221002175327278