CSL 859: CSL 859: Advanced Advanced Computer Computer Graphics Graphics Dept of Computer Sc. & Dept of Computer Sc. & Engg. Engg. IIT Delhi IIT Delhi
Mar 18, 2016
CSL 859: CSL 859: Advanced Advanced Computer Computer GraphicsGraphicsDept of Computer Sc. & Engg.Dept of Computer Sc. & Engg.
IIT DelhiIIT Delhi
Tracing RaysTracing Rays
Trace many more rays
Tracing RaysTracing Rays
Not just in the ideal specular directions
Tracing RaysTracing Rays
Could distribute rays based on surface property
Rendering EquationRendering Equation The total light leaving a point =The total light leaving a point =
Exitance from the point +Exitance from the point + Incoming light from other sources Incoming light from other sources
reflected at the pointreflected at the point
dLLL iooooeoo cos),,(),,,(),,(),,( xxx x
Light
leaving
Exitance Sum BRDF Incoming
light
Incoming light reflected at the point
Photorealistic LightingPhotorealistic Lighting Solve the equationSolve the equation
To compute light leaving x, need to find To compute light leaving x, need to find how much light reaches ithow much light reaches it
To find how much light reaches x, need to To find how much light reaches x, need to compute light leaves every other pointcompute light leaves every other point
Hard because BRDFs are high Hard because BRDFs are high dimensionaldimensional
But some light interaction in the scene is But some light interaction in the scene is diffuseddiffused
View angle independentView angle independent
Global IlluminationGlobal Illumination Traditional Raytracing only considers Traditional Raytracing only considers
specular reflectionsspecular reflections Does not account for (indirect) diffused Does not account for (indirect) diffused
reflections reaching eyereflections reaching eye Need to “trace” those rays alsoNeed to “trace” those rays also
Stochastic methodsStochastic methods Monte Carlo techniques to solve rendering Monte Carlo techniques to solve rendering
equationequation Separate diffused and specular reflectionSeparate diffused and specular reflection
RadiosityRadiosity
Radiosity AssumptionsRadiosity Assumptions All surfaces are perfectly diffuseAll surfaces are perfectly diffuse Illumination is Illumination is constantconstant over a over a patchpatch
Subdivide triangles into small patchesSubdivide triangles into small patches Problems at sharp illumination boundaries, Problems at sharp illumination boundaries,
e.g., shadowse.g., shadows Less space/time efficient solutionsLess space/time efficient solutions Discontinuity meshingDiscontinuity meshing
Can be pre-computedCan be pre-computed With view-dependent illumination With view-dependent illumination
computed and added latercomputed and added later
Radiosity ExampleRadiosity Example Extreme color Extreme color
bleeding herebleeding here Textures are post Textures are post
illuminationillumination Notice meshing Notice meshing
artifacts like the artifacts like the banding around the banding around the pictures on the wallpictures on the wall
From Alan Watt, “3D Computer Graphics”
Radiosity MeshingRadiosity Meshing Each patch is Each patch is
colored with its colored with its illuminationillumination
The previous The previous image was image was obtained by obtained by pushing color to pushing color to vertices and then vertices and then Gourand shadingGourand shading
From Alan Watt, “3D Computer Graphics”
Global IlluminationGlobal Illumination What’s wrong with factoring into What’s wrong with factoring into
Radiosity and Ray-tracing?Radiosity and Ray-tracing? Factor into direct illumination + Factor into direct illumination +
indirect illuminationindirect illumination Indirect illumination is the hard partIndirect illumination is the hard partBut:But: Indirect illumination has low varianceIndirect illumination has low variance
Can be sampled and interpolated (with Can be sampled and interpolated (with care)care)
Photon MappingPhoton Mapping
[Jensen]
Two-Pass AlgorithmTwo-Pass Algorithm Pass 1:Pass 1:
Photons are generated and tracedPhotons are generated and traced They are associated with surface points and They are associated with surface points and
storedstored Photon Map is createdPhoton Map is created View independent passView independent pass
Pass 2Pass 2 Photon map is a static and used toPhoton map is a static and used to
Compute estimates of the incoming flux and the Compute estimates of the incoming flux and the reflected radiance at any point in the scenereflected radiance at any point in the scene
Look up indirect illumination from Photon mapLook up indirect illumination from Photon map Or, Trace rays once and then look up illuminationOr, Trace rays once and then look up illumination
Photon TracingPhoton Tracing Indirect illumination on diffuse surfaces Trace photons from the light sources
Store them at diffuse surfaces Brighter light => More Photons
Photons of uniform flux Diffuse point light emits in uniformly distributed random
directions Directional light emits in its direction Square light source emits from random positions on the square
with directions limited to a hemisphere Photon emission should follow light’s emission
properties Controls origin and direction of each photon Cosine distribution (more photon’s emitted perpendicular to
light)
Photon OriginationPhoton Origination
Pphoton= Plight / nphoton
Photon DistributionPhoton Distribution Importance samplingImportance sampling
Multiple light sourcesMultiple light sources Projection mapProjection map
Project a bounding sphere for objectsProject a bounding sphere for objects Photons not wasted on backgroundPhotons not wasted on background
Photon InteractionsPhoton Interactions On intersection, a photon can beOn intersection, a photon can be
Reflected, transmitted, or absorbedReflected, transmitted, or absorbed Probabilistic method based on the Probabilistic method based on the
material propertiesmaterial properties Russian rouletteRussian roulette
Roll a dice and decide next step for the Roll a dice and decide next step for the photonphoton
Controls count not the power of the Controls count not the power of the reflected/transmitted photonreflected/transmitted photon
Photon Paths in Cornell Photon Paths in Cornell BoxBox
Chrome sphere (left) and Glass sphere (right)(a) Two diffuse reflections followed by absorption(b) Specular reflection followed by two diffuse reflections(c) Two specular transmissions followed by absorption
Monochromatic Photon Monochromatic Photon BehaviorBehavior
Consider monochromatic simulationConsider monochromatic simulation Reflective surface withReflective surface with
Diffuse reflection coefficient Diffuse reflection coefficient dd SSpecular reflection coefficient pecular reflection coefficient s s (with (with d d + + s <=s <= 11) )
Uniformly distributed random variableUniformly distributed random variable X X ϵϵ [0[0, , 1]1]
Sample X. IfSample X. If X X ϵϵ [0[0, d, d] =] => > diffuse reflectiondiffuse reflection X X ϵϵ ] ]d, s d, s + + dd] =] => > specular reflectionspecular reflection X X ϵϵ ] ]s s + + d, d, 1] =1] => > absorptionabsorption
““Chromatic” PhotonsChromatic” Photons Probability PProbability Pdd for diffuse reflection = for diffuse reflection =
MAX(dMAX(drrPPrr, d, dggPPgg, d, dbbPPbb) / MAX(P) / MAX(Prr, P, Pgg, P, Pbb)) where (dwhere (drr, d, dgg, d, dbb) are the diffuse reflection ) are the diffuse reflection
coefficientscoefficients (P(Prr, P, Pgg, P, Pbb) are the powers of the incident photons) are the powers of the incident photons
Probability PProbability Pss for specular reflection is for specular reflection is MAX(sMAX(srrPPrr, s, sggPPgg, s, sbbPPbb) / MAX(P) / MAX(Prr, P, Pgg, P, Pbb)) where (swhere (srr, s, sgg, s, sbb) are the specular reflection ) are the specular reflection
coefficientscoefficients Instead of MAX, probabilities can also be Instead of MAX, probabilities can also be
based on total powerbased on total power
Chromatic Photon Chromatic Photon BehaviorBehavior
Sample X. IfSample X. If X X ϵϵ [0, P [0, Pdd] => diffuse reflection] => diffuse reflection X X ϵϵ ]P ]Pdd, P, Pss + P + Pdd] => specular reflection] => specular reflection X X ϵϵ ]P ]Pss + P + Pdd, 1] => absorption, 1] => absorption
The power of the reflected photon must changeThe power of the reflected photon must change If specular reflection was chosen:If specular reflection was chosen:
PPrefl,rrefl,r = P = Pinc,rinc,r s srr/P/Pss PPrefl,grefl,g = P = Pinc,ginc,g s sgg/P/Pss PPrefl,brefl,b = P = Pinc,binc,b s sbb/P/Pss
where Pwhere Pincinc is the power of the incident photon is the power of the incident photon Similarly for diffused and absorbed photonsSimilarly for diffused and absorbed photons
Photon MapPhoton Map Photons are only stored where they hit Photons are only stored where they hit
non-specular surfacesnon-specular surfaces Global data structure: photon map storesGlobal data structure: photon map stores
PositionPosition Incoming photon powerIncoming photon power Incident directionIncident direction A flag for help with sorting and look-upA flag for help with sorting and look-up
For participative media, one might For participative media, one might construct a volume photon mapconstruct a volume photon map
ExampleExample
(a) Raytraced image (direct
illumination, specularreflection and
transmission)
(b) Photons in thephoton map.
Images courtesy of Henrik Wann Jensen
Participative MediaParticipative Media Photons can be emitted from volumes (and Photons can be emitted from volumes (and
surfaces and points) surfaces and points) Probability of being Probability of being scatteredscattered or or absorpedabsorped in the in the
medium depends onmedium depends on Density of the mediumDensity of the medium Distance the photon travels through the mediumDistance the photon travels through the medium
The denser the medium, the shorter the average distance The denser the medium, the shorter the average distance before a photon interaction happens.before a photon interaction happens.
Photons are stored at the positions where a Photons are stored at the positions where a scattering event happensscattering event happens Exception photons directly from the light sourceException photons directly from the light source Direct illumination is evaluated using ray tracingDirect illumination is evaluated using ray tracing Not necessary, but this separation improves efficiencyNot necessary, but this separation improves efficiency
Participative MediumParticipative Medium
Glass sphere in fog illuminated by directional light
Images courtesy of Henrik Wann Jensen
Three Photon MapsThree Photon Maps Caustic photon map
Photons that have been through at least one specular reflection before hitting a diffuse surface: LS+D.
Global photon map Approximate representation of the global
illumination solution Scene for all diffuse surfaces
Volume photon map Indirect illumination of a participating medium
Rendering PassRendering Pass To find radiance at a pointTo find radiance at a point
Find the nearest photonsFind the nearest photons Use balanced K-d treeUse balanced K-d tree
Heap-like, store in an arrayHeap-like, store in an array Element i has its left child at 2i+1 and right Element i has its left child at 2i+1 and right
at 2i+2at 2i+2 Root at 0Root at 0
Radiance EstimateRadiance Estimate
Find a sphere around x containing n photons.Use these n photons to estimate the radiance.
n
ppoooor x
rL
12 ,,),,,(1),,(
xx
Photon p has power ΔΦp
Estimate FilteringEstimate Filtering Averaging samples creates blurAveraging samples creates blur
Good for radiosity, they are smoothGood for radiosity, they are smooth Not so good for caustics, they have sharp Not so good for caustics, they have sharp
boundariesboundaries Use weigted averagingUse weigted averaging Use differential filtersUse differential filters
Detect edges from the samplesDetect edges from the samples ““Zero” weights for samples outside edges Zero” weights for samples outside edges
RenderingRendering
Perform a single step of secondary illumination
ExamplesExamples
Raytraced Cornell boxSharp shadows
Raytraced Cornell boxSoft shadows
Images courtesy of Henrik Wann Jensen
Caustic Photon MapCaustic Photon Map
Photon map has 50000 photons and the estimate uses60 photons Images courtesy of Henrik Wann Jensen
Global Illumination with Global Illumination with Photon MapPhoton Map
200000 photons in the global photon map. 100 photons used in the estimate.
Images courtesy of Henrik Wann Jensen
Photon NeighborhoodPhoton Neighborhood
Global photon map radiance estimates visualized directly using 500 photons
Sphere EstimateSphere Estimate Disk EstimateDisk Estimate
Images courtesy of Henrik Wann Jensen
Cornell Box with WaterCornell Box with Water
Displacement-mapped water surface (20,000 tris). 500,000 photons in both the caustics and the global photon maps, and 100 photons in the radiance estimate. Images courtesy of Henrik Wann Jensen
Cognac Glass and Cognac Glass and CausticCaustic
Glass made with 12000 triangles. 200,000 photons in the map. The radiance estimates with 40 photons.Images courtesy of Henrik Wann Jensen
Caustic through Prism Caustic through Prism DispersionDispersion
Only three separate wavelengths have been sampled. 500, 000 photons in the caustics and 80 photons in the radiance estimate.
Images courtesy of Henrik Wann Jensen
Diana, the HuntressDiana, the Huntress
Light behind translucent marble. (200,000 photons)