๐ฑ ๐, ๐โฒ = ๐(๐, ๐โฒ) ๐ ๐, ๐โฒ + เถฑ
๐ป
๐ ๐, ๐โฒ, ๐โฒโฒ ๐ฑ ๐โฒ, ๐โฒโฒ ๐๐โฒโฒ
INFOMAGR โ Advanced Graphics
Jacco Bikker - November 2018 - February 2019
Lecture 16 - Bits & Pieces Welcome! , = (, ) - - PowerPoint PPT Presentation
INFOMAGR Advanced Graphics Jacco Bikker - November 2018 - February 2019 Lecture 16 - Bits & Pieces Welcome! , = (, ) , + , , ,
๐ฑ ๐, ๐โฒ = ๐(๐, ๐โฒ) ๐ ๐, ๐โฒ + เถฑ
๐ป
๐ ๐, ๐โฒ, ๐โฒโฒ ๐ฑ ๐โฒ, ๐โฒโฒ ๐๐โฒโฒ
Jacco Bikker - November 2018 - February 2019
โช On Offsetting Shadows and Reflections โช Consistent Normal Interpolation โช Path Classification โช Packing Normals โช Multiple Importance Sampling, One More Time โช Research Directions
You have been toldโฆ
โฆTo offset your shadow rays by โepsilon times R or Lโ. โช How should be chose epsilon? โช Is epsilon the same everywhere? โช Is this always sufficient?
Advanced Graphics โ Bits & Pieces 3 p ๐๐ ๐๐ ๐
SafeOrigin
When R (or L) is almost parallel to the surface, the epsilon offset fails. Alternative: ๐ += cos ๐3 ๐ ๐ + 1 โ cos ๐3 ๐ ๐
Advanced Graphics โ Bits & Pieces 4 p ๐๐ ๐๐ ๐
SafeOrigin
When R (or L) is almost parallel to the surface, the epsilon offset fails. Alternative: ๐ += cos ๐3 ๐ ๐ + 1 โ cos ๐3 ๐ ๐
Advanced Graphics โ Bits & Pieces 5 p ๐๐ ๐๐ ๐
โช On Offsetting Shadows and Reflections โช Consistent Normal Interpolation โช Path Classification โช Packing Normals โช Multiple Importance Sampling, One More Time โช Research Directions
The Problem
Vertex normal: the average of the normals of all polygons connected to the vertex. Generating / updating vertex normals in O(N): โช set each vertex normal to (0,0,0); โช loop over polygons; โช add normal of each polygon to each polygon vertex; โช normalize all vertex normals.
Advanced Graphics โ Bits & Pieces 7
The Problem
Vertex normal: the average of the normals of all polygons connected to the vertex. Using vertex normals: โช Mรถller-Trumbore yields โu,vโ coordinates: these are barycentric coordinates; โช calculate ๐ฅ = 1 โ (๐ฃ + ๐ค); โช now ๐๐ = ๐ฅ โ ๐0 + ๐ฃ โ ๐1 + ๐ค โ ๐2. Mind the side! Advanced Graphics โ Bits & Pieces 8
The Problem
Vertex normal: the average of the normals of all polygons connected to the vertex. For grazing directions, the reflection may go into the surface. Now what? โช Use geometric normal instead of interpolated normal? โช Clamp dot between R and N to 0? โช Just return black? Advanced Graphics โ Bits & Pieces 9
Advanced Graphics โ Bits & Pieces 10
Advanced Graphics โ Bits & Pieces 11
Consistent Normal Interpolation*
Can we come up with an interpolated normal ๐๐ that behaves properly? โช It is smooth โช Reflections in ๐๐ point away from the surface โช If all vertex normals are equal to ๐, ๐๐ = ๐ โช If ๐๐๐ข ๐, ๐ = 1, ๐๐ = ๐๐ It turns out that this is indeed possible. The paper outlines how to calculate, for a given ๐, a vector ๐ that satisfies the constraints. ๐๐ now is simply ๐๐๐ ๐๐๐๐๐จ๐ ๐ + ๐ .
*: Reshetov et al., Consistent Normal Interpolation. ACM Transactions on Graphics, 2010.
Advanced Graphics โ Bits & Pieces 12
Advanced Graphics โ Bits & Pieces 13
Advanced Graphics โ Bits & Pieces 14
Advanced Graphics โ Bits & Pieces 15
Advanced Graphics โ Bits & Pieces 16
Normal Mapping
A normal map can be used to modify normals. Advanced Graphics โ Bits & Pieces 17
Normal Mapping
A normal map can be used to modify normals. This is typically done in tangent space. Problem: the orientation of tangent space matters. We need to align ๐ and ๐ถ with the texture, in other words: it needs to be based on the U and V vectors over the surface. This is non-
T and B, see: learnopengl.com/Advanced-Lighting/Normal-Mapping Advanced Graphics โ Bits & Pieces 18
โช On Offsetting Shadows and Reflections โช Consistent Normal Interpolation โช Path Classification โช Packing Normals โช Multiple Importance Sampling, One More Time โช Research Directions
Advanced Graphics โ Bits & Pieces 20
Splitting Light Transport
Global illumination consists of: โช Direct illumination โช Indirect illumination Or: โช Direct illumination โช Indirect illumination with one diffuse bounce โช Indirect illumination with multiple bounces
Advanced Graphics โ Bits & Pieces 21
Splitting Light Transport
Light transport consists of: โช All paths of all lengths between the camera and the light. Or: โช All paths with zero or one diffuse vertices, plus โช all paths with at least two diffuse vertices. Or: โช All paths that start with ES (e.g. ESDL), plus โช all paths that do not start with ES (e.g. EDDL). If we can isolate a certain class of paths, we can handle this class with a dedicated rendering algorithm.
Advanced Graphics โ Bits & Pieces 22
Heckbertโs Path Notation*
Vertex types: โช L: light โช E: eye โช S: specular โช D: diffuse (D)+
(D)* zero or more diffuse vertices (D)? zero or one diffuse vertices (DSโ) a diffuse or a specular vertex
*: Heckbert, Adaptive radiosity textures for bidirectional ray tracing. SIGGRAPH 1990.
Advanced Graphics โ Bits & Pieces 23
Splitting Light Transport
If we can isolate a certain class of paths, we can handle this class with a dedicated rendering algorithm. ESDL: Whitted-style EDL: Whitted-style, with next event estimation EDSL: Photon mapping, direct visualization of the photon map EDD(S*)L: Photon mapping, with final gather We can also do this to parts of the path: โช Camera ray: rasterization? โช Path segments that gather direct light: NEE โช Path segments that gather indirect light: baked?
Advanced Graphics โ Bits & Pieces 24
Splitting Light Transport
If we can isolate a certain class of paths, we can handle this class with a dedicated rendering algorithm. ESDL: Whitted-style EDL: Whitted-style, with next event estimation EDSL: Photon mapping, direct visualization of the photon map EDD(S*)L: Photon mapping, with final gather We can also do this to parts of the path: โช Camera ray: rasterization? โช Path segments that gather direct light: NEE + filter, small kernel โช Path segments that gather indirect light: bounce + filter, large kernel
Advanced Graphics โ Bits & Pieces 25
Splitting Light Transport
If we can evaluate a certain path length using multiple techniques, we can use Multiple Importance Sampling to automatically select the best one. E.g. Next Event Estimation: EDL via explicit or implicit technique. Or, BDPT (book, latest edition, 16.3).
Advanced Graphics โ Bits & Pieces 26
Advanced Graphics โ Bits & Pieces 27
โช On Offsetting Shadows and Reflections โช Consistent Normal Interpolation โช Path Classification โช Packing Normals โช Multiple Importance Sampling, One More Time โช Research Directions
Efficiently Storing Normals
A float color pixel contains r, g and b. Wouldnโt it be convenient if the fourth component could store the normal? โ Can we store a normal accurately in 32 bits? Observation: For a normal, we need two components (plus a sign). โ Can we store the two components in 16 bits each?
Advanced Graphics โ Bits & Pieces 29
Efficiently Storing Normals
For an extensive study on this topic, see: aras-p.info/texts/CompactNormalStorage.html Bottom line: We can encode a normal in 32-bit, and the precision will be excellent: expect approximately four digits of precision. Pack: uint PackNormal( float3 N ) { float f = 65535.0f / sqrtf( 8.0f * N.z + 8.0f ); return (uint)(N.x * f + 32767.0f) + ((uint)(N.y * f + 32767.0f) << 16); }
Advanced Graphics โ Bits & Pieces 30
Efficiently Storing Normals
For an extensive study on this topic, see: aras-p.info/texts/CompactNormalStorage.html Bottom line: We can encode a normal in 32-bit, and the precision will be excellent: expect approximately four digits of precision. Pack: float3 UnpackNormal( uint p ) { float4 nn = make_float4( (float)(p & 65535) * (2.f / 65535.f), (float)(p >> 16) * (2.f / 65535.f), 0, 0 ); nn += make_float4( -1, -1, 1, -1 ); float l = dot( make_float3( nn.x, nn.y, nn.z ), make_float3( -nn.x, -nn.y, -nn.w ) ); nn.z = l, l = sqrtf( l ), nn.x *= l, nn.y *= l; return make_float3( nn ) * 2.0f + make_float3( 0, 0, -1 ); }
Advanced Graphics โ Bits & Pieces 31
โช On Offsetting Shadows and Reflections โช Consistent Normal Interpolation โช Path Classification โช Packing Normals โช Multiple Importance Sampling, One More Time โช Research Directions
Method 1: direct light sampling
โช Samples only the part of the hemisphere
โช Does so by checking the visibility of a random point on a random light.
Method 2: BRDF sampling
โช Samples only the part of the hemisphere not occupied by light sources โช Does so by rejecting samples that happen to hit a light source. Method 1 and 2 can (should!) be summed to sample the full hemisphere exactly once.
Advanced Graphics โ Bits & Pieces 33
โ๐ ๐ โ๐ ๐
๐๐๐ = แ 1 ๐ก๐๐๐๐ ๐๐๐๐๐
angle ๐๐ ๐๐ = เถฑ
โ๐ ๐
๐๐๐ก๐
๐๐๐ = cos ๐ ๐
Advanced Graphics โ Bits & Pieces 34
เถฑ ๐ ๐ฆ ๐๐ฆ = ๐น ๐ ๐ฆ โ 1 ๐ เท
๐=1 ๐
๐ ๐๐ ๐น ๐ ๐ฆ โ 1 ๐ เท
๐=1 ๐ ๐ ๐๐
๐ ๐๐
๐๐๐ ๐๐ ๐ค๐๐๐ฃ๐ ๐ก๐๐๐๐ ๐ค๐๐๐ฃ๐ = ๐ค๐๐ ๐ง ๐๐๐ ๐๐ ๐๐๐ ๐๐ ๐ค๐๐๐ฃ๐ ๐๐๐ ๐๐ ๐ค๐๐๐ฃ๐ โ 1
Advanced Graphics โ Bits & Pieces 35
Using two pdfs: randomly pick one.
๐น ๐ ๐ โ 1 ๐ เท
๐=1 ๐ ๐ ๐๐
๐ ๐๐ ๐น ๐ ๐ โ เท
๐=1 ๐
1 ๐๐ เท
๐=1 ๐๐
๐๐(๐๐,๐) ๐ ๐๐,๐ ๐๐ ๐๐,๐
This is what we did before. Now, we combine the sampling techniques. Weights: ฯ ๐๐ = 1 Most basic weight:
1 ๐
(i.e., a weighted average of the techniques).
iterate over the available techniques / pdfs draw ๐๐ samples using technique ๐ apply a weight to each sample
Advanced Graphics โ Bits & Pieces 36
Weights: ฯ ๐๐ = 1, most basic weight:
1 ๐ . Can we do better?
Objective: minimize variance in the estimator. How about this one: This time, the weight is proportional to the pdf (!).
๐น ๐ าง ๐ฆ โ เท
๐=1 ๐
1 ๐๐ เท
๐=1 ๐๐
๐๐(๐๐,๐) ๐ ๐๐,๐ ๐๐ ๐๐,๐
iterate over the available techniques draw ๐๐ samples using technique ๐ apply a weight to each sample
๐๐(๐) = ๐๐๐๐(๐) ฯ๐ ๐๐๐๐(๐) โฆ = เท
๐=1 ๐
๐๐(๐๐) ๐ ๐๐ ๐๐ ๐๐ ๐๐(๐) = ๐๐(๐) ฯ๐ ๐๐(๐)
For two pdfs:
๐๐ต(๐) = ๐๐ต(๐) ๐๐ต(๐) +๐๐ถ (๐) ๐๐ถ(๐) = ๐๐ถ(๐) ๐๐ต(๐) +๐๐ถ (๐)
Letโs set ๐๐ to 1 to simplify things:
We are drawing ๐ from ๐๐ต, and we are looking up the same ๐ in ๐๐ถ.
Advanced Graphics โ Bits & Pieces 37
Summarizing:
๐บ = เท
๐=1 ๐
๐๐(๐๐) ๐ ๐๐ ๐๐ ๐๐ = ๐๐ต ๐๐ต ๐ ๐๐ต ๐๐ต ๐๐ต + ๐๐ถ ๐๐ถ ๐ ๐๐ถ ๐๐ถ ๐๐ถ where ๐๐ต(๐) = ๐๐ต(๐) ๐๐ต ๐ +๐๐ถ ๐ and ๐๐ถ(๐) = ๐๐ถ(๐) ๐๐ต(๐) +๐๐ถ (๐) So: for both sampling strategies, we add to the pdf the pdf of the other strategy for the same point on the hemisphere.
๐๐ต ๐๐ต ๐ ๐๐ต ๐๐ต ๐๐ต ๐๐ถ ๐๐ถ ๐ ๐๐ถ ๐๐ถ ๐๐ถ = ๐๐ถ(๐๐ถ) ๐๐ต(๐๐ถ) +๐๐ถ (๐๐ถ) ๐ ๐๐ถ ๐๐ถ ๐๐ถ = ๐ ๐๐ถ ๐๐ต ๐๐ถ +๐๐ถ (๐๐ถ) = ๐๐ต(๐๐ต) ๐๐ต(๐๐ต) +๐๐ถ (๐๐ต) ๐ ๐๐ต ๐๐ต ๐๐ต = ๐ ๐๐ต ๐๐ต ๐๐ต +๐๐ถ (๐๐ต)
= ๐ ๐๐ต ๐๐ต ๐๐ต + ๐๐ถ(๐๐ต) + ๐ ๐๐ถ ๐๐ต(๐๐ถ) + ๐๐ถ ๐๐ถ Advanced Graphics โ Bits & Pieces 38
โช On Offsetting Shadows and Reflections โช Consistent Normal Interpolation โช Path Classification โช Packing Normals โช Multiple Importance Sampling, One More Time โช Research Directions
Topics
Path tracing BVH GPGPU
Blue noise Materials
Subdivision surfaces, hair, displacement maps Many lights Geometry compression
Advanced Graphics โ Bits & Pieces 40
โช On Offsetting Shadows and Reflections โช Consistent Normal Interpolation โช Path Classification โช Packing Normals โช Multiple Importance Sampling, One More Time โช Research Directions
Jacco Bikker - November 2018 โ February 2019
next lecture: โGrand Recapโ