Lecture 16 -Bits & Pieces - Universiteit Utrecht

Preview:

Citation preview

๐‘ฐ ๐’™, ๐’™โ€ฒ = ๐’ˆ(๐’™, ๐’™โ€ฒ) ๐ ๐’™, ๐’™โ€ฒ + เถฑ๐‘บ

๐† ๐’™, ๐’™โ€ฒ, ๐’™โ€ฒโ€ฒ ๐‘ฐ ๐’™โ€ฒ, ๐’™โ€ฒโ€ฒ ๐’…๐’™โ€ฒโ€ฒ

INFOMAGR โ€“ Advanced GraphicsJacco Bikker - November 2018 - February 2019

Lecture 16 - โ€œBits & Piecesโ€

Welcome!

Todayโ€™s Agenda:

โ–ช 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?

Offsets

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 ๐œ€ ๐‘

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

๐œ”๐‘œ

๐œ”๐‘–

๐‘

Todayโ€™s Agenda:

โ–ช 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.

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

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 9

Normals

Advanced Graphics โ€“ Bits & Pieces 10

Normals

Advanced Graphics โ€“ Bits & Pieces 11

Normals

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

Normals

Advanced Graphics โ€“ Bits & Pieces 13

Normals

Advanced Graphics โ€“ Bits & Pieces 14

Normals

Advanced Graphics โ€“ Bits & Pieces 15

Normals

Advanced Graphics โ€“ Bits & Pieces 16

Normals

Normal Mapping

A normal map can be used to modify normals.

Advanced Graphics โ€“ Bits & Pieces 17

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 18

Normals

Todayโ€™s Agenda:

โ–ช On Offsetting Shadows and Reflections

โ–ช Consistent Normal Interpolation

โ–ช Path Classification

โ–ช Packing Normals

โ–ช Multiple Importance Sampling, One More Time

โ–ช Research Directions

Paths

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

Paths

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.

Paths

Advanced Graphics โ€“ Bits & Pieces 22

Heckbertโ€™s Path Notation*

Vertex types:

โ–ช L: lightโ–ช E: eyeโ–ช S: specularโ–ช D: diffuse

(D)+ one or more diffuse vertices(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.

Paths

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-styleEDL: Whitted-style, with next event estimationEDSL: Photon mapping, direct visualization of the photon mapEDD(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?

Paths

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-styleEDL: Whitted-style, with next event estimationEDSL: Photon mapping, direct visualization of the photon mapEDD(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

Paths

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

Paths

Advanced Graphics โ€“ Bits & Pieces 26

Paths

Advanced Graphics โ€“ Bits & Pieces 27

Todayโ€™s Agenda:

โ–ช 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?

Packing

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

}

Packing

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

}

Packing

Advanced Graphics โ€“ Bits & Pieces 31

Todayโ€™s Agenda:

โ–ช On Offsetting Shadows and Reflections

โ–ช Consistent Normal Interpolation

โ–ช Path Classification

โ–ช Packing Normals

โ–ช Multiple Importance Sampling, One More Time

โ–ช Research Directions

MIS

Method 1: direct light sampling

โ–ช Samples only the part of the hemisphere occupied by unoccluded light sources.

โ–ช 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

MIS

โˆ’๐œ‹ ๐œ‹

โˆ’๐œ‹ ๐œ‹

๐‘๐‘‘๐‘“ = แ‰

1

๐‘ ๐‘œ๐‘™๐‘–๐‘‘ ๐‘Ž๐‘›๐‘”๐‘™๐‘’0

angle

๐‘Ž๐‘Ÿ๐‘’๐‘Ž = เถฑโˆ’๐œ‹

๐œ‹

๐‘๐‘œ๐‘ ๐œƒ

๐‘๐‘‘๐‘“ =cos ๐œƒ

๐œ‹

Advanced Graphics โ€“ Bits & Pieces 34

MIS

เถฑ ๐‘“ ๐‘ฅ ๐‘‘๐‘ฅ = ๐ธ ๐‘“ ๐‘ฅ โ‰ˆ1

๐‘

๐‘–=1

๐‘

๐‘“ ๐‘‹๐‘–

๐ธ ๐‘“ ๐‘ฅ โ‰ˆ1

๐‘

๐‘–=1

๐‘๐‘“ ๐‘‹๐‘–

๐‘ ๐‘‹๐‘–

๐‘™๐‘Ž๐‘Ÿ๐‘”๐‘’ ๐‘ฃ๐‘Ž๐‘™๐‘ข๐‘’

๐‘ ๐‘š๐‘Ž๐‘™๐‘™ ๐‘ฃ๐‘Ž๐‘™๐‘ข๐‘’= ๐‘ฃ๐‘’๐‘Ÿ๐‘ฆ ๐‘™๐‘Ž๐‘Ÿ๐‘”๐‘’

๐‘™๐‘Ž๐‘Ÿ๐‘”๐‘’ ๐‘ฃ๐‘Ž๐‘™๐‘ข๐‘’

๐‘™๐‘Ž๐‘Ÿ๐‘”๐‘’ ๐‘ฃ๐‘Ž๐‘™๐‘ข๐‘’โ‰ˆ 1

Advanced Graphics โ€“ Bits & Pieces 35

Using two pdfs:

randomly pick one.

MIS

๐ธ ๐‘“ ๐‘‹ โ‰ˆ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 weightto 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 (!).

MIS

๐ธ ๐‘“ าง๐‘ฅ โ‰ˆ

๐‘–=1

๐‘1

๐‘๐‘–

๐‘—=1

๐‘๐‘–

๐œ”๐‘–(๐‘‹๐‘–,๐‘—)๐‘“ ๐‘‹๐‘–,๐‘—

๐‘๐‘– ๐‘‹๐‘–,๐‘—

iterate over the available techniques

draw ๐‘๐‘– samples using technique ๐‘–

apply a weightto 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.

MIS

๐œ”๐ด ๐‘‹๐ด

๐‘“ ๐‘‹๐ด

๐‘๐ด ๐‘‹๐ด

๐œ”๐ต ๐‘‹๐ต

๐‘“ ๐‘‹๐ต

๐‘๐ต ๐‘‹๐ต=

๐‘๐ต(๐‘‹๐ต)

๐‘๐ด(๐‘‹๐ต) +๐‘๐ต (๐‘‹๐ต)

๐‘“ ๐‘‹๐ต

๐‘๐ต ๐‘‹๐ต=

๐‘“ ๐‘‹๐ต

๐‘๐ด ๐‘‹๐ต +๐‘๐ต (๐‘‹๐ต)

=๐‘๐ด(๐‘‹๐ด)

๐‘๐ด(๐‘‹๐ด) +๐‘๐ต (๐‘‹๐ด)

๐‘“ ๐‘‹๐ด

๐‘๐ด ๐‘‹๐ด=

๐‘“ ๐‘‹๐ด

๐‘๐ด ๐‘‹๐ด +๐‘๐ต (๐‘‹๐ด)

=๐‘“ ๐‘‹๐ด

๐‘๐ด ๐‘‹๐ด + ๐‘๐ต(๐‘‹๐ด)+

๐‘“ ๐‘‹๐ต

๐‘๐ด(๐‘‹๐ต) + ๐‘๐ต ๐‘‹๐ต

Advanced Graphics โ€“ Bits & Pieces 38

Todayโ€™s Agenda:

โ–ช On Offsetting Shadows and Reflections

โ–ช Consistent Normal Interpolation

โ–ช Path Classification

โ–ช Packing Normals

โ–ช Multiple Importance Sampling, One More Time

โ–ช Research Directions

Topics

Path tracingBVHGPGPU

---------------

FilteringBlue noiseMaterials

---------------

Large scenesSubdivision surfaces, hair, displacement mapsMany lightsGeometry compression

Future Work

Advanced Graphics โ€“ Bits & Pieces 40

Todayโ€™s Agenda:

โ–ช On Offsetting Shadows and Reflections

โ–ช Consistent Normal Interpolation

โ–ช Path Classification

โ–ช Packing Normals

โ–ช Multiple Importance Sampling, One More Time

โ–ช Research Directions

INFOMAGR โ€“ Advanced GraphicsJacco Bikker - November 2018 โ€“ February 2019

END of โ€œBits & Piecesโ€next lecture: โ€œGrand Recapโ€