Chapter 2 Selected Topics on Physically-Based Rendering · CHAPTER 2. SELECTED TOPICS ON...

20
Chapter 2 Selected Topics on Physically-Based Rendering In this chapter we review the fundamental aspects of physically-based rendering that are used throughout this book. Physically-based rendering involves simulating the behavior of light, as it starts from luminaires, i.e., area light sources, then travels through the environment, interacting with different objects, and finally reaching a viewer. Reflectance and transmittance models are used to describe how the light interacts with the objects. These models must satisfy certain physical requirements so that important physical effects are not excluded and the energy consistency needed for global illumination calculations is maintained [207]. These issues are also examined in this chapter. 2.1 Optics Concepts Throughout this book we use the terminology suggested by Meyer-Arendt [147]. In his terminology terms ending in -ion, such as reflection, transmission and absorption, describe a process whereas terms ending in -ivity, such as reflectivity, transmissivity and absorptivity, refer to a general property of a material and terms ending in -ance, such as reflectance, transmittance or absorptance, refer to properties of a given object or surface. Reflection is the process in which light at a specific wavelength incident on a material is propagated outward by the material with a change in direction but not a change in wavelength. Similarly, transmission is the process in which light at a specific wavelength incident on the interface between materials passes through the interface and into the other material without a change in wavelength [75]. Absorption is a general term for the 9

Transcript of Chapter 2 Selected Topics on Physically-Based Rendering · CHAPTER 2. SELECTED TOPICS ON...

  • Chapter 2

    Selected Topics on Physically-Based Rendering

    In this chapter we review the fundamental aspects of physically-basedrendering that are used throughout this book. Physically-based renderinginvolves simulating the behavior of light, as it starts from luminaires,i.e., area light sources, then travels through the environment, interactingwith different objects, and finally reaching a viewer. Reflectance andtransmittance models are used to describe how the light interacts with theobjects. These models must satisfy certain physical requirements so thatimportant physical effects are not excluded and the energy consistencyneeded for global illumination calculations is maintained [207]. Theseissues are also examined in this chapter.

    2.1 Optics Concepts

    Throughout this book we use the terminology suggested by Meyer-Arendt[147]. In his terminology terms ending in -ion, such as reflection,transmission and absorption, describe a process whereas terms endingin -ivity, such as reflectivity, transmissivity and absorptivity, refer toa general property of a material and terms ending in -ance, such asreflectance, transmittance or absorptance, refer to properties of a givenobject or surface.

    Reflection is the process in which light at a specific wavelength incidenton a material is propagated outward by the material with a change indirection but not a change in wavelength. Similarly, transmission is theprocess in which light at a specific wavelength incident on the interfacebetween materials passes through the interface and into the other materialwithout a change in wavelength [75]. Absorption is a general term for the

    9

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 10

    process by which the light incident on a material is converted to anotherform of energy, usually to heat. All of the incident light is accounted forby the processes of reflection, transmission and absorption [6].

    Hall [88] suggested that reflection and transmission can be broken intotwo components, a coherent (or specular) component and an incoherent(or diffuse) component [17]. The coherent component is reflected usingthe law of reflection and transmitted using the law of refraction, which aredescribed later. The incoherent component is reflected and/or transmittedin all directions, and it can be computed using a statistical probabilityfunction associated with surface properties (Section 2.5). It should benoted that most natural materials present a scattering profile intermediate(or mixed) to that expected of diffuse and specular materials (Figure 2.1).

    Figure 2.1: Different forms of light propagation.

    The reflection and transmission (refraction1) of light at the smoothsurfaces of pure materials (i.e., not mixed with any other substance ormaterial) is described by the Fresnel equations [75, 96, 172]. Before gettingto the specifics of these equations, we shall review some relevant physicalparameters, definitions and laws.

    Materials such as conductors (metals), semi-conductors anddielectrics are characterized by their complex index of refraction,N(λ), which is composed of a real and an imaginary term. The real

    1Refraction, or the coherent component of transmission, can be defined as the bending or thechange in the direction of the light rays as they pass from one medium to another [102]. This bendingis determined by the change in the velocity of propagation associated with the different indexes ofrefraction of the media [59].

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 11

    term corresponds to the real index of refraction (refractive index, forshort), which measures how much an electromagnetic wave slows downrelative to its speed in vacuum [75]. The imaginary term corresponds tothe extinction coefficient, which represents how easily an electromagneticwave can penetrate into the medium [75]. The resulting expression forN(λ) is given by:

    N(λ) = η(λ) + jµ(λ) (2.1)

    where:λ = wavelength,η(λ) = real index of refraction as a function of λ,µ(λ) = extinction coefficient as a function of λ,j = imaginary unit (j =

    √−1).

    The extinction coefficient is related to the conductive properties ofthe material, where semi-conductors are materials with a small extinctioncoefficient and dielectrics are essentially non-conductors whose extinctioncoefficient is by definition zero [172]. In the following, most quantitiesmay be made dependent on the wavelength λ. For notational simplicity,however, we will remove the explicit dependency on λ in the remainingequations presented in this section.

    When light hits a smooth surface, the reflection direction, representedby the vector ~r (Figure 2.2), for light incident at an interface is obtainedusing the law of reflection [96]. This states that the angle of the reflectiondirection, θr, is equal to the angle of incidence, θi, and will be in the sameplane as the incident direction, represented by the vector~i, and the surfacenormal, represented by the vector ~n:

    θr = θi (2.2)

    where the angle θi can be obtained using the following equation:

    θi = arccos

    (

    ~n ·~i| ~n ||~i |

    )

    (2.3)

    Considering the geometry described in Figure 2.2 and applying the lawof reflection stated above, the reflection direction, ~r, is given by:

    ~r =~i+ 2~n cos θi =~i− 2~n(~i · ~n) (2.4)

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 12

    cos θi

    cos θt

    ← sin θi →

    θi θr

    θt

    i→

    r→

    m→

    n

    ← →

    ηiηt

    t→

    ← sin θt →

    Figure 2.2: Geometry for light incident at an interface between different materials.

    The transmission (refraction) direction, represented by the vector ~t(Figure 2.2), is obtained using the law of refraction, also known as Snell’slaw [96]:

    ηi sin θi = ηt sin θt (2.5)

    where:ηi = refractive index of the material (medium) of incidence,ηt = refractive index of the transmissive material (medium).

    More specifically, the transmission (refraction) direction ~t is given by:

    ~t = −~n cos θt + ~m sin θt (2.6)

    where:

    ~m = vector perpendicular to ~n and in the same plane as ~i and ~n.

    Equation 2.6 can be expanded to yield the expression presented by

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 13

    Heckbert [97]:

    ~t =

    −ηi

    ηt(~i · ~n)−

    √√√√1−

    (

    ηiηt

    )2 (

    1− (~i · ~n)2)

    ~n+

    ηiηt~i (2.7)

    The incident rays are not only reflected and/or transmitted (refracted)at an interface between dielectrics, but also attenuated. This attenuationis given by the Fresnel coefficients for reflection and transmission(refraction), which are computed from the Fresnel equations. For acomplete derivation of these equations, the reader is referred to the textsby Hecht and Zajac [96] and Glassner [75]. The Fresnel coefficients forreflection of light polarized in directions perpendicular to (R⊥) and parallel(R‖) to an interface are given by the following expressions collected byShirley [172]:

    R⊥ =b21 + b

    22 − 2b1cosθi + cos2θi

    b21 + b22 + 2b1cosθi + cos

    2θi(2.8)

    R‖ = R⊥b21 + b

    22 − 2b1sinθi tanθi + sin2θi tan2θi

    b21 + b22 + 2b1sinθi tanθi + sin

    2θi tan2θi(2.9)

    where b1 and b2 are given by:

    b21 =1

    2η2i

    {√

    (η2t − µ2 − η2i sin2θi)2 + 4η2t µ2 + η2t − µ2 − η2i sin2θi}

    (2.10)

    b22 =1

    2η2i

    {√

    (η2t − µ2 − η2i sin2θi)2 + 4η2t µ2 − (η2t − µ2 − η2i sin2θi)}

    (2.11)

    The Fresnel coefficient for reflection, or reflectivity [147], R, forpolarized light is the weighted sum of the polarized components, in whichthe weights must to sum to unity [75]. In this book we are interestedin the Fresnel coefficients for unpolarized light. In this case, the Fresnelcoefficient for reflection is simply the average of the two coefficients R⊥

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 14

    and R‖. Then, the equation used to compute this coefficient for dielectrics(µ = 0) reduces to following expression:

    R =(η2i − η2t )2c2it + (cos θ2i − cos θ2t )2n2it(cit(η2i + η

    2t ) + nit(cos θ

    2i + cos θ

    2t ))2

    (2.12)

    where:cit = cos θi cos θt,nit = ηiηt.

    An important property of these equations is that they can be appliedwithout regard to the direction of propagation [172], which becomesrelevant when one applies ray tracing methods. To find the Fresnelcoefficient T for transmission (refraction), or transmissivity [147], weobserve that there is no absorption at an interface between dielectrics.Thus, T can be easily obtained from R through a simpler relation:T = 1−R, rather than resorting to an expression similar to Equation 2.12.Incidentally, absorption may occur once light is transmitted into amedium. Absorption of the transmitted light is discussed in Section 2.3.

    2.2 Radiometric Terms and Properties

    In this section the fundamental radiometric terms and their mostimportant properties used throughout the book are described.

    Radiometric terms generally describe measurements of light integratedover all wavelengths and spectral radiometric terms are the samemeasurements evaluated at a specific wavelength λ [75]. For the sakeof simplicity, we will, however, omit the adjective “spectral” in thefollowing definitions and use the same terms for wavelength dependentand wavelength integrated quantities.

    Radiant energy, denoted by Q (measured in joules, J), is a fundamentalquantity representing the energy of a packet of rays. This cannot beapplied directly in a rendering situation. For this case it is assumed thatthere is a steady state of energy flow representing the amount of lighthitting a surface or film plane during a set period of time. This, measuredas radiant power or flux denoted by Φ (measured in Watts, W , or J

    s), is

    therefore often used. Shirley [172] notes that radiant power is convenientto work with because it allows energy balance constraints to be applied,

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 15

    assuming that either the solution is steady state or the speed of light isinfinite. The later assumption is usually appropriate, since the time ittakes light to travel across a typical scene is very small compared to acamera shutter speed or the human temporal visual threshold [172]. Theamount of radiant power traveling from a source in a certain direction,per unit of solid angle2, is called the radiant intensity and denoted by I(measured in W

    sr).

    The underlying purpose of the rendering process is to determine thecolors of the surfaces within an environment. The color of a givensurface will depend on how much light is emitted, reflected, absorbedand transmitted by the surface, but will not depend on the surface area.Hence, it is not convenient to use radiant intensity to approximate color,since this radiometric quantity depends on the area of the light source.As pointed out by Shirley [172], the radiometric quantity that moreclosely approximates the color of a surface, through an indication of itsbrightness3, is the radiance, denoted by L (measured in W

    sr.m2), which is

    not dependent on the size of the object being viewed, nor on the distanceto the viewer. The radiance at a point x of a surface and in a directionψ (usually represented by a pair of spherical coordinates) is denoted byL(x, ψ, λ) and can be expressed as:

    L(x, ψ, λ) =dI(x, ψ, λ)

    dA cosθ=d2Φ(x, ψ, λ)

    d~ω dA cosθ=dM(x, ψ, λ)

    d~ω cosθ(2.13)

    where:dI(x, ψ, λ) = radiant intensity at x and in a direction ψ,dΦ(x, ψ, λ) = radiant power (flux) at x and in a direction ψ,dM(x, ψ, λ) = radiant exitance at x and in a direction ψ,θ = angle between the normal vector and

    the direction ψ,dA = differential area surrounding x,d~ω = differential solid angle at which dΦ arrives at or

    leaves from x.

    The fraction of light at wavelength λ incident from a direction ψi at

    2A solid angle is the three-dimensional analog to the two-dimensional concept of angle [75]. Forexample, the solid angle subtended by an area A on a sphere with radius R is equal to A

    R2. This

    quantity is the measure of the angle in steradians (radians squared), denoted by sr [46].3Brightness can be defined as the attribute by which an area of color of finite size is perceived to

    emit, transmit, or reflect a greater or lesser amount of light [6].

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 16

    a point x that is neither absorbed into nor transmitted through a givensurface is called the reflectance, ρ(x, ψi, λ), of the surface. It representsthe ratio of the reflected flux to the incident flux:

    ρ(x, ψi, λ) =Φr(x, ψ, λ)

    Φi(x, ψi, (λ)(2.14)

    Similarly, the fraction of light transmitted through the surface is calledthe transmittance, τ(x, ψi, λ). It represents the ratio of the transmittedflux to the incident flux:

    τ(x, ψi, λ) =Φt(x, ψ, λ)

    Φi(x, ψi, (λ)(2.15)

    The light that is neither reflected nor transmitted by the surfaceis absorbed. The parameter that describes the amount of absorbedlight is absorptance [6]. The sum of the reflectance, transmittance andabsorptance is one.

    For some applications (Chapter 3) it is more convenient to work witha reflectance factor, R(λ), instead of reflectance. It represents the ratio ofthe reflected flux from a surface to the flux that would have been reflectedby a perfectly diffuse surface in the same circumstances:

    R(x, ψi, λ) =Φr(x, ψ, λ)

    Φpd(x, ψi, λ)(2.16)

    The reflectance and the transmittance do not describe the spatialdistribution of the reflected and transmitted light. The bidirectionalreflectance distribution function (BRDF), fr, and the bidirectionaltransmittance distribution function (BTDF), ft, are used to represent thesespatial distributions. As suggested by Glassner [75], these functions canbe combined into the bidirectional surface-scattering distribution function(BSSDF, or simply BDF [75]). The BDF, f , can be expressed in terms ofthe ratio between the radiance propagated at a point x of a surface in thedirection ψ and the radiant energy (per unit of area and per unit of time)incident from a direction ψi at the point x of the surface:

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 17

    f(x, ψi, ψ, λ) =dL(x, ψ, λ)

    Li(x, ψi, λ) d~ωi cosθi(2.17)

    where:f(x, ψi, ψ, λ) = BDF of the surface at x,dL(x, ψ, λ) = radiance propagated at x and in a direction ψ,Li(x, ψi, λ) = incident radiance at x and in a direction ψi,θi = angle between the surface normal at xi and the

    direction ψi,d~ωi = differential solid angle at which Li arrives at x.

    An important property of the BDF is its symmetry or reciprocitycondition, which is based on Helmholtz Reciprocity Rule4 [43]. Thiscondition states that the BDF for a particular point and incoming andoutgoing directions remains the same if these directions are exchanged(Figure 2.3). It allows, for instance, the “forward” simulation of lightrays traveling from a viewer to a light source, which is used by globalillumination methods such as path tracing [112, 172]. Quantitatively, thiscondition can be expressed as:

    f(x, ψi, ψ, λ) = f(x, ψ, ψi, λ) (2.18)

    ⇔xx

    →n→n

    Figure 2.3: Reciprocity of the BDF.

    Another important property of the BDFs is that they must benormalized, i.e., conserve energy. This means that the total energypropagated in response to some irradiation must be no more than the

    4The original statement of Helmholtz Reciprocity Rule does not include non-specular reflection ofany sort [43, 196]. Veach [196] derived a reciprocity condition for general BDFs using Kirchhoff’s lawsregarding radiative transfer [181].

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 18

    energy received [75]. In other words, for any incoming direction theradiant power propagated over the hemisphere can never be more than theincident radiant power [123]. Any radiant power that is not propagatedis absorbed. Formally, in the case of reflection of light, the so-calleddirectional-hemispherical reflectance [6] should therefore be less than orat most equal to 1:

    ρ(x, ψi, 2π, λ) =∫

    outgoing ψfr(x, ψi, ψ, λ) cos θd~ω ≤ 1, ∀ψi (2.19)

    where:fr(x, ψi, ψ, λ) = BRDF of the surface at x,θ = angle between the surface normal and the

    outgoing direction ψ,d~ω = differential solid angle at which the radiance is

    reflected.

    A similar relation given in terms of the directional-hemisphericaltransmittance [6] and the BTDF is used for the transmission oflight. BRDF and BTDF models, or simply BDF models, that areenergy-conserving and reciprocal are considered physically plausible5. Thisis a crucial requirement for physically-based rendering frameworks aimedat global illumination applications.

    Sometimes, when energy transport or energy balance is of concern asopposed to lighting at a point, it is more convenient to work with theradiant power (radiant flux) [6] than with the radiance [172]. Underthese circumstances, it is more natural to describe the surface reflectionand transmission properties in terms of the probability distribution ofthe reflected and transmitted light. This term is called the scatteringprobability function (SPF) [171, 172]. It describes the amount of energyscattered in each direction ψ, at a point x of a surface and at wavelengthλ as:

    s(x, ψi, ψ, λ) =dI(x, ψ, λ)

    ρ(x, ψi, λ)dΦ(x, ψi, λ)(2.20)

    The term ρ(x, ψi, λ) appears in the numerator when we are dealing withreflection of light. It scales the function to a valid probability densityfunction (PDF) (Section 2.5) over the solid angle through which the

    5Lewis [128, 129] uses the term “plausible” to describe BDF models whose existence does not violatethe laws of physics.

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 19

    reflected light leaves the surface [171, 172]. In the case of transmissionof light, a similar expression is used, in which ρ(x, ψi, λ) is replaced byτ(x, ψi, λ).

    2.3 Absorption in a Homogeneous Medium

    In this section we will focus on the losses affecting the transmittance of ahomogeneous medium, i.e., a material in which the physical propertiesthat affect light propagation are assumed to be identical everywhere.The losses affecting the transmittance of a inhomogeneous medium canbe simulated through successive application of the laws for homogeneousmedium [2]. Another alternative is to think of an inhomogeneous materialas a structure composed of two or more homogeneous layers [168]. Thereader interested in the spectrophotometry regarding the transmittance ofinhomogeneous materials is referred to the text by MacAdam [135].

    The transmittance of a homogeneous material, after correction forsurface losses, varies in accordance with Bouguer’s law (Figure 2.4), alsocalled Lambert’s law of absorption [135]. This law states that the lossdue to the process of absorption is proportional to the power of the lightincident on the medium, to the thickness of the medium (or the distancetraveled by the light in the medium) and to a constant of proportionalitycalled absorptivity [147]. This constant, also known as absorptioncoefficient, is a characteristic of the medium and a function of wavelength.A complete derivation of this law is presented by Meyer-Arendt [147]. Itis usually written as follows:

    τ(λ) =Φt(λ)

    Φi(λ)= e−a(λ) h (2.21)

    where:a(λ) = absorption coefficient of the medium at wavelength λ,h = thickness of the medium,e = Euler’s number (2.718281 · · ·).

    Another law called Beer’s law [132] states that for a dye solutionthe absorption coefficient of the solution is directly proportional to itsconcentration. Combining Beer’s law with Bouguer’s law [135] for samplesof thickness h and concentration c results in the following expression forthe transmittance of a homogeneous material:

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 20

    τ(λ) = e−a(λ) c h (2.22)

    where:c = concentration of the solution.

    ← h →

    Φi(λ) Φt(λ)

    Figure 2.4: Loss of light at wavelength λ in a medium of thickness h.

    Sometimes it is more convenient to specify the absorption of luminousenergy by a medium by means of the extinction coefficient [132, 156], µ,which can be expressed as:

    µ =a(λ)λ

    4π(2.23)

    2.4 Rendering Equation

    Three major global illumination approaches have been used in renderingto simulate the light transfer mechanisms: ray tracing, radiosity andhybrid methods. Kajiya [112] unified the discussion of global illuminationmethods with the rendering equation. This equation, also known astransport equation, can be expressed in terms of radiances (Equation 2.24)on the basis of the ray law (the radiance is constant along a line of sightbetween objects [172]), and the definition of the BDF. In a simplified formit is given by:

    L(x, ψ, λ)︸ ︷︷ ︸

    total

    = Le(x, ψ, λ)︸ ︷︷ ︸

    emitted

    +Lp(x, ψ, λ)︸ ︷︷ ︸

    propagated

    (2.24)

    Equation 2.24 states that the radiance of a point x on a surface, in adirection ψ and at wavelength λ is given by the sum of the emitted radiancecomponent, Le, and the propagated radiance component, Lp. Usually Le

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 21

    is known from the input data, and the computation of Lp constitutes themajor computational problem.

    x

    xj

    Liθi

    θj dAj

    Lp

    dA

    →n

    →nj

    Figure 2.5: Geometry for computing Lp as an integral over all the surfaces within theenvironment.

    The term Lp can be written as an integral over all the surfaces withinthe environment (Figure 2.5), resulting in the formulation presented inthe following equation:

    Lp(x, ψ, λ) =∫

    all xjf(x, ψ, ψi, λ)Li(x, ψi, λ) cos θi V (x, xj)

    cosθjdAj‖xj − x‖2

    (2.25)where:θi = angle between the surface normal at x and

    the direction ψi,θj = angle between the surface normal at xj and

    the direction ψi,dAj = differential area surrounding xj,V (x, xj) = visibility term.

    The visibility term V (x, xj) used in the Equation 2.25 is one if a pointxj of a certain surface can “see” a point x of another surface, and zero

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 22

    otherwise. This equation is commonly used by deterministic renderingmethods based on standard numerical techniques [123]. In the context ofglobal illumination these techniques are used to solve the multiple integralsand linear systems of equations resulting form these when applying theradiosity method [46].

    Alternatively, Lp can also be expressed in terms of all directions visibleto x (Figure 2.6) [172]. This expression for Lp is more suitable tonondeterministic rendering methods based on Monte Carlo techniques [91],and it is given by:

    Lp(x, ψ, λ) =∫

    incoming ψif(x, ψ, ψi, λ)Li(x, ψi, λ) cos θid~ωi (2.26)

    where:θi = angle between the surface normal at x and

    the direction ψi,d~ωi = differential solid angle where Li arrives.

    x

    →n

    Li

    θidωi

    Lp

    Figure 2.6: Geometry for computing Lp in terms of all directions visible to a point x.

    2.5 Monte Carlo Techniques for Directional Sampling

    Monte Carlo based algorithms are intuitive and capable of handlecomplex geometries. Although they are relatively expensive due totheir statistical nature, which requires that many photon histories tobe traced to obtain asymptotically convergent results, their reliabilitymakes them a premier choice for the implementation and evaluation of

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 23

    physically-based systems. In this section we outline some Monte Carlodefinitions and techniques are outlined. A concise derivation of warpingfunctions used in the particular application of the Monte Carlo methodto physically-based rendering is also presented. The material presentedin this section have been extensively examined by computer graphicsresearchers [75, 123, 124, 129, 172], but it differs from previous reviewsby being oriented to scattering simulations and by providing derivationdetails frequently omitted in computer graphics papers. For a morecomprehensive treatment of Monte Carlo methods the reader is referredto classic Monte Carlo texts [91, 113, 136].

    2.5.1 Importance Sampling and Warping Transformations

    The integral term of the rendering equation (Section 2.4) can be estimatedusing Monte Carlo techniques. Among these techniques one can highlightimportance sampling [91]. The idea behind this technique is simple. Ifthe integrand is a product of two functions, and we know one of them,we can use this information to guide our sampling strategy. Usually areasthat contribute more (large values) or vary more quickly will have moreimportance and will be sampled more densely. In this case we need tocompensate for the non-uniform sampling to avoid the introduction ofbias6 in the final result.

    Suppose that we need to determine Θ given by the following integralinvolving a real-valued function u:

    Θ =∫

    u(x) dx =∫u(x)

    Γ(x)Γ(x) dx (2.27)

    where Γ(x) represents the importance (real-valued) function, also calledthe probability density function (PDF) [91], which satisfies the followingconditions [113, 123]:

    • Γ(x) ≥ 0 for each x ∈ [0, 1] for which f(x) 6= 0,• ∫ 10 Γ(x) dx = 1,

    • u(x)Γ(x)

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 24

    • draw samples from u, attach weights given by Γ and sum them, or• draw samples ξi with the density given by Γ, evaluate u(ξi) and sum

    them.

    In this section we focus on the second alternative. In order to applyit, one often uses a technique called warping [75, 172]. This techniqueconsists of generating uniform distributed samples in a canonical space,and, afterwards, deform that space to match the desired density given byΓ.

    The key aspect of any importance sampling application is the selectionof the PDF. For example, for the problem represented by Equation 2.27,an optimal PDF Γ(x) would be given by Γ(x) = Cu(x), with the constantC represented by 1

    Θ! Clearly this is not an option, since, if we already

    knew Θ, we would not need to use Monte Carlo techniques to estimateit. The practical solution is to choose a function Γ̃(x) “close” to Γ(x). Wewill examine this aspect in more detail in the next sections.

    2.5.2 Probability Density Functions

    For the sake of simplicity, since transmission is usually handled verysimilarly to reflection, we will focus on the BRDF (fr) in the followingpresentation implicitly including the BTDF by analogy.

    In order to solve the rendering equation using importance sampling, oneusually resorts to stochastic ray tracing, in which new scattering directionshave to be sampled recursively at each intersection point such that:

    Lr(x, ψ) = Le(x, ψ) +fr(x, ψ, ψi)Le(x

    ′, ψ′) +fr(x, ψ, ψi)fr(x

    ′, ψ′, ψ′i)Le(x′′, ψ′′) + ...

    (2.28)

    where:Lr = reflected radiance.

    In a path tracing implementation of Equation 2.28, for example, thexn is chosen by sending a ray from xn−1 in the direction −ψn−1, and ψn−1is chosen according to a PDF based on the BRDF of the surfaces of theenvironment. Ideally, to choose reflected ray directions for radiosity [173]or stochastic ray tracing [112] calculations, one should be able to sample

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 25

    according to the following PDF:

    Γ(ψ) =fr(x, ψi, ψ) cosθi

    Ω fr(x, ψi, ψ) cosθidωi(2.29)

    where:Ω = hemisphere,dωi = differential solid angle around ψi,cosθi = cosine of the angle between ψi and the normal at x.

    In practice one often has to use an approximating PDF. Before gettingto the specifics of the PDFs presented in this section, it is relevantto examine more closely a BRDF which constitutes the basis for thederivation of a number of PDFs frequently used in rendering applications,specially those involving the simulation of non-Lambertian phenomena.The formulation of this BRDF is based on a modified version of the Phongmodel [124, 128].

    The original Phong model [157] does not have a physical basis andcannot be used as a BRDF in physically-based rendering applications.Immel et al. [103] has suggested a Phong-like BRDF, however, which waslater constrained by Lewis [129] to become physically plausible and usedin rendering applications. This BRDF is given by:

    fr(x, ψi, ψ) =ρdSd

    +ρsSs

    cosnαb (2.30)

    where:αb = angle between the halfway vector (between the source

    and viewing directions) and the normal,ρd = the diffuse reflectance,ρs = the specular reflectance,n = the specular exponent,Sd and Ss = constant factors included to conserve energy.

    Recall that in order to conserve energy (Section 2.2) the followingrelation has to be satisfied:

    ρ(x, ψ) =∫

    Ωfr(x, ψi, ψ) cosα dω ≤ 1 ∀x, ψi (2.31)

    with the differential solid angle given by:

    dω = sinα dα dβ (2.32)

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 26

    where:α = polar angle (α ∈ [0, π

    2] for the upper hemisphere),

    β = azimuthal angle (β ∈ [0, 2π]).

    Using Equation 2.31, the constant factor Sd is given by:

    Sd =∫

    Ω cosα dω =∫ 2πβ=0

    ∫ π2

    α=0 cosα sinα dα dβ

    = − ∫ 2πβ=0∫ π

    2

    α=0 cosα dcosα dβ

    = −2π[ cos2α2

    ]π2

    0 = π

    (2.33)

    and the constant factor Ss is given by:

    Ss =∫

    Ω cosn+1α dω =

    ∫ 2πβ=0

    ∫ π2

    α=0 cosn+1α sinα dα dβ

    = − ∫ 2πβ=0[−cosn+1α

    n+2]

    π2

    0 dβ

    = 1n+2

    ∫ 2πβ=0 dβ

    = 2πn+2

    (2.34)

    Replacing Sd and Ss in Equation 2.30 [124] gives:

    fr(x, ψi, ψ) =ρdπ

    + ρsn+ 2

    2πcosnαb (2.35)

    Usually specular directions are sampled according to the following PDFbased on the specular component of Equation 2.35 [172]:

    Γ(α, β) =n+ 1

    2πcosnα (2.36)

    Diffuse directions, on the other hand, are commonly sampled using thefollowing PDF [124, 172]:

    Γ(α, β) =1

    πcosα (2.37)

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 27

    Another PDF based on the specular component of Equation 2.35 wasproposed by Shirley and Wang [179], and it is given by:

    Γ(αp, βp) =n+ 2

    8πcosn

    (αp2

    )

    (2.38)

    where:αp = angle between the reflection direction and the outgoing

    direction,βp = azimuthal angle around the reflection direction.

    2.5.3 Warping Functions

    As pointed out by Lafortune and Willems [124], the space of directionsin a three-dimensional space is two-dimensional. Consequently, the PDFspresented in the previous section can be sampled by selecting two uniformstochastic variables, ξ1 and ξ2, over the interval [0,1], and transformingthem using the warping technique mentioned in Section 2.5.1. In thissection we present the derivation of the warping functions used in themodels described in this book (Chapters 7 and 8), which correspond tothe PDFs described by Equations 2.36 and 2.37.

    Before presenting the derivations, we shall briefly review some relevantconcepts. If a random variable ξ ranges over some region

  • CHAPTER 2. SELECTED TOPICS ON PHYSICALLY-BASED RENDERING 28

    function used to generate the corresponding scattered directions [172].Solving Equation 2.40 in the dimension associated with α results in:

    ∫ α

    0

    n+ 1

    2πcosnα′ sinα′ dα′ =

    [

    −n + 1n + 1

    cosn+1α′]α

    0= −cosn+1α + 1

    (2.41)then we have:

    ξ1 = −cosn+1α + 1 (2.42)or:

    α = arccos(1− ξ1)1

    n+1 (2.43)

    Solving for the dimension associated with β gives:∫ β

    0

    1

    2πdβ ′ =

    β

    2π(2.44)

    from which we get:

    ξ2 =β

    2π(2.45)

    or:β = 2πξ2 (2.46)

    Therefore, the corresponding warping function is represented by:

    (α, β) = (arccos(1− ξ1)1

    n+1 , 2πξ2) (2.47)

    where:ξ1 and ξ2 = uniformly distributed random numbers ∈ [0, 1].

    Finally, consider the PDF given by Equation 2.37. Then thecorresponding cumulative density function is given by:

    P(α, β) =∫ β

    0

    ∫ α

    0

    cosα′

    πsinα′ dα′ dβ ′ (2.48)

    As in the previous case, the PDF presented in the integrand ofEquation 2.48 is separable, and derivation techniques can be appliedon each dimension to find the warping function used to generated thecorresponding scattered directions. Thus, solving Equation 2.48 in thedimension associated with α results in:

    ∫ α

    02 cosα′ sinα′ dα′ = 2

    [

    −cos2α′

    2

    0

    = −cos2α + 1 (2.49)