Recursive raytracing
send a ray from eye center through each pixel center
draw the object that intersect the ray closest to the image plane:
algorithm:
For every of the screen{
1. generate primary ray: eye -> pixel center
2. color(ray)
}
color(ray){
- computer 1. intersection; if no, return background color
- set C to zero vector
- For each light source{
1.compute line segment from intersection to light source
2. test for intersection with objects
3. if no intersection, add phong model color for light source and intersection to C
} - if object at intersection is mirror-like, generate refelcted ray and add color to C
- if object at intersection is transparent, generate refracted ray and add color to C
- return color
}
Ray Object Intersection
ray definition:
R
(
t
)
=
R
0
+
t
∗
R
d
R(t) = R_0+t*R_d
R(t)=R0+t∗Rd
R
0
R_0
R0 origin of the ray
R
d
R_d
Rd direction
- Sphere
- Triangle
- Triangle better
- Algebraic Surfaces
- Implicit surface
ray tracing is slow:
n #primitives in the scene
m #primary rays
comlexity: at least O(mn)
Faster/fewer ray object intersection
- spatial data structure/bounding volume hierarchies
non-intersection faster - directional precomputation
light-buffer - hierarchical spatial subdivison
kd-tree traversal
Fewer rays
adaptive recursion depth
Faster ray object intersection
bounding volume hierarchies: culling algorithm
(adaptive) spatial subdivision
hierarchical spatial subdivison
Directional precomputation
- light buffer
Distribution ray tracing
- soft shadows 软阴影
- Gloss/Blurred reflection 光泽/反射模糊
- Blurred transparency 透明度模糊
- Motion Blur 运动模糊
- Depth of field 景深
Advantages
only ray intersection and normal computation at intersection
Disadvantages
sampling => aliasing =>solution: super sampling, but expensive
high computation effort
expensive shadow edges - penumbra/soft shadows 阴影边缘–半影/柔和阴影
recomputed for each new viewpoint