# CS 184: COMPUTER GRAPHICS

PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT

# Warm-up Problem: Determine which of the locations (A, B, C, D) has the maximum and the minimum ambient occlusion:

## SOLUTION

We discuss Photon Mapping and Ambient Occlusion first, because they are suitable project extensions.
Now I want to give you a quick survey, so that when you here the various names you have an idea what it is all about.
But first some important definitions and generalizations:

## BRDF (Bidirectional Reflectance Distribution Function)

The  BRDF  expresses a simple model of light interaction with a surface; it states what fraction of the incoming light from a particular direction ω' is sent off in the direction ω :
$f_r(x, \vec w', \vec w) = \frac{dL_r(x, \vec w)}{L_i(x, \vec w')(\vec w' \cdot \vec n) d\vec w'}$

This general expression, where L is radiance,  x  is a location on a surface,  n  is the surface normal at that point, and  ω  are direction vectors, can capture the surface properties of almost all materials; in principle there is such a formula for every spectral band of interest (e..g, R G B).
The simpler models of diffuse reflection, specular reflection, and Phong reflection are idealized special cases of a BRDF.

## The Rendering Equation

This is of mostly academic/theoretical use. It calculates the amount of reflected light in any direction given full knowledge of the BRDF of the surface and of the incoming light distribution. It serves as the most abstract formal expression of the non-perceptual aspect of rendering. All specific rendering algorithms can understood as finding (approximate) solutions to some parts of this equation.

$L_o(x, \vec w) = L_e(x, \vec w) + \int_\Omega f_r(x, \vec w', \vec w) L_i(x, \vec w') (\vec w' \cdot \vec n) d\vec w'$

The outgoing light (Lo) for a particular position and direction is the sum of the emitted light (Le) and the reflected light. The reflected light is the sum of the incoming light (Li) from all directions, multiplied by the surface reflection and cosine of incoming angle. By connecting outward light to inward light, via an interaction point, this equation stands for the whole 'light transport' — all the movement of photons — in a scene. (to learn more).

## Rendering Techniques:

### Ray Casting

Rays are cast from the eye through all pixels and reports first intersection in Scene. From these points of intersections, rays may be cast towards all light sources to determine whether they are illuminated by those sources or are shadowed by some obstacle.
Symbolically, these are the paths that are being investigated:  E (S|D) L

### Ray Tracing

Rays are cast from the eye through all pixels. At intersections with reflective or with transparent surfaces, secondary rays are initiated in the reflected and refracted directions; these new rays are generated in a recursive manner.
Symbolically, these are the paths that are being investigated:  E S* (S|D) L

### Cone Tracing

This was a (mostly unsuccessful) attempt to make ray-tracing more efficient by exploiting coherence of near-by rays. Cone-shaped bundles of rays are pursued jointly, with the expectation that they would experience (for the most part) the same kind of surface intersections, reflections, and shadowing. But for interesting scenes, this is typically not true, and the book-keeping becomes prohibitive.

### Beam Tracing

This was another (mostly unsuccessful) attempt to make ray-tracing more efficient by exploiting coherence of near-by rays. In this case, the rays that are traced together form pyramids with polygonal cross sections corresponding to the shape of individual faces or the spaces left between them. Again, the various rays in a bundle will typically encounter different situations and thus become dissimilar very quickly.

### Classical Rendering Pipeline

In a loose analogy, this can be understood as a one-step "beam-casting" procedure. The pyramids corresponding to individual faces in the scene, with the eye as the pyramid tip are cast into the z-buffer and enhanced with some lighting effects such as Gouraud shading or Phong shading.

### Path Tracing

This is an exhaustive (inefficient), un-biased, statistical approach to ray-casting that also generates secondary rays on diffuse surfaces. These secondary rays are emitted in a statistical manner based on the BRDF (Bidirectional reflectance distribution function) at the intersection point with a surface. (More likely directions of reflection are sampled more frequently.)
Symbolically, these are the paths that are being investigated:  E (S|D)* L

### Photon Tracing

This is also an exhaustive (inefficient), statistical approach to deal with all forms of illumination in an unbiased way. It simulates realistic photon behavior by using an adapted ray tracing method that sends rays from all light sources. Each ray keeps bouncing around until one of three things occurs: (a) it leaves the rendering scene; (b) it hits the eye or camera; (c) it has been absorbed by one of the surface intersections or reduced in it radiance value (probability of existance of the photon) below some appropriate threshold.
Symbolically, these are the paths that are being investigated:  L (S|D)* E

### Metropolis Light Transport

The procedure constructs paths from the eye to a light source using bidirectional path tracing, then constructs slight modifications to the path. Some careful statistical calculation (the Metropolis algorithm) is used to compute the appropriate distribution of brightness over the image. Once a path has been found from a light to the eye, the algorithm can then explore nearby paths; thus difficult-to-find light paths can be explored more thoroughly with the same number of simulated photons. Metropolis Light Transport is an unbiased method that converges to a solution of the rendering equation quicker than other unbiased algorithms such as Path Tracing or Photon Tracing.

### Ambient Occlusion

Deals with the ambient lighting coming from the "sky."
(to lern more).

Tries to answer the question "How do the photons from the light source(s) travel around the scene?" in a more efficient manner than Photon Tracing by exploiting coherence.
In the simplest case we assume all the surfaces are perfectly diffuse reflectors. Thus the apparent brightness of a surface is independent of viewer position.
However, large (flat) polygons can still have non-uniform brightness because of non-uniform illumination. We now consider indirect illumination by other illuminated and diffusely reflecting surfaces. For this, we break up large surfaces into small flat polygons (patches) over which we can assume the brightness to be constant.
Once all the patches have been assigned their brightness (color) values, we can render the scene from any viewpoint.

To calculate the amount of diffuse illumination that gets passed from one patch to another, we need to know the form factor between them.
This form factor describes how well the two patches can see one another (depends on distance, relative orientation, occluders between them).
Once we have determined all these purely geometrical form factors, we can set up a system of p linear equations in the radiosity of the p patches.
Solving this system with a direct method (e.g. Gaussian elimination) is not practical, if there are thousands or millions of patches.
But we can exploit the fact that most of the form factors are typically zero, since many pairs of patches cannot send much light to each other.
Thus we can apply an iterative approach:
-- First consider only the light directly emitted by the active light sources.
-- Then add the light that results from only a single reflection on any surface from the source lights.
-- Next add the light that has seen two reflections, and so on ...
-- The process is stopped locally whenever the additional contributions fall below some desired level of accuracy.
Symbolically, these are the paths that are being investigated:  L D* E

### Two-Pass Method

One way to combine the best capabilities of radiosity-based rendering (indirect lighting by diffuse-diffuse interreflections)
and of ray-tracing (specular reflections, translucency), is to use a two-pass method.
The first pass is a radiosity-like algorithm that creates an approximate global illumination solution.
In the second pass this approximation is rendered using an optimized Monte Carlo ray tracer (statistical sampling).
This scheme works very well for modest scenes.
But for models with millions of polygons, procedural objects, and many glossy reflections, the rendering costs rise steeply,
mainly because storing illumination within a tessellated representation of the geometry uses too much memory.

### Photon Mapping

This gives the best results for the amount of computational effort spent.
Symbolically, these are the paths that are being investigated:  L (S|D)* E;   E S* D.

## First intermediate report (="AS#9"):  Submit names of team members plus your plan (1 - 5 sentences) for the project by WED April 29, 2009.

PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT
Page Editor: Carlo H. Séquin