5.5 Working with Radiometric Integrals

One of the most frequent tasks in rendering is the evaluation of integrals of radiometric quantities. In this section, we will present some tricks that can make this task easier. To illustrate the use of these techniques, we will use the computation of irradiance at a point as an example. Irradiance at a point normal p Subscript with surface normal bold n Subscript due to radiance over a set of directions normal upper Omega  is

upper E Subscript Superscript Baseline left-parenthesis normal p Subscript Baseline comma bold n Subscript Baseline right-parenthesis equals integral Underscript normal upper Omega Endscripts upper L Subscript normal i Superscript Baseline left-parenthesis normal p Subscript Baseline comma omega right-parenthesis StartAbsoluteValue cosine theta EndAbsoluteValue normal d omega Subscript Baseline comma
(5.4)

where upper L Subscript normal i Superscript Baseline left-parenthesis normal p Subscript Baseline comma omega right-parenthesis is the incident radiance function (Figure 5.12) and the cosine theta term in this integral is due to the normal d upper A Subscript Superscript up-tack term in the definition of radiance. theta is measured as the angle between omega Subscript and the surface normal bold n Subscript . Irradiance is usually computed over the hemisphere script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis of directions about a given surface normal  bold n Subscript .

Figure 5.12: Irradiance at a point normal p Subscript is given by the integral of radiance times the cosine of the incident direction over the entire upper hemisphere above the point.

5.5.1 Integrals over Projected Solid Angle

The various cosine terms in the integrals for radiometric quantities can often distract from what is being expressed in the integral. This problem can be avoided using projected solid angle rather than solid angle to measure areas subtended by objects being integrated over. The projected solid angle subtended by an object is determined by projecting the object onto the unit sphere, as was done for the solid angle, but then projecting the resulting shape down onto the unit disk that is perpendicular to the surface normal (Figure 5.13). Integrals over hemispheres of directions with respect to cosine-weighted solid angle can be rewritten as integrals over projected solid angle.

Figure 5.13: The projected solid angle subtended by an object is the cosine-weighted solid angle that it subtends. It can be computed by finding the object’s solid angle, projecting it down to the plane perpendicular to the surface normal, and measuring its area there. Thus, the projected solid angle depends on the surface normal where it is being measured, since the normal orients the plane of projection.

The projected solid angle measure is related to the solid angle measure by

normal d omega Subscript Baseline Superscript up-tack Baseline equals StartAbsoluteValue cosine theta EndAbsoluteValue normal d omega Subscript Baseline comma

so the irradiance-from-radiance integral over the hemisphere can be written more simply as

upper E Subscript Superscript Baseline left-parenthesis normal p Subscript Baseline comma bold n Subscript Baseline right-parenthesis equals integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper L Subscript normal i Superscript Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript Baseline right-parenthesis normal d omega Subscript Baseline Superscript up-tack Baseline period

For the rest of this book, we will write integrals over directions in terms of solid angle, rather than projected solid angle. In other sources, however, projected solid angle may be used, and so it is always important to be aware of the integrand’s actual measure.

Just as we found irradiance in terms of incident radiance, we can also compute the total flux emitted from some object over the hemisphere surrounding the normal by integrating over the object’s surface area  upper A :

StartLayout 1st Row 1st Column normal upper Phi 2nd Column equals integral Underscript upper A Endscripts integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper L Subscript normal o Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript Baseline right-parenthesis cosine theta normal d omega Subscript Baseline normal d upper A Subscript Baseline 2nd Row 1st Column Blank 2nd Column equals integral Underscript upper A Endscripts integral Underscript script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis Endscripts upper L Subscript normal o Baseline left-parenthesis normal p Subscript Baseline comma omega Subscript Baseline right-parenthesis normal d omega Subscript Baseline Superscript up-tack Baseline normal d upper A Subscript Baseline period EndLayout

5.5.2 Integrals over Spherical Coordinates

It is often convenient to transform integrals over solid angle into integrals over spherical coordinates left-parenthesis theta comma phi right-parenthesis . Recall that an left-parenthesis x comma y comma z right-parenthesis direction vector can also be written in terms of spherical angles (Figure 5.14):

StartLayout 1st Row 1st Column x 2nd Column equals sine theta cosine phi 2nd Row 1st Column y 2nd Column equals sine theta sine phi 3rd Row 1st Column z 2nd Column equals cosine theta period EndLayout

Figure 5.14: A direction vector can be written in terms of spherical coordinates left-parenthesis theta comma phi right-parenthesis if the x , y , and z basis vectors are given as well. The spherical angle formulae make it easy to convert between the two representations.

In order to convert an integral over a solid angle to an integral over left-parenthesis theta comma phi right-parenthesis , we need to be able to express the relationship between the differential area of a set of directions normal d omega Subscript and the differential area of a left-parenthesis theta comma phi right-parenthesis pair (Figure 5.15). The differential area normal d omega Subscript is the product of the differential lengths of its sides, sine theta normal d phi Subscript and normal d theta Subscript . Therefore,

normal d omega Subscript Baseline equals sine theta normal d theta Subscript Baseline normal d phi Subscript Baseline period
(5.5)

Figure 5.15: The differential area normal d omega Subscript subtended by a differential solid angle is the product of the differential lengths of the two edges sine theta normal d phi Subscript and normal d theta Subscript . The resulting relationship, normal d omega Subscript Baseline equals sine theta normal d theta Subscript Baseline normal d phi Subscript , is the key to converting between integrals over solid angles and integrals over spherical angles.

We can thus see that the irradiance integral over the hemisphere, Equation (5.4) with normal upper Omega equals script upper H squared left-parenthesis bold n Subscript Baseline right-parenthesis , can equivalently be written as

upper E Subscript Superscript Baseline left-parenthesis normal p Subscript Baseline comma bold n Subscript Baseline right-parenthesis equals integral Subscript 0 Superscript 2 pi Baseline integral Subscript 0 Superscript pi slash 2 Baseline upper L Subscript normal i Superscript Baseline left-parenthesis normal p Subscript Baseline comma theta comma phi right-parenthesis cosine theta sine theta normal d theta Subscript Baseline normal d phi Subscript Baseline period

If the radiance is the same from all directions, the equation simplifies to upper E Subscript Superscript Baseline equals pi upper L Subscript normal i Superscript .

For convenience, we’ll define two functions that convert theta and phi values into left-parenthesis x comma y comma z right-parenthesis direction vectors. The first function applies the earlier equations directly. Notice that these functions are passed the sine and cosine of theta , rather than theta itself. This is because the sine and cosine of theta are often already available to the caller. This is not normally the case for phi , however, so phi is passed in as is.

<<Geometry Inline Functions>>+=  
inline Vector3f SphericalDirection(Float sinTheta, Float cosTheta, Float phi) { return Vector3f(sinTheta * std::cos(phi), sinTheta * std::sin(phi), cosTheta); }

The second function takes three basis vectors representing the x , y , and z axes and returns the appropriate direction vector with respect to the coordinate frame defined by them:

<<Geometry Inline Functions>>+=  
inline Vector3f SphericalDirection(Float sinTheta, Float cosTheta, Float phi, const Vector3f &x, const Vector3f &y, const Vector3f &z) { return sinTheta * std::cos(phi) * x + sinTheta * std::sin(phi) * y + cosTheta * z; }

The conversion of a direction left-parenthesis x comma y comma z right-parenthesis to spherical angles can be found by

StartLayout 1st Row 1st Column theta 2nd Column equals arc cosine z 2nd Row 1st Column phi 2nd Column equals arc tangent StartFraction y Over x EndFraction period EndLayout

The corresponding functions follow. Note that SphericalTheta() assumes that the vector v has been normalized before being passed in; the clamp is purely to avoid errors from std::acos() if StartAbsoluteValue monospace v monospace period monospace z EndAbsoluteValue is slightly greater than 1 due to floating-point round-off error.

<<Geometry Inline Functions>>+=  
inline Float SphericalTheta(const Vector3f &v) { return std::acos(Clamp(v.z, -1, 1)); }

<<Geometry Inline Functions>>+= 
inline Float SphericalPhi(const Vector3f &v) { Float p = std::atan2(v.y, v.x); return (p < 0) ? (p + 2 * Pi) : p; }

5.5.3 Integrals over Area

One last transformation of integrals that can simplify computation is to turn integrals over directions into integrals over area. Consider the irradiance integral in Equation (5.4) again, and imagine there is a quadrilateral with constant outgoing radiance and we’d like to compute the resulting irradiance at a point normal p Subscript . Computing this value as an integral over directions is not straightforward, since given a particular direction it is nontrivial to determine if the quadrilateral is visible in that direction. It’s much easier to compute the irradiance as an integral over the area of the quadrilateral.

Differential area is related to differential solid angle (as viewed from a point normal p Subscript ) by

normal d omega Subscript Baseline equals StartFraction normal d upper A Subscript Baseline cosine theta Over r squared EndFraction comma
(5.6)

where theta is the angle between the surface normal of normal d upper A Subscript and the vector to normal p Subscript , and r is the distance from normal p Subscript to normal d upper A Subscript (Figure 5.16). We will not derive this result here, but it can be understood intuitively: if normal d upper A Subscript is at distance 1 from  normal p Subscript and is aligned exactly so that it is perpendicular to normal d omega Subscript , then normal d omega Subscript Baseline equals normal d upper A Subscript , theta equals 0 , and Equation (5.6) holds. As normal d upper A Subscript moves farther away from normal p Subscript , or as it rotates so that it’s not aligned with the direction of normal d omega Subscript , the r squared and cosine theta terms compensate accordingly to reduce  normal d omega Subscript .

Figure 5.16: The differential solid angle subtended by a differential area normal d upper A Subscript is equal to normal d upper A Subscript Baseline cosine theta slash r squared , where theta is the angle between normal d upper A Subscript ’s surface normal and the vector to the point normal p Subscript and r is the distance from normal p Subscript to normal d upper A Subscript .

Therefore, we can write the irradiance integral for the quadrilateral source as

upper E Subscript Superscript Baseline left-parenthesis normal p Subscript Baseline comma bold n Subscript Baseline right-parenthesis equals integral Underscript upper A Endscripts upper L Subscript Superscript Baseline cosine theta Subscript normal i Baseline StartFraction cosine theta Subscript normal o Baseline normal d upper A Subscript Baseline Over r squared EndFraction comma

where upper L Subscript Superscript is the emitted radiance from the surface of the quadrilateral, theta Subscript normal i is the angle between the surface normal at normal p Subscript and the direction from normal p Subscript to the point normal p prime on the light, and theta Subscript normal o is the angle between the surface normal at normal p prime on the light and the direction from normal p prime to normal p Subscript (Figure 5.17).

Figure 5.17: To compute irradiance at a point normal p Subscript from a quadrilateral source, it’s easier to integrate over the surface area of the source than to integrate over the irregular set of directions that it subtends. The relationship between solid angles and areas given by Equation (5.6) lets us go back and forth between the two approaches.