跳到正文
DEV Community· Semen Klenov·· 1 小時前AI 評分45

為甚麼路徑追蹤渲染有噪點:平方根定律

Why renders are noisy: the square-root law of path tracing

AI 導讀

路徑追蹤以隨機射線估算光照,因此渲染影像會有噪點;噪點會按樣本數平方根的反比下降。每像素射線數增加至 4 倍,噪點減半;要把噪點由 7% 降至低於 1%,則需 64 倍射線及渲染時間。

正文

Every 3D artist has seen it: a beautiful render covered in grain that only clears after minutes or hours. Beginners often blame their computer or settings. The real reason is statistical, and once you understand it you can control render time much better. In this article I explain where render noise comes from, why games can render in milliseconds, and I show the law behind it with an experiment.

Two ways to make an image from a 3D scene

Rasterisation (game engines) takes each triangle, projects it onto the screen and colours the pixels it covers. It is extremely fast and fits a frame budget: 16.7 ms per frame at 60 fps, 33.3 ms at 30 fps. Shadows, reflections and bounced light are added with clever approximations.

Path tracing (Cycles, Arnold, V-Ray, RenderMan, and now real-time engines too) simulates light physically. For each pixel it sends random rays into the scene, lets them bounce off surfaces and adds up the light they collect. This is a Monte Carlo estimate of the rendering equation (Kajiya, 1986). It is accurate, but it is an average of random samples. Random samples have noise.

The experiment: how noise falls with samples

I estimated the light arriving at a point under a uniform white sky, a simple case where the exact answer is known: π. Each estimate used N random rays, and I repeated each estimate 2,000 times to measure how much it varies.

Rays per pixel Mean estimate Noise (% of true value)
4 3.161 29.6%
16 3.146 14.6%
64 3.138 7.0%
256 3.143 3.7%
1,024 3.142 1.8%
4,096 3.141 0.9%

The average is right from the start. Only the noise changes, and it follows a strict law: noise falls with the square root of the number of samples. Four times more rays halve the noise. Going from 7% to under 1% noise costs 64 times more rays, and so 64 times more render time.

How the industry beats the square root

Since brute force is expensive, most rendering research is about getting more quality per ray. Eric Veach's thesis (1997) laid much of the foundation.

  • Importance sampling: send rays where light actually comes from (towards lamps, bright windows, the shiny lobe of a material).
  • Multiple importance sampling: combine several sampling strategies and weight them, so each covers the other's weak cases.
  • Denoising: AI denoisers (OptiX, Intel Open Image Denoise and others) clean a low-sample image using extra data such as normals and albedo.
  • Caching and approximations: irradiance caches, light probes and, in games, screen-space and hybrid techniques.

Practical tips

  1. Find the noise source. Small bright light sources, caustics and indirect light through small openings cause the most noise. Big soft lights render cleaner.
  2. Use adaptive sampling with a noise threshold instead of a fixed sample count.
  3. Clamp extreme values carefully to remove "fireflies", knowing that it slightly darkens highlights.
  4. Denoise, but check details. Denoisers can smear fine textures and text.
  5. Plan time with the square-root law. To halve visible noise, budget four times the render time.

What this means for my work

SMART ONE includes a photon simulation that shows how light moves through a room reconstructed from a photo. It relies on the same Monte Carlo idea of following many random light paths. In my advertising and 3D work, understanding this law is what makes render budgets predictable. It also explains why lighting design (soft, large sources) is a technical decision as much as an artistic one.

If you are just starting

  • Render the same scene at 16, 64 and 256 samples and compare: you will see the square-root law yourself.
  • Learn your renderer's adaptive sampling and denoiser before buying a faster GPU.
  • In games, learn the frame budget: everything must fit into a few milliseconds.

Reproduce it

import numpy as np
rng = np.random.default_rng(1)
for N in [4, 16, 64, 256, 1024, 4096]:
    cos = rng.random((2000, N))          # uniform hemisphere: cos(theta) is uniform on [0, 1]
    est = (cos*2*np.pi).mean(1)          # estimate of irradiance under a white sky (= pi)
    print(N, round(est.mean(), 3), round(est.std()/np.pi*100, 1), "% noise")

References

  • Kajiya, J. T. (1986). The rendering equation. Computer Graphics (SIGGRAPH 86), 20(4), 143–150.
  • Pharr, M., Jakob, W., & Humphreys, G. (2023). Physically Based Rendering: From Theory to Implementation (4th ed.). MIT Press.
  • Veach, E. (1997). Robust Monte Carlo Methods for Light Transport Simulation (PhD thesis). Stanford University.

SEMEN KLENOV · 3D graphics for beginners. Drafted with AI assistance; experiment code and numbers checked by the author.


Originally published at https://semenklenov.com/journal/why-renders-are-noisy/

來源:DEV Community · dev.to