图形学基础光线追踪

Why Ray Tracing?
Rasterization couldn’t handle global effects well

  • (Soft) shadows
  • And especially when the light bounces more than once
    • Rasterization is fast, but quality is relatively low

Ray tracing is accurate, but is very slow

  • Rasterization: real-time, ray tracing: offline
  • ~10K CPU core hours to render one frame in production

Basic Ray-Tracing Algorithm
光线直线传播、不碰撞、从光源出发最终进入眼睛

Ray Casting
Generating Eye Rays

Shading Pixels (Local Only)

Recursive (Whitted-Style) Ray Tracing

Ray-Surface Intersection
光线数学定义

和球求交



显式表面

与平面求交

Möller Trumbore Algorithm MT算法 等式左边光线 右边三角形内部点

Accelerating Ray-Surface Intersection

Bounding Volumes包围体积
AABB




Uniform Spatial Partitions (Grids)

For each grid cell Test intersection with all objects stored at that cell

空间划分
Spatial Partitions

KD-tree 不好写 物体可能存在多个盒子里


物体划分(重要)
Object Partitions & Bounding Volume Hierarchy (BVH) 先分物体,再求包围盒




Basic radiometry (辐射度量学)

Radiant Energy and Flux (Power)

Radiant Intensity power每单位立体角

立体角的概念 锥的面积除以半径的平方




Irradiance power每单位投影面积 光线与面垂直投影

Lambert’s Cosine Law

Irradiance衰减r^2

Radiance power每单位立体角每单位投影面积



Incident Radiance:the irradiance per unit solid angle

Exiting Radiance:the intensity per unit projected area

Irradiance vs. Radiance
Irradiance: total power received by area dA
Radiance: power received by area dA from “direction” dω

Bidirectional Reflectance Distribution Function (BRDF)双向反射分布函数 定义能量从某个方向进来以后反射方向上能量分布
Reflection at a Point

光线和物体的作用,受物体的材质影响

从某个方向看着色点,后三项为dA收到的能量irradiance

Recursive Equation除了光源,其他点反射的radiance 递归

The Rendering Equation渲染方程 Le自己发射的radiance

反射方程理解


面光源 积分面光源的立体角

反射面当做光源


简写

NB!!!!
弹射一次直接光照
两次间接光照
全部加起来:全局光照
无限反射会收敛至一定亮度

Probability Review 概率论回顾

Expected Value of a Random Variable期望

Probability Distribution Function (PDF)概率分布函数

Monte Carlo Integration蒙特卡洛积分 一种近似
Why: we want to solve an integral, but it can be too difficult to solve analytically.
What & How: estimate the integral of a function by averaging random samples of the function’s value.



Path Tracing 路径追踪
Whitted-style ray tracing:

  • Always perform specular(光滑) reflections / refractions
  • Stop bouncing at diffuse surfaces

Are these simplifications reasonable?(why)
High level: let’s progressively improve upon Whitted-Style Ray Tracing and lead to our path tracing algorithm!
whitted-style光线追踪不对,渲染方程是对的,需要解决积分求解的问题

简单情况只考虑直接光照





Global Illumination
One more step forward: what if a ray hits an object?


存在的问题
1、光线数量爆炸,指数级增长

解决方法:只打出一条光线(只采样一次)n=1,路径跟踪

结果:噪声比较大
Ray Generation 用足够多的path


2、The recursive algorithm will never stop!
解决方法:Solution: Russian Roulette (RR)俄罗斯轮盘赌
Russian Roulette is all about probability
With probability 0 < P < 1, you are fine
With probability 1 - P, otherwise
期望仍是Lo


仍存在的问题:不够高效
SPP (samples per pixel):一个像素打出的光线数量
四面八方采样效率较低

直接光源采样,蒙特卡洛积分矛盾,渲染方程得在光源处微表面积分

dA投影就是立体角


两方面的光:光源、其他反射物


遮挡问题

点光源?

Ray tracing: Previous vs. Modern Concepts

posted @ 2022-09-15 19:45  夏末薄荷  阅读(138)  评论(0)    收藏  举报