CS184 Lecture 34 summary

Radiosity - continued

Recall the definition of radiance:

Intensity or Radiance

Since light rays have both direction and "location" (as in what points they pass through), we have to measure energy per unit time per unit area and per unit solid angle. The units of energy per unit time is watts. So

Radiance is radiant energy per unit time, per unit area, per unit solid angle.
Its units are watts/m2/steradian

This definition can be a bit confusing, because we will talk about the radiance at a point, or in a given direction. What we mean in those cases is:

Radiance at a point p: is the energy per unit time per unit solid angle striking an infinitesimal area dA containing p, divided by the area of dA.

Radiance in a direction L: is the energy per unit time per unit area within a range dw of solid angle about L, divided by dw.

This is just like density: e.g. we can talk about the density of an object as mass/volume, but we can also talk about the density at a point as the ratio dM/dV, where dV is a small volume containing the point, and dM is the mass inside that volume.

Form Factors

The coupling between surface patches is expressed using form factors. The form factor Fjk between patch j and patch k is the fraction of energy Bj emitted by patch j that is caught by patch k. Not all the energy received by patch k is reflected, and in fact the amount that it reflects is a fraction rk, which is related to its diffuse reflection coefficient Kd. So in fact what it radiates due to illumination from patch j is

Bk = rk Fjk Bj

Since many other patches may illuminate patch k, its total radiant energy is:

Bk = rk S Fjk Bj

To compute the form factors, let's consider infinitesimal patches first. Let the patches be dAj and dAk, and let r be the distance between them. We also need the angles between the patch normals and the line between them, call these qj and qk respectively.

If we assume that the patch j is a diffuse reflector, its apparent intensity is the same in all directions (Lambertian assumption). But that doesnt mean its radiated power is the same in all directions. The patch will have the same brightness, but subtend less area when viewed away from its normal. In fact, the area subtended falls off as the cosine of the angle from the normal to the direction of view.

To compute the power at radius r, we consider the hemisphere of radius r centered at the patch dAj. We know that the power isnt distributed evenly, but falls off as cos qj. There is a simple geometric interpretation of this. The radiant energy incident on a patch dA at radius r on the hemisphere is equal to the projection of this patch on the filled circle of radius r, divided by the area of this circle, which is pr2. Thus the intensity from the patch dAj which is received by an element dA at distance r is:

Rj cos qj dA / pr2

And the last step for computing Fjk is to figure out how much of this energy reaches dAk. This depends on how much area subtends on the hemisphere of radius r. Once again, this depends on a cosine. Specifically, the area dA on the hemisphere is

dA = dAk cos qk

And so the energy radiated by dAj and caught by dAk is

Bj cos qj dAk cos qk / pr2

Whence the coupling coefficient Fjk is obtained by dividing this quantity by Bj and is

cos qj dAk cos qk / pr2

To get the coupling coefficients Fjk between larger patches j and k, we must integrate this quantity over the areas Aj and Ak, and divide by Aj.

Because of the symmetry between j and k in the form factor Fjk, we can express the form factor in the other direction Fkj by multiplying by areas:

Aj Fjk = Ak Fkj

Note also that for a completely sealed enclosure (one where all the light eventually hits some surface patch), the sum over j of the coupling coefficients Fjk must be 1. This is just a statement that the radiant energy is conserved. Whatever is radiated from patch k is coupled to some surface in the environment.

The radiosity equations

Once we have the coupling equations:

Bk = rk S Fjk Bj

we can add an emissive term to some of the surfaces so that we have lighting in the environment:

Bk = rk S Fjk Bj

Then, given the known quantities Fjk and rk, we have n linear equations in the n unknowns Bj. We can solve them to compute the brightness of each surface patch Bj. That gives us complete information about the diffuse brightness of every patch in the environment.

Here is an example of an environment (known as the Cornell box) computed with (left) and without (right) radiosity. Note the absence of indirect illumination from the colored walls in the right-hand figure.

cornell12.jpg (39782 bytes)

You should be able to see a red glow on the left face of the left-hand box in the first figure and a green glow on the right-hand box. The second figure has neither of these properties and the ceiling is much dimmer because there is no diffuse scattering of light from the top faces of the boxes. The source code for the left-hand figure (taken from BMRTs examples directory) is here.

Occlusion/ Patch size

We have assumed so far that any patch can receive light from any other. But this is only possible if the two patches are at least partially visible to each other. If there is something in the way, the actual form factor will be a fraction of the value computed above. If there is something in the way, it is quite possible that the coupling will not be uniform across the two patches, and one patch may be partially shadowed by the object in the way.

For this reason, the patches used in radiosity are made "small". The idea is to make them small enough that their illumination is uniform over their area. In BMRT, you can specify patch size with the "patchsize" option (see the online guide). To determine the coupling between two patches, you can cast rays between them. If the rays are chosen randomly from within the space of possible rays through the patches, the fraction that get through is a good estimate of the scaling factor that should be applied to the form factor Fjk. By default, BMRT only casts one ray. It assumes the patches are small enough that they are either fully visible or invisible to each other. You can increase this number with the "-rsamples" option.

Other renderers choose patch sizes adaptively. If you cast multiple rays between two patches, and some get through while others do not, then the patches are partly occluded. In this case, its a good idea to subdivide them so that the smaller patches are either fully visible or invisible.

Two-pass Rendering

We now have the ray-tracing method to deal with specular reflections and radiosity to deal with diffuse refection. A real image will have both. How do we combine them?

One common approach (used in BMRT), is to run radiosity first, followed by ray-tracing. This is the most natural approach, because radiosity assumes that the diffuse illumination is available. Radiosity on the other hand, is mostly independent of the specular reflections, and so usually gives the right answer when run before ray-tracing. The approach of running a radiosity step before ray-tracing is often called two-pass rendering.

Note: Shadows happen naturally in radiosity algorithms because light sources (including area sources) are just surface patches that emit light, and their mutual visibility has already been checked. In fact, radiosity does a very good job with area sources and doesnt require sampling the way ray-tracing does.

There are some bad cases for this process however. One of them happens in the example below.

dresser12.jpg (76787 bytes)

In the image on the left, radiosity intensities are computed from casting rays directly to the light sources (which creates shadows if there is something in the way). But indirect lighting from a specular object (like the mirror) doesnt happen because the ray-tracing step hasnt happened yet. The figure on the right shows an improvement where radiosity lighting is computed by limited ray-tracing during the radiosity step.

This is implemented in BMRT by declaring a bouncer light source. The bouncer isnt a light source at all, but is a procedure that is called each time a surface patch looks for the light sources. What it does is to compute ray directions from the real light sources via specular objects in the environment. By declaring a bouncer as light source number 1, we get the effect in the second figure above. Namely, there is now indirect illumination of the dresser (and a forward shadow of the thermos) in the second figure.

Ray-tracer/radiosity capabilities

There is a notation that is sometimes used to express the capabilities of the renderer in terms of the kinds of surface reflections that can happen between viewer and light source. We use S to represent a specular reflection, D a diffuse reflection, and L a light sources. A normal ray tracer supports

S* D L

meaning that a ray can have any number of specular reflections (or refractions), then hit a diffuse surface, and then a light source. It requires a ray-trace step from the last D to L to compute shadows.

A two-pass (radiosity then ray-tracing) renderer can encounter multiple diffuse surfaces on its way to the source (but only after the specular surfaces) which we could write as:

S* D* L

If we incorporate the bouncer light source as in BMRT, then the capability extends to

S* D* S L

The BMRT documentation is unclear whether there can be more than one S in the second group (i.e. whether its S* D* S L or S* D* S* L). The last example image required only one (for the mirror).