Realistic Image Synthesis - BRDFs and Direct Lighting - Philipp Slusallek Karol Myszkowski Gurprit Singh Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Importance Sampling Example • Example: Generate Cosine weighted distribution – Generate ray according to cosine distribution with respect to normal – Need only average of the incident radiance Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Multidimensional Inversion • Multidimensional Inversion Method (here 2D) – Goal: density function 𝑞(𝑦, 𝑧) with 𝑦 ∈ 𝑏, 𝑐 , 𝑧 ∈ [𝑑, 𝑒] – Compute cumulative distribution function 𝑧 𝑦 𝑄 𝑦, 𝑧 = න න 𝑞 𝑦′, 𝑧′ 𝑒𝑦′𝑒𝑧′ 𝑑 𝑏 – Random variables along x are generated by integrating 𝑄 over entire y-range (marginal density) ′ , 𝑧 ቚ 𝑧=𝑒 = ′ 𝜊 1 = 𝑄 𝜊 1 𝑄 𝜊 1 ′ = 𝑄 −1 (𝜊 1 ) ⇒ 𝜊 1 – Now, given 𝑦 = 𝜊′ 1 we have a one-dimensional problem but we still need to normalize ′ ቚ ′ = ෨ ′ 𝜊 2 ~ 𝑄 𝑦, 𝜊 2 𝑄 𝜊 2 𝑦=𝜊 1 ෨ 𝑄 −1 (𝜊 2 ) ′ ~ ෨ ′ = 𝑄 −1 𝜊 2 ⇒ 𝜊 2 ⇒ 𝜊 2 ෨ 𝑄(𝑒) Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Multidim. Inversion: Hemisphere • Multidimensional probability function ( 𝑞 𝜕 = 𝑑𝑝𝑜𝑡𝑢 = 𝑑 ) 𝑑 = 1 න p 𝜕 𝑒𝜕 = 1 ⇒ 𝑑 න 𝑒𝜕 = 1 ⇒ 2𝜌 Ω + Ω + 𝑞 𝜕 = 1 𝑞 𝜄, 𝜒 = sin(𝜄) ⇒ with 𝑒𝜕 = 𝑡𝑗𝑜𝜄 𝑒𝜄d𝜒 2𝜌 2𝜌 • Marginal density function (integrating out 𝝌 ) 2𝜌 𝑡𝑗𝑜𝜄 𝜄 𝑡𝑗𝑜𝜄 ′ 𝑒𝜄 ′ = 1 − 𝑑𝑝𝑡𝜄 𝑞 𝜄 = න 2𝜌 𝑒𝜒 = 𝑡𝑗𝑜𝜄 ⇒ 𝜊 1 = 𝑄 𝜄 = න 0 0 • Conditional density function 𝜒 𝑞 𝜒 𝜄 = 𝑞(𝜄, 𝜒) = 1 2𝜌 𝑒𝜒 ′ = 𝜒 1 2𝜌 ⇒ 𝜊 2 = 𝑄 𝜒 𝜄 = න 𝑞(𝜄) 2𝜌 0 • Inverting, with: if (1 − 𝑌) is uniform in [𝟏, 𝟐] , so is 𝒀 𝜄 = 𝑑𝑝𝑡 −1 1 − 𝜊 1 = 𝑑𝑝𝑡 −1 𝜊 1 𝜒 = 2𝜌𝜊 2 Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Sampling a BRDF • Uniformly distributed on the hemisphere ( ~𝑒𝜕 ) = − 2 x cos( 2 ) ( 1 ) 1 2 = 2 = − 1 2 y sin( 2 ) ( 1 ) = 1 2 acos( ) 2 = z 2 • Cosine distributed on the hemisphere ( ~𝑑𝑝𝑡𝜄d𝜕 ) = − x cos( 2 ) ( 1 ) 1 2 = 2 1 = − y sin( 2 ) ( 1 ) = 1 2 acos( ) 2 = z 2 • Cosine-power distributed on the hemisphere ( ~𝑑𝑝𝑡 𝑜 𝜄𝑒𝜕 ) 2 = − + n 1 x cos( 2 ) ( 1 ) 1 2 = 2 Also see 2 1 + = − n 1 y sin( 2 ) ( 1 ) Global Illumination Compentium 1 1 2 = + by Philip Dutre (U. Leuven): acos( ) n 1 2 1 = http://www.cs.kuleuven.ac.be/~phil/GI/ + z n 1 2 Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Sampling a BRDF • Phong BRDF = + n f ( , x , ) L cos d k L cos d k L cos cos d r i o i d i s i + + + N 2 k = • Sampling the diffuse part d I L ( ) cos 1 k k k N = – Uniform on the hemisphere k 1 N k – Better: Cosine distributed = d I L ( ) 1 k k N • Sampling the glossy part = k 1 – Uniform on the hemisphere N 2 k = n s I L ( ) cos cos – Better: Cosine distributed 2 k k k k N = k 1 – Cosine-power distributed N k • Cdigon integrates only over = n s I L ( ) cos 2 k k k positive hemisphere N = k 1 (see GI-Compendium) N k = s I C L ( ) cos θ ' 2 digon k k k θ N = k 1 Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Direct Lighting Computation • Need to compute the integral • See also – Shirley et al.: MC-Techniques for Direct Lighting Calculations • Single light source, not too close (>1/5 of its radius) – Small: • 1/𝑠 2 has low variance, cos𝜄 𝑦 has low variance – Planar: • cos𝜄 𝑧 has low variance too • Choose samples uniformly on light source geometry – Sampling directions could have high variance – For curved light sources • Take into account orientation/normal Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Direct Lighting Computation Sampling projected solid angle Sampling light source area 4 eye rays per pixel 4 eye rays per pixel 100 shadow rays 100 shadow rays Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Direct Lighting Computation Fixed sample location Random sample location 4 eye rays per pixel 4 eye rays per pixel 1 shadow ray each 1 shadow ray each Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Direct Lighting Computation Sample locations on 2D grid Stratified random sample locations 4 eye rays per pixel 4 eye rays per pixel 64 shadow ray 64 shadow ray Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Direct Lighting Computation Stratified random sample locations Stratified random sample locations 4 eye rays per pixel 64 eye rays per pixel 16 shadow ray 1 shadow ray Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Direct Lighting Computation • Importance sampling of many light sources – Ray tracing cost grows with number of lights • Approaches – Equal probability (1/N L ) – Fixed weights according to total power of light = i p • Sample as discrete probability density function i i • Make sure that pdf is not zero if light could be visible – Must use conservative approximation – Stratification through spatial subdivision • Estimate the contribution of lights in each cell (e.g. octree) – Dynamic and adaptive importance sampling • Compute a running average of irradiance at nearby points • Use the relative contribution as the importance function • Should use coherent sampling • Might need to estimate separately for primary and secondary rays Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Direct Lighting Computation • Example: Sampling thousands of lights interactively – At each pixel send random path into the scene & towards some light • Low overhead since we already trace many rays per pixel – Gives a rough estimate of light contribution to the entire image • Take maximum contribution of each light at any pixel • Might want to average over several images (less variance) – Use this estimate for importance sampling • Make sure every light is sampled eventually • Might ignore lights with very low probability (but introduces bias) – Trace samples ONLY from the eye • Avoids touching the entire scene • Minimizes working set for very large scenes – Published as [Wald et al., Interactive Global Illumination in Complex and Highly Occluded Environments, EGSR ’ 03] Realistic Image Synthesis SS18 – BRDFs and Direct Lighting
Recommend
More recommend