advanced global illumination brian chen thursday, february 12, 2004
Post on 20-Dec-2015
216 views
TRANSCRIPT
Advanced Global Advanced Global IlluminationIllumination
Brian ChenBrian Chen
Thursday, February 12, 2004Thursday, February 12, 2004
Physical Simulation Physical Simulation of Light Transport:of Light Transport:
AccuracyAccuracyaccount for ALL light pathsaccount for ALL light pathsconservation of energyconservation of energyPredictionPredictionforward renderingforward renderingcalculate light meter readingscalculate light meter readingsAnalysisAnalysisinverse renderinginverse rendering! find surface properties !! find surface properties !Realism?Realism?perceptually necessary?perceptually necessary?
Global IlluminationGlobal Illumination
Global IlluminationGlobal Illumination ““Everything is lit by Everything is lit by Everything ElseEverything Else””
Screen color = Screen color = entire scene’s lightingentire scene’s lighting * surface reflectance * surface reflectance Refinements: Models of area light sources, caustics, Refinements: Models of area light sources, caustics,
soft-shadowing, fog/smoke, photometric calibration, … soft-shadowing, fog/smoke, photometric calibration, …
H. Rushmeier et al., SIGGRAPH`98 Course 05 “A Basic Guide to Global Illumination”H. Rushmeier et al., SIGGRAPH`98 Course 05 “A Basic Guide to Global Illumination”
OverviewOverview
Physics (Optics) conceptsPhysics (Optics) concepts Models of LightModels of Light RadiometryRadiometry BRDFs & Rendering EquationBRDFs & Rendering Equation Monte Carlo MethodsMonte Carlo Methods Photon MappingPhoton Mapping
Optics DefinitionsOptics Definitions Reflection – when light bounces off a surfaceReflection – when light bounces off a surface
Refraction – the bending of light when it goes Refraction – the bending of light when it goes through different mediums (ex. air and glass)through different mediums (ex. air and glass)
Diffraction – the phenomenon where light Diffraction – the phenomenon where light “bends” around obstructing objects“bends” around obstructing objects
Dispersion – when white light splits into its Dispersion – when white light splits into its components colors, result of refractioncomponents colors, result of refraction
Light’s Dual NatureLight’s Dual Nature
Is light a wave? Or is it a beam of particles?Is light a wave? Or is it a beam of particles?
Wave Theory of Light – Thomas Young’s Wave Theory of Light – Thomas Young’s double-slit experimentdouble-slit experiment
Particle Theory of Light – Newton, refraction Particle Theory of Light – Newton, refraction & dispersion& dispersion
Light ModelsLight Models
Models of light are used to capture/explain the Models of light are used to capture/explain the different behaviors of light that stem from its different behaviors of light that stem from its dual naturedual nature
Quantum OpticsQuantum Optics Wave ModelWave Model Geometric OpticsGeometric Optics
Quantum OpticsQuantum Optics
Explains dual wave-particle nature at the Explains dual wave-particle nature at the submicroscopic level of electronssubmicroscopic level of electrons
Way too detailed for purposes of image Way too detailed for purposes of image generation for computer graphics scenesgeneration for computer graphics scenes
Therefore, it is not usedTherefore, it is not used
Wave ModelWave Model
Simplification of Quantum ModelSimplification of Quantum Model Captures effects that occur when light interacts Captures effects that occur when light interacts
with objects of size comparable to the with objects of size comparable to the wavelength of light (diffraction, polarization)wavelength of light (diffraction, polarization)
This model is also ignored, too complex and This model is also ignored, too complex and detaileddetailed
Geometric OpticsGeometric Optics
Simplest and most commonly used light modelSimplest and most commonly used light model Assumes light is emitted, reflected, and Assumes light is emitted, reflected, and
transmitted (refraction)transmitted (refraction) Also assumes:Also assumes:
Light travels in straight lines, no diffractionLight travels in straight lines, no diffraction Light travels instantaneously through a medium Light travels instantaneously through a medium
(travels at infinite speed)(travels at infinite speed) Light is not influenced by gravity, magnetic fieldsLight is not influenced by gravity, magnetic fields
RadiometryRadiometry
Radiometry – area of study involved in the Radiometry – area of study involved in the physical measurement of lightphysical measurement of light
Goal of illumination algorithm is to compute Goal of illumination algorithm is to compute the steady-state distribution of light energy in the steady-state distribution of light energy in a scenea scene
Radiometric QuantitiesRadiometric Quantities
Radiant Power Radiant Power flux (in Watts = Joule/sec), flux (in Watts = Joule/sec), ΦΦ How much total energy flows from/to/through a How much total energy flows from/to/through a
surface per unit timesurface per unit time Irradiance (“ear”)Irradiance (“ear”)
incoming radiant power on a surface per unit incoming radiant power on a surface per unit surface area (Watt/msurface area (Watt/m22))
E = dE = dΦΦ/dA/dA
More Radiometric QuantitiesMore Radiometric Quantities
RadiosityRadiosity Outgoing radiant power per unit surface area Outgoing radiant power per unit surface area
(Watt/m(Watt/m22)) B = dB = dΦΦ/dA/dA
RadianceRadiance Flux per unit projected area per unit solid Flux per unit projected area per unit solid
angle (W/(steradian x angle (W/(steradian x mm22)))) How much power arrives at (or leaves from) a How much power arrives at (or leaves from) a
certain point on a surface, per unit solid angle, certain point on a surface, per unit solid angle, and per unit projected areaand per unit projected area
L(x, L(x, ӨӨ) = d) = d22ΦΦ / (d / (dωω dA cos dA cosӨӨ)) The most important quantity in global The most important quantity in global
illumination because it captures the illumination because it captures the “appearance” of objects“appearance” of objects
Radiance cont’dRadiance cont’d
Radiance: Radiance: The Pointwise Measure of LightThe Pointwise Measure of Light Free-space light power Free-space light power LL ==(energy/time) ==(energy/time)
At At leastleast a 5D scalar function: a 5D scalar function: L(x, y, z, L(x, y, z, , , , …), …) Position (x,y,z), Angle (Position (x,y,z), Angle (,,) and more (t, ) and more (t, , …) , …) Power density units, but tricky…Power density units, but tricky…
SolidAnglereaProjectedAtime
energyL
**
Taken with permission from Jack Tumblin
Yet More RadianceYet More RadianceTricky: think Hemispheres Tricky: think Hemispheres
with a floor:with a floor:
Solid AngleSolid Angle (steradians) (steradians)=d=dωω = fraction of a = fraction of ahemisphere’s area (4hemisphere’s area (4))
dAdA
Projected AreaProjected Area
cos cos dA dA
SolidAnglereaProjectedAtime
energyL
**
Taken with permission from Jack Tumblin
Properties of RadianceProperties of Radiance 1: Radiance is invariant along straight paths and does 1: Radiance is invariant along straight paths and does
not attenuate with distancenot attenuate with distance Radiance leaving point x directed towards point y is equal Radiance leaving point x directed towards point y is equal
to the radiance arriving at point y from the point xto the radiance arriving at point y from the point x 2: Sensors, such as cameras and human eye, are 2: Sensors, such as cameras and human eye, are
sensitive to radiancesensitive to radiance The response of our eyes is proportional to the radiance The response of our eyes is proportional to the radiance
incident upon them.incident upon them. It is now clear that radiance is the quantity that global It is now clear that radiance is the quantity that global
illumination algorithms must compute and display to the illumination algorithms must compute and display to the observerobserver
BRDF (Bidirectional Reflectance BRDF (Bidirectional Reflectance Distribution Function)Distribution Function)
Intuitively the BRDF represents, for each Intuitively the BRDF represents, for each incoming angle, the amount of light that is incoming angle, the amount of light that is scattered in each outgoing anglescattered in each outgoing angle
BRDF at a point x is defined as the ratio of the BRDF at a point x is defined as the ratio of the radiance reflected in an exitant direction (radiance reflected in an exitant direction (ӨӨ), ), and the irradiance incident in a differential and the irradiance incident in a differential solid angle (solid angle (ΨΨ).).
ffrr(x,(x,ΨΨ->->ӨӨ) = dL(x->) = dL(x->ӨӨ) / (L(x<-) / (L(x<-ΨΨ)cos(N)cos(Nxx,,ΨΨ)d)dωωΨΨ)) cos(Ncos(Nxx,,ΨΨ) = cos of angle formed by normal & ) = cos of angle formed by normal &
incident direction vectorincident direction vector
Point-wise Reflectance: Point-wise Reflectance: BRDFBRDFBBidirectional idirectional RReflectance eflectance DDistribution istribution FFunctionunction
((i i , , i i , , r r , , r r , , i i , , r , …r , … )) == (L == (Lrr / L / Lii) ) a scalar (sra scalar (sr-1-1))
Illuminant Illuminant LLii
Reflected Reflected LLrr
InfinitesimalInfinitesimalSolid AngleSolid Angle
BRDF PropertiesBRDF Properties
Value of BRDF remains unchanged if the Value of BRDF remains unchanged if the incident and outgoing directions are incident and outgoing directions are interchangedinterchanged
Law of conservation of energy requires that Law of conservation of energy requires that the total amount of power reflected all the total amount of power reflected all directions must be less than or equal to the directions must be less than or equal to the total amount of power incident on the surfacetotal amount of power incident on the surface
BRDF Examples, DiffuseBRDF Examples, Diffuse
Andrew Glassner et al.. SIGGRAPH`94 Course 18:Andrew Glassner et al.. SIGGRAPH`94 Course 18:““Fundamentals and Overview of Computer Graphics”Fundamentals and Overview of Computer Graphics”
Fr = (x,ΨΨ<-><->ӨӨ) = ) = ρρdd//ππ, constant, constant
ρρdd is the fraction of incident energy that is reflected at a is the fraction of incident energy that is reflected at a
surface, 0-1surface, 0-1
BRDF Examples, SpecularBRDF Examples, Specular
Andrew Glassner et al.. SIGGRAPH`94 Course 18:Andrew Glassner et al.. SIGGRAPH`94 Course 18:““Fundamentals and Overview of Computer Graphics”Fundamentals and Overview of Computer Graphics”
Exitant direction:
R = 2(N dot ΨΨ)N – )N – ΨΨ
For Most SurfacesFor Most Surfaces
Andrew Glassner et al.. SIGGRAPH`94 Course 18:Andrew Glassner et al.. SIGGRAPH`94 Course 18:““Fundamentals and Overview of Computer Graphics”Fundamentals and Overview of Computer Graphics”
Most Materials:Most Materials:Combination ofCombination ofDiffuse & Diffuse & Specular…their Specular…their BRDF is difficult BRDF is difficult to model with to model with formulasformulas
Practical Shading Models (BRDF)Practical Shading Models (BRDF)
Lambert: kLambert: kdd = = ρρd/d/ππ
Phong: fr = kPhong: fr = kss*((R*((R··ӨӨnn)/(N)/(N··ΨΨ)) + k)) + kdd
Blinn-Phong = kBlinn-Phong = kss*((N*((N·H·H)/(N)/(N··ΨΨ)) + k)) + kdd, ,
H=halfway vector between H=halfway vector between ΨΨ & & ӨӨ Modified Blinn-Phong = kModified Blinn-Phong = kss*(N*(N·H)·H)nn + + kkdd Cook-TorranceCook-Torrance WardWard
Lambert BRDFLambert BRDF
Phong BRDFPhong BRDF
Blinn-Phong BRDFBlinn-Phong BRDF
Ward Anisotropic BRDFWard Anisotropic BRDF
Rendering EquationRendering EquationFinally! Putting radiance and the BRDF together to get:
BRDF & Rendering Eq.BRDF & Rendering Eq. For example, suppose that we wish to For example, suppose that we wish to
determine the illumination of a scene determine the illumination of a scene containing containing nn light sources – light source 1 to light sources – light source 1 to light source light source nn. In this case, the local . In this case, the local illumination of a surface is given by,illumination of a surface is given by,
where where LijLij is the intensity of the jth light source is the intensity of the jth light source and and wijwij = ( = (ij,ij,ijij) is the direction to the jth ) is the direction to the jth light source. light source.
n
j
ji
jioo
ji
jio LBRDFL
1
cos),,,(
BRDF & Rendering Eq.BRDF & Rendering Eq.
For a single point light source, the light For a single point light source, the light reflected in the direction of an observer isreflected in the direction of an observer is
This is the general BRDF lighting equation for This is the general BRDF lighting equation for a single point light source a single point light source
iiooiio LBRDFL cos),,,(
Rendering EquationRendering EquationOpportunitiesOpportunities Scalar operations only: Scalar operations only: ()() and and L()L(), indep. of , indep. of , x,y,z, , x,y,z, ,, … … Linearity: Linearity:
Solution = weighted sum of one-light solns.Solution = weighted sum of one-light solns. Many BRDFs Many BRDFs weighted sum of diffuse, specular, gloss terms weighted sum of diffuse, specular, gloss terms
DifficultiesDifficulties Almost Almost nono nontrivial analytic solutions exist; nontrivial analytic solutions exist;
MUST use approximate methods to solveMUST use approximate methods to solve Verification: tough to measure real-world Verification: tough to measure real-world ()() and and L() L() wellwell Notable wavelength-dependent surfaces exist Notable wavelength-dependent surfaces exist
(iridescent insect wings & casing, CD grooves, oil)(iridescent insect wings & casing, CD grooves, oil) BRDF doesn’t capture important subsurface scatteringBRDF doesn’t capture important subsurface scattering
Review 1Review 1Big Ideas:Big Ideas:
Measure Light: RadianceRadiance
Measure Light Attenuation: : BRDFBRDF
Light will ‘bounce around’ endlessly, decaying on each bounce: The Rendering Equation The Rendering Equation (intractable: must approximate)(intractable: must approximate)
Monte Carlo TechniquesMonte Carlo Techniques
Mathematical techniques that use statistical Mathematical techniques that use statistical sampling to simulate phenomena or evaluate sampling to simulate phenomena or evaluate values of functionsvalues of functions
Use a probability distribution function (PDF) Use a probability distribution function (PDF) to generate random samples, p(x)to generate random samples, p(x)
EstimatorsEstimators
Unbiased – when the expected value of the Unbiased – when the expected value of the estimator is exactly the value of the integralestimator is exactly the value of the integral
Biased – when the above property is not trueBiased – when the above property is not true Bias – the difference between the expected Bias – the difference between the expected
value of the estimator and the actual value of value of the estimator and the actual value of the integralthe integral
As number of samples N increases, the As number of samples N increases, the estimate becomes closer estimate becomes closer
Monte Carlo TechniquesMonte Carlo Techniques
The reliability of Monte-Carlo sampling is The reliability of Monte-Carlo sampling is measured by the variance of the estimators. measured by the variance of the estimators. The variance of the estimators is given as The variance of the estimators is given as
where is the primary estimator, while its where is the primary estimator, while its average is a secondary estimatoraverage is a secondary estimator
Monte Carlo TechniquesMonte Carlo Techniques
As a consequence of the above formula, the Monte-As a consequence of the above formula, the Monte-Carlo technique requires a large number of samples to Carlo technique requires a large number of samples to reduce the variance of the primary estimator reduce the variance of the primary estimator
The error of the approximation is itself The error of the approximation is itself a random variable with zero mean, i.e. the estimator a random variable with zero mean, i.e. the estimator is unbiased. The standard deviation of this estimator is unbiased. The standard deviation of this estimator is reduced only proportional to which is known is reduced only proportional to which is known as the as the diminishing returndiminishing return of the Monte-Carlo of the Monte-Carlo technique, i.e. the number of samples must be technique, i.e. the number of samples must be quadrupled to reduce the standard deviation by one quadrupled to reduce the standard deviation by one half. half.
Monte Carlo TechniquesMonte Carlo Techniques
For importance sampling we adjust the pdf For importance sampling we adjust the pdf pp to be to be similar in shape to the integrand similar in shape to the integrand ff. If we were able to . If we were able to choose choose pp((xx)= )= CfCf((xx), with a constant factor ), with a constant factor CC= 1/= 1/II, the , the variance of the primary estimator would be zero and a variance of the primary estimator would be zero and a single sample would always give the correct result. single sample would always give the correct result.
Unfortunately, the constant C is determined by the Unfortunately, the constant C is determined by the integral we want to compute and is therefore integral we want to compute and is therefore unavailable. On the other hand, some a priori unavailable. On the other hand, some a priori knowledge about the shape of knowledge about the shape of ff is often available and is often available and can be used to adjust can be used to adjust pp to reduce the variance of the to reduce the variance of the estimators. estimators.
Monte Carlo ExampleMonte Carlo Example
Computing a one-dimensional integralComputing a one-dimensional integral Samples are selected randomly over the domain of Samples are selected randomly over the domain of
the integral to get a close approximation (estimator the integral to get a close approximation (estimator <I><I>
<I> = (1/N) <I> = (1/N) ΣΣ f(xi) / p(xi) f(xi) / p(xi)
Another ExampleAnother Example
Integration over a hemisphereIntegration over a hemisphere Estimate the radiance at a point by integrating the Estimate the radiance at a point by integrating the
contribution of light sources in the scenecontribution of light sources in the scene Light source LLight source L
I = I = ∫∫LLsourcesourcecoscosddωω = = ∫∫0022ππ ∫ ∫0 0
ππ/2 /2 LLsourcesourcecoscossinsinddddφφ
<I>=(1/N)<I>=(1/N)Σ Σ ((LLsourcesource((ωωii) cos) cossinsin) / p() / p(ωωii))
p(p(ωωii) = cos) = cossinsin/ / ππ
<I>=(1/N)<I>=(1/N)Σ Σ LLsourcesource((ωωii))
StepsSteps General:General:
Sampling according to a probability distribution functionSampling according to a probability distribution function Evaluation of the function at that sampleEvaluation of the function at that sample Averaging these appropriately weighted sampled valuesAveraging these appropriately weighted sampled values
Graphics:Graphics: Generate random photon paths from source (lights or Generate random photon paths from source (lights or
pixels)pixels) Set a discrete random length for the pathSet a discrete random length for the path Count how many photons terminate in state i, average Count how many photons terminate in state i, average
radiances for that pointradiances for that point
http://graphics.stanford.edu/courses/cs348b-02/lectures/lecture15/walk014.html
http://graphics.stanford.edu/courses/cs348b-02/lectures/lecture15/walk014.html
Advantages/DisadvantagesAdvantages/Disadvantages
AdvantagesAdvantages Simple: just sample signal/function and average estimatesSimple: just sample signal/function and average estimates Widely applicable: nuclear physics, graphics, high-Widely applicable: nuclear physics, graphics, high-
dimensional integrations of complicated functionsdimensional integrations of complicated functions Can be used with radiosityCan be used with radiosity
DisadvantagesDisadvantages Very slow, take many, many samples to converge to Very slow, take many, many samples to converge to
correct solutioncorrect solution Need 4x samples to decrease error by halfNeed 4x samples to decrease error by half
Monte Carlo ImagesMonte Carlo Images
Monte Carlo ImagesMonte Carlo Images
Photon MappingPhoton Mapping
One of the “fastest” algorithms available for One of the “fastest” algorithms available for global illuminationglobal illumination
Monte-Carlo basedMonte-Carlo based 2-pass algorithm 2-pass algorithm
Photon Mapping, 1Photon Mapping, 1stst pass pass 1st pass1st pass
photons shot from the light into the scenephotons shot from the light into the scene they bounce around interacting with all the types of they bounce around interacting with all the types of
surfaces they encountersurfaces they encounter Clever twistsClever twists
11stst, instead of redoing those same computations over and over, a , instead of redoing those same computations over and over, a few thousand of time for each pixels, the photons are stored only few thousand of time for each pixels, the photons are stored only once in a special data structure called a photon map for later reuseonce in a special data structure called a photon map for later reuse
22ndnd, instead of trying to completely fill the whole scene with , instead of trying to completely fill the whole scene with billions of photons, a few thousands to a million photons are billions of photons, a few thousands to a million photons are sparsely stored and the rest is statistically estimated from the sparsely stored and the rest is statistically estimated from the density of the stored photons.density of the stored photons.
After all the photons have been stored in the map, a After all the photons have been stored in the map, a statistical estimate of the irradiance at each photon statistical estimate of the irradiance at each photon position is computed.position is computed.
Photon Mapping, 2Photon Mapping, 2ndnd Pass Pass
Direct illumination is computed just like Direct illumination is computed just like regular ray tracing, but the indirect regular ray tracing, but the indirect illumination, which comes from the walls and illumination, which comes from the walls and other objects around, is computed from other objects around, is computed from querying the stored photons in the photon mapquerying the stored photons in the photon map
At each secondary hit, the photon map is At each secondary hit, the photon map is queried in order to gather the radiance coming queried in order to gather the radiance coming from the objects around in the environment.from the objects around in the environment.
Photon Mapping ImagesPhoton Mapping Images
SummarySummary
Global illumination’s goal is to calculate the steady-Global illumination’s goal is to calculate the steady-state distribution of light energy in a scenestate distribution of light energy in a scene
BRDFs used to calculate reflection radiancesBRDFs used to calculate reflection radiances Rendering Equation used to calculate the radiance Rendering Equation used to calculate the radiance
sent out from an objectsent out from an object Monte-Carlo techniques used to calculate irradiance Monte-Carlo techniques used to calculate irradiance
at random locations throughout sceneat random locations throughout scene Photon Maps used to accurately calculate caustics, Photon Maps used to accurately calculate caustics,
inter-object reflectionsinter-object reflections