Refrac on of a Caus c
• Monte‐Carlo ray tracing handles all paths of light: L(D|S)*E, but not equally well • Has difficulty sampling LS*DS*E paths, Photon Mapping e.g. refrac on of a caus c • Path tracing would need a very lucky first hit • Bidirec onal ray tracing can find Jan Kautz caus c, but reflec on of caus c s ll needs lucky first hit during path tracing
Featuring images swiped from Henrik Wann Jensen
Photon Mapping Why Map Photons?
• Jensen EGRW 95, 96 • High variance in Monte‐Carlo • Simulates the transport of individual renderings results in noise photons • Collec on of deposited photons • Photons emi ed from light sources into a “photon map” (a 3‐D • Photons bounce off of specular spa al data structure) provides a surfaces flux density es mate The scene above contains glossy surfaces, and was rendered in 50 • Photons deposited on diffuse surfaces • Flux samples filtered easier than – Held in a 3‐D spa al data structure minutes using photon mapping. The path samples, resul ng in error at same scene took 6 hours for render – Surfaces need not be parameterized lower frequencies with Radiance, a rendering system that • Photons collected by path tracing from used radiosity for diffuse reflec on and eye • Error is a result of bias, which decreases as the number of path tracing for glossy reflec on. samples increase • And, oh yeah, it’s a lot faster
What is a Photon? Sources
ωp • A photon p is a par cle of light • Point source that carries flux ΔΦp(xp, ωp) – Photons emi ed uniformly in all – Power: ΔΦp – magnitude (in direc ons Wa s) and color of the flux it • ΔΦp Power of source (W) distributed carries, stored as an RGB triple evenly among photons – Posi on: xp – loca on of the • photon xp Flux of each photon equal to source power divided by total # of photons – Direc on: ω – the incident p • direc on ωi used to compute For example, a 60W light bulb would irradiance send out a total of 100K photons, • Photons vs. rays each carrying a flux ΔΦ of 0.6 mW – Photons propogate flux • Photons sent out once per simula on, – Rays gather radiance not con nuously as in radiosity
1 Mixed Surfaces Russian Roule e ? • Surfaces have specular and • Arvo & Kirk, S90
diffuse components ρd = 50% • Reflected flux only a frac on of = 30% incident flux – ρ – diffuse reflectance ρs d • A er several reflec ons, spending – ρs – specular reflectance a lot of me keeping track of very – ρd + ρs < 1 (conserva on of li le flux energy) • Instead, completely absorb some • Let ζ be a uniform random value photons and completely reflect from 0 to 1 others at full power • Spend me tracing fewer full • If ζ < ρd then reflect diffuse power photons • Else if ζ < ρd + ρs then reflect • Probability of reflectance is the specular reflectance ρ. ρ = 60% • Otherwise absorb • Probability of absorp on is 1 – ρ.
Storing Photons K‐D Tree
• Uses a kd‐tree – a sequence of axis‐ aligned par ons • Given a large number of points p1,…,pn in 3D – 2‐D par ons are lines space we want to classify them and be able to – 3‐D par ons are planes • Axis of par ons alternates wrt make fast queries: depth of the tree – • Average access me is O(log n) Find all the points within a cuboid • Worst case O(n) when tree is – Find all the points within a neighbourhood of a severely lopsided • Need to maintain a balanced tree, given point which can be done in O(n log n) • These points are photon posi ons on surfaces. • Can find k nearest neighbors in O(k + log n) me using a heap
K‐D Tree K‐D Tree
• • A K‐D tree is just an axis aligned BSP tree. Write pi = (x1i, x2i, x3i) • Let xj* be the median of the values of the jth coordinate • Each node of the tree stores a separa ng (j=1,2,3). • Start with x1* which will par on the original set of points plane, defined by the median value along one into two sets (divided along the X axis). of the coordinates. • Now apply the same procedure to each of the le ‐ and right‐ sets, except now subdivide on x2* • The leaves of the tree contain the original data • Now apply the same procedure recursively to each of these points. subsets except now subdivide on x3* • Keep applying this recursively un l each leaf of the tree contains a data point.
2 K‐D Tree 2D Example K‐D Tree 2D Example
K‐D Tree 2D Example K‐D Tree Code
KDTree makeKDTree(int n, point_kd p[], int depth) /*returns a kd-tree for the n 3-dimensional points in p - assume all indices start from 1*/ { if n==1 return a leaf containing p[1]; /*base case*/
x = median of values of (depth mod 3) coordinate in the points; pLeft is the set of points to the left of x and pRight is the set to the right;
leftNode = makeKDTree(n/2,pLeft,depth+1); rightNode = makeKDTree(n/2,pRight,depth+1); /*assumes that the median splits the points exactly in two*/
/*compose a new node and return*/ return compose(leftNode,x,rightNode); }
K‐D Tree Advantages Reflected Radiance
• Using a K‐D tree solu on does not depend on • Recall the reflected radiance equa on the providing a mesh on the surfaces – the ΔA = πr2 distribu on of the photons is maintained independently of the representa on of the • Convert incident radiance into incident flux surfaces • The method does not rely on ‘regular’ surfaces • Reflected radiance in terms of incident flux such as polygons, but could equally well apply to fractal type surfaces. • Numerically
3 How Many Photons? Filtering
• How big is the disk radius r? • Too few photons cause blurry • Large enough that the disk results surrounds the n nearest • Simple averaging produces a box photons. Radiance es mate using 50 photons filtering of photons • The number of photons used for • Photons nearer to the sample a radiance es mate n is usually between 50 and 500. should be weighted more heavily • Results in a cone filtering of photons
ΔA = πr2 Radiance es mate using 500 photons
Mul ple Photon Maps Rendering
• Global L(S|D)*D photon map • Rendered by glossy‐surface distributed ray tracing – Photon s cks to diffuse surface and bounces to next surface (if • When ray hits first diffuse it survives Russian roule e) surface… – Compute direct illumina on – Photons don’t s ck to specular Caustic map Global map – Compute reflected radiance surfaces photons photons of caus c map photons First diffuse intersec on. Use global – Ignore global map photons Return radiance of caus c map • Caus c LSS*D photon map map photons here, but – Importance sample BRDF f photons to – High resolu on r ignore global map photons return as usual radiance – Light source usually emits – Use global photon map to when photons only in direc ons that importance sample incident evalua ng hit the thing crea ng the caus c radiance func on Li Li at first – Evaluate reflectance integral diffuse by cas ng rays and intersec on accumula ng radiances from . global photon map
www.bennolan.com www.bennolan.com Examples Examples
Direct Illumina on Global Photon Map
4 www.bennolan.com www.bennolan.com Examples Examples
Indirect Illumina on Final Rendering
Photon Map Example Photon Map Example
http://www.vrayrender.com/stuff/PMapTutorial/ http://www.vrayrender.com/stuff/PMapTutorial/
Photon Mapping
• One of the recent of the established global illumina on solu ons • Has a pre‐rendering phase to es mate global illumina on • A path tracing phase for the final rendering (final gathering) • It is significantly faster than path tracing (minutes compared to hours), and the pre‐rendering phase only has to be done once. • Most me goes into the final rendering phase, and in par cular in es ma ng the radiance from nearby photons.
5