lecture 15 -bits & pieces - universiteit utrecht

51
, = (, ) , +න , , ′′ , ′′ ′′ INFOMAGR – Advanced Graphics Jacco Bikker - November 2019 - February 2020 Lecture 15 - “Bits & Pieces” Welcome!

Upload: others

Post on 27-Feb-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

𝑰 𝒙, 𝒙′ = 𝒈(𝒙, 𝒙′) 𝝐 𝒙, 𝒙′ + න𝑺

𝝆 𝒙, 𝒙′, 𝒙′′ 𝑰 𝒙′, 𝒙′′ 𝒅𝒙′′

INFOMAGR – Advanced GraphicsJacco Bikker - November 2019 - February 2020

Lecture 15 - “Bits & Pieces”

Welcome!

Today’s Agenda:

▪ On Offsetting Shadows and Reflections

▪ Consistent Normal Interpolation

▪ Packing Normals

▪ Spatial Splits in BVHs

▪ 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?

Offsets

Advanced Graphics – Bits & Pieces 3

p

𝜔𝑜

𝜔𝑖𝑁

You have been told…

Geek solution: use fixed point numbers.

This time: epsilon = 1.

Offsets

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 𝑒 𝑁

Offsets

Advanced Graphics – Bits & Pieces 5

p

𝜔𝑜

𝜔𝑖𝑁

SafeOrigin

When R (or L) is almost parallel to the surface, the epsilon offset fails.

Alternative:

𝑂 += cos 𝜃3 ∙ 𝑅 + 1 − cos 𝜃3 ∙ 𝑁

Offsets

Advanced Graphics – Bits & Pieces 6

p

𝜔𝑜

𝜔𝑖

𝑁

Second Opinion

Ray Tracing Gems, chapter 6:

A Fast and Robust Method for Avoiding Self-Intersection.Carsten Wächter and Nikolaus Binder, 2019.

Offsets

Advanced Graphics – Bits & Pieces 7

Today’s Agenda:

▪ On Offsetting Shadows and Reflections

▪ Consistent Normal Interpolation

▪ Packing Normals

▪ Spatial Splits in BVHs

▪ 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.

Normals

Advanced Graphics – Bits & Pieces 9

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 10

Normals

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 11

Normals

Advanced Graphics – Bits & Pieces 12

Normals

Advanced Graphics – Bits & Pieces 13

Normals

Consistent Normal Interpolation*

Can we come up with an interpolated normal 𝑛𝑐 that behaves properly? - Requirements:

▪ 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 14

Normals

Advanced Graphics – Bits & Pieces 15

Normals

Advanced Graphics – Bits & Pieces 16

Normals

Advanced Graphics – Bits & Pieces 17

Normals

Advanced Graphics – Bits & Pieces 18

Normals

Normal Mapping

A normal map can be used to modify normals.

Advanced Graphics – Bits & Pieces 19

Normals

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 theU and V vectors over the surface. This is non-trivial. For a derivation of the calculation ofT and B, see:

learnopengl.com/Advanced-Lighting/Normal-Mapping

Advanced Graphics – Bits & Pieces 20

Normals

What if the normal sends you into the surface

Advanced Graphics – Bits & Pieces 21

Normals

What if the normal sends you into the surface

Advanced Graphics – Bits & Pieces 22

Normals

What if the normal sends you into the surface

Microfacet-based Normal Mapping for Robust Monte Carlo Path Tracing. Schüssler et al., 2017.

Advanced Graphics – Bits & Pieces 23

Normals

Today’s Agenda:

▪ On Offsetting Shadows and Reflections

▪ Consistent Normal Interpolation

▪ Packing Normals

▪ Spatial Splits in BVHs

▪ 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?

Packing

Advanced Graphics – Bits & Pieces 25

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);

}

Packing

Advanced Graphics – Bits & Pieces 26

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.

Unpack:

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 );

}

Packing

Advanced Graphics – Bits & Pieces 27

Today’s Agenda:

▪ On Offsetting Shadows and Reflections

▪ Consistent Normal Interpolation

▪ Packing Normals

▪ Spatial Splits in BVHs

▪ Research Directions

Splitting

Problematic Large Polygons

Large polygons lead to poor BVHs.

(far more common than you’d think)

Advanced Graphics – Bits & Pieces 29

Splitting

Problematic Large Polygons

Large polygons lead to poor BVHs.

Using the spatial splits in kD-trees, this is far less of an issue:

The triangle will simply be assigned to each subspace.

Advanced Graphics – Bits & Pieces 30

Splitting

Problematic Large Polygons

Large polygons lead to poor BVHs.

Using the spatial splits in kD-trees, this is far less of an issue:

The triangle will simply be assigned to each subspace.

Solution 1: split large polygons*.

Observations:

1. A polygon can safely reside in multiple leafs;2. The bounds of a leaf do not have to include the

entire polygon.

*: Early Split Clipping for Bounding Volume Hierarchies, Ernst & Greiner, 2007

Advanced Graphics – Bits & Pieces 31

Splitting

Early Split Clipping

Observations:

1. A polygon can safely reside in multiple leafs;2. The bounds of a leaf do not have to include the

entire polygon.3. BVH construction only uses primitive bounding

boxes.

Algorithm:

Prior to BVH construction, we recursively subdivide any polygon with a surface area that exceeds a certain threshold.

Issues:

▪ Threshold parameter▪ Individual polygons are split,

regardless of surrounding geometry▪ Primitives may end up multiple times

in the same leaf

(some of these issues are resolved in: The Edge Volume Heuristic - Robust Triangle Subdivision for Improved BVH Performance, Dammertz & Keller, 2008)

Advanced Graphics – Bits & Pieces 32

Splitting

Spatial Splits for BVHs

Observation: spatial splits are not limited to kD-trees.

But: spatial splits tend to increase the cost of a split.

Idea:

1. Determine cost of optimal object partition;2. Determine cost of optimal spatial split;3. Apply spatial split if cost is lower than object partition*.

*: Spatial Splits in Bounding Volume Hierarchies, Stich et al., 2009

𝐶𝑠𝑝𝑙𝑖𝑡 = 𝐴𝑙𝑒𝑓𝑡 ∗ 𝑁𝑙𝑒𝑓𝑡 + 𝐴𝑟𝑖𝑔ℎ𝑡 ∗ 𝑁𝑟𝑖𝑔ℎ𝑡 < 𝐴 ∗ 𝑁

Advanced Graphics – Bits & Pieces 33

Splitting

State of the Art: SBVH

Summary: high quality bounding volume hierarchies can be obtained by combining the surface area heuristic and spatial splits.

Compared to a regular SAH BVH, spatial splits improve the BVH by ~25% (see paper for scenes and figures).

Advanced Graphics – Bits & Pieces 34

Better BVHs

Advanced Graphics – Bits & Pieces 35

Better BVHs

Advanced Graphics – Bits & Pieces 36

BVH

Bounding Volume Hierarchies – Final Words

Materials:

SAH guided spatial split partitioning for fast BVH construction. Ganestam and Doggett, 2016.

Fast Parallel Construction of High-Quality Bounding Volume Hierarchies. Karras and Aila, 2013.

Efficient Incoherent Ray Traversal on GPUs Through Compressed Wide BVHs. Ylitie et al., 2017.

Tree Rotations for Improving Bounding Volume Hierarchies. Kensler, 2008.

Improved Two-Level BVHs using Partial Re-Braiding. Benthin et al., 2017.

Advanced Graphics – Bits & Pieces 37

Today’s Agenda:

▪ On Offsetting Shadows and Reflections

▪ Consistent Normal Interpolation

▪ Packing Normals

▪ Spatial Splits in BVHs

▪ Research Directions

Materials

Future Work

Advanced Graphics – Bits & Pieces 40

Other resources:

Implementing the Disney BSDFschuttejoe.github.io/post/disneybsdf

Efficient Rendering of Layered Materials using an Atomic Decomposition with Statistical Operators. Belcour, 2018.

Eric Heitz’s Research Page:eheitzresearch.wordpress.com/research(all his work is good)

Spectral Rendering

Future Work

Advanced Graphics – Bits & Pieces 41

Other resources:

Hero Wavelength Spectral Sampling. Wilie et al., 2014.

Physically Meaningful Rendering using Tristimulus Colours. Meng et al., 2015.

PBRT. Pharr et al., 2004-2018.https://www.pbrt.org

Mitsuba Renderer. W. Jakob, 2014.https://www.mitsuba-renderer.org

Participating Media

Future Work

Advanced Graphics – Bits & Pieces 42

Other resources:

Importance Sampling Techniques for Path Tracing in Participating Media. Kulla and Fajardo, 2014.

Area Light Equi-Angular Sampling on ShaderToy:https://ww.shadertoy.com/view/ldXGzS

Light Transport

Future Work

Advanced Graphics – Bits & Pieces 43

Other resources:

The Rendering Equation. James T. Kajiya, 1986.

Bidirectional Path Tracing. Michal Vlnas, 2018 (student paper).

Global Illumination using Photon Maps. Jensen, 1996.

Progressive Photon Mapping. Hachisuka et al., 2008.

(article on) Vertex Connection and Merging, Georgev et al., 2012. https://schuttejoe.github.io/post/vertexconnectionandmerging

Primitives

Future Work

Advanced Graphics – Bits & Pieces 44

Other resources:

Direct Ray Tracing of Smoothed andDisplacement Mapped Triangles. Smits et al., 2000.

Direct Ray Tracing of Phong Tessellation. Ogaki and Tokuyoshi, 2011.

Two-Level Ray Tracing with Reordering for Highly Complex Scenes. Hanika et al., 2010.

Production

Future Work

Advanced Graphics – Bits & Pieces 45

Other resources:

The Iray Light Transport Simulation and Rendering System. Keller et al., 2017.

The Design and Evolution of Disney’s Hyperion Renderer. Burley et al., 2018.

Manuka: A batch-shading architecture for spectral path tracing in movie production. Fascione et al., 2018.

Mitsuba 2: A Retargetable Forward and Inverse Renderer. Nimier-David, 2019.

Production

Future Work

Advanced Graphics – Bits & Pieces 46

Other resources:

OptiX: A General Purpose Ray Tracing Engine. Parker et al., 2010.

REAL-TIME RAYTRACINGWITH NVIDIA RTX. Stich, 2018.

(not a lot of research so far…)

Massive Scenes

Future Work

Advanced Graphics – Bits & Pieces 47

Moana Island scene. Heather Pritchett & Rasmus Tamstorf, 2016. ~15 billion primitives.

Today’s Agenda:

▪ On Offsetting Shadows and Reflections

▪ Consistent Normal Interpolation

▪ Packing Normals

▪ Spatial Splits in BVHs

▪ Research Directions

Exam Questions

In path tracing, we can reduce variance by using cosine weighted sampling of the hemisphere, rather than uniform

sampling, for diffuse surfaces.

a) Why does this reduce variance?

b) When using cosine weighted sampling, the result

remains unbiased. What does unbiased mean?

Advanced Graphics – Bits & Pieces 49

Exam Questions

An exam can be seen as a Monte-Carlo process. Explain why.

Advanced Graphics – Bits & Pieces 50

Exam Questions

Advanced Graphics – Bits & Pieces 51

A scene is illuminated by a single double-sided square light souce.

Two algorithms are used to sample the light source: the first picks a random point on a random side of the light source, while the second algorithm only picks random points on the side of the light source facing point 𝒑.

a) Write down the Monte-Carlo integrator that estimates the illumination on point 𝒑 using the first algorithm.

b) Write down the Monte-Carlo integrator that estimates the illumination on point 𝒑 using the second algorithm.

Note: both methods should obviously produce the same answer, on average™.

INFOMAGR – Advanced GraphicsJacco Bikker - November 2019 – February 2020

END of “Bits & Pieces”next lecture: “Big Picture”