You are on page 1of 64

Advanced Computer Graphics

• Global Illumination – Ray tracing


• Global Illumination - Radiosity
Ray Tracing
Ray Tracing
} Idea
} A technique based on digital simulation of geometric optics
} Rays of light are traced from light source, following their way
to observers point of view.
} Forward Mapping (Natural phenomenon)
¨ infinite number of rays from light source to object to viewer
} Backward Mapping (Ray Tracing)
¨ finite number of rays from viewer through each sample to object
to light source (or other object)
Ray Tracing (cont’)
} Has ability to render such effects as
} Shadowing, Transparency, Reflection and Refraction.
} Suggested by Appel in 1968 (Ray Casting process)

} Ray Casting Process


} The light rays may reach the observer by reflection from the
objects
} If the light rays from the source are traced, very few will reach the
observer
} Appel originally suggest that ray should be traced in opposite
direction
} A method determining the first object to be encountered by a ray
Ray Tracing (cont’)
} In 1980,
} Whitted implemented complete Ray-Tracing algorithms in
conjunction with global illumination models.

} Now
} Can deals with reflection, refraction for transparent objects, and
shadow effects.
Ray Tracing Algorithm
} Assumes that scene has been transformed to image space.
} The observer is assumed to be on the positive z-axis
} Parallel or perspective

} Generate primary (‘eye’) ray


} Each ray passes from the observer through the center of a pixel into the
scene
} Find closest object along ray path
} Find first intersection between ray and an object in scene
} Compute light sample
} Use illumination model to determine direct contribution from light sources
for greater accuracy
} Recursively generate secondary rays at equal
Ray Tracing Algorithm

First order reflection Second order reflection


Ray Tracing Algorithm
} Reflection and Refraction
Ray Tracing vs. Scan Conversion
} Scan conversion
} After meshing and projection
} 3D → 2D → Image
} Based on transforming geometry
} For each triangle in scene

} Raytracing
} 3D → Image
} Geometric reasoning about light rays
} For each sample in pixel image…
Examples
Ray Generation
} Ray equation

} Through eye at t = 0
} At pixel center at t = 1

R(t) = E + td
Intersection point calculation
} Ray-Scene Intersection
} Intersections with geometric primitives
} Sphere
} Triangle
} Groups of primitives (scene)
} Acceleration techniques
} Bounding volume hierarchies
} Spatial partitions
¨ Uniform grids
¨ Octrees
¨ BSP trees
Intersection point calculation (cont’)
} Ray-Sphere Intersection
Intersection point calculation (cont’)
} Ray-Sphere Intersection
Intersection point calculation (cont’)
} Ray-Sphere Intersection
} Need normal vector at intersection for lighting
calculations
Intersection point calculation (cont’)
} Ray-Triangle Intersection
} First, intersect ray with plane
} Then, check if point is inside triangle
Intersection point calculation (cont’)
} Ray-Triangle Intersection
} intersect ray with plane
Intersection point calculation (cont’)
} Ray-Triangle Intersection
} Check if point is inside triangle algebraically

0
0
Intersection point calculation (cont’)
} Other Ray-Primitive Intersections
} Cone, cylinder, ellipsoid:
} Similar to sphere
} Box
} Intersect 3 front-facing planes, return closest
} Convex polygon
} Same as triangle (check point-in-polygon algebraically)
} Concave polygon
} Same plane intersection
} More complex point-in-polygon test
Intersection point calculation (cont’)
} Expensive Cost
} Ray Tracing is an exhaustive process for a display of
512 x 512 pixels
} 512 x 512 = 266,144 rays must be traced, and their potential
intersections with the objects should been evaluated

} The most critical part of this process is ray-object


intersection test
Intersection point calculation (cont’)
} Acceleration techniques
} intersections,
} use bounding volume of an objects
} use space subdivision technique
} As a bounding volume, either a
} bounding box
} bounding sphere
may be used
Intersection point calculation (cont’)
} Bounding Volumes
} Check for intersection with simple shape first
} If ray doesn’t intersect bounding volume, then it doesn’t intersect
its contents
} If found another hit closer than hit with bounding box, then can
skip checking contents of bounding box
Intersection point calculation (cont’)
} Bounding Volume Hierarchies
} Use hierarchy to accelerate ray intersections
} Intersect node contents only if hit bounding volume
Computing light sample
} Local Illumination è Ray Casting
Computing light sample
} Recursive Ray Tracing
} Shadows and direct lighting
} Reflection and refraction
} Antialiasing, motion blur, soft shadows, and depth of field
Advanced Ray-Tracing Techniques
} Shadow Ray
} Reflection Ray
} Refracted Ray
} Distributed Ray-Tracing
} Soft Shadow
} Glossy Reflection
} Glossy Translucency
} Motion Blur
} Depth of Field
Shadow Rays
} Detect shadow by rays to light source
Shadow Rays
} Test for occluder
} No occluder, shade normally ( e.g. Phong model )
} Yes occluder, skip light ( don’t skip ambient )
Reflection Ray
} Recursive shading
} Ray bounces off object
} Treat bounce rays (mostly) like eye rays
} Shade bounce ray and return color
} Shadow rays
} Recursive reflections
} Add color to shading at original point
} Specular or separate reflection coefficient

V B

S
Refracted Ray
} Transparent materials bend light
} Snell’s Law
“Distributed” Raytracing
} Send multiple rays through each pixel

} Average results together


} Jittering trades aliasing for noise
} Use multiple rays for reflection and refraction
How many rays???
“Distributed” Raytracing
: Soft Shadows
} Soft shadows result from non-point lights
} Some part of light visible, some other part occluded

Area Light

Occluder
“Distributed” Raytracing
: Soft Shadows
} Distribute shadow rays over light surface
Soft Shadows
“Distributed” Raytracing
: Glossy Reflection
} multiple reflection rays

Justin Legakis

θ θ polished surface
“Distributed” Raytracing
: Glossy Translucency
} Jittering the rays about the actual transmission angle
N
produces a blurred effect
I

qI

T
Bound of jittered
reflection rays
“Distributed” Raytracing
: Motion Blur
} Distribute rays over time
} More when we talk about animation...
“Distributed” Raytracing
: Depth of Field
} Pinhole camera – everything in focus.
} Camera with lens – utilized depth of field

Pinhole Camera Camera with lens

Image Plane Image Plane Focal Plane


“Distributed” Raytracing
: Depth of Field (DoF)
} Distribute rays over a lens assembly
} multiple rays per pixel
Depth of Field
} multiple rays per pixel

film focal length Justin Legakis


Depth of Field
Radiosity
Radiosity
} Global illumination for diffuse
surfaces
} Models view-independent
illumination
} Diffuse/soft shadows, color bleeding
} Motivation
} Energy transport between diffuse
surfaces
} Area light sources
} Soft shadows → Realistic images
Radiosity Example
Radiosity Example
Radiosity Example
Local Illumination
Ray-tracing Illumination
Radiosity Illumination
Radiosity
} Light energy per unit time per unit area
} Based on conservation of light energy
} Assumes area light sources
Radiosity Equation
Modeling Light Reflections
Form Factor
Radiosity Equation
Radiosity Equation
Radiosity Equation

: Gauss-Seidel Method
How to compute Form Factors
How to compute Form Factors

The projected area / The area of the circle


Hemi-Cube Form Factors

The projected area / The area of the square


Progressive Refinement Radiosity
Progressive Refinement Radiosity
Radiosity Artifacts
} Light Leaks
} Hemicube aliasing
} Light distribution at patches, whereas vertices are used
for shading
} Mesh discretization (solution: adaptive meshing)
} Need a separate specular pass to capture specular
highlights
Radiosity Artifacts

Light Leaks
Radiosity vs. Ray Tracing
} Radiosity
} Simulates the diffuse propagation of light
starting at the light sources
} Independent of the viewing direction: pre-
computable for static scenes
} Ray tracing
} Follows all rays from the eye of the viewer
back to the light sources
} Good at simulating specular reflections
and transparency

You might also like