Lecture 2 - Whitted Welcome! , = (, ) , - - PowerPoint PPT Presentation

β–Ά
lecture 2 whitted
SMART_READER_LITE
LIVE PREVIEW

Lecture 2 - Whitted Welcome! , = (, ) , - - PowerPoint PPT Presentation

INFOMAGR Advanced Graphics Jacco Bikker - November 2019 - February 2020 Lecture 2 - Whitted Welcome! , = (, ) , + , , ,


slide-1
SLIDE 1

𝑱 π’š, π’šβ€² = 𝒉(π’š, π’šβ€²) 𝝑 π’š, π’šβ€² + ΰΆ±

𝑻

𝝇 π’š, π’šβ€², π’šβ€²β€² 𝑱 π’šβ€², π’šβ€²β€² π’†π’šβ€²β€²

INFOMAGR – Advanced Graphics

Jacco Bikker - November 2019 - February 2020

Lecture 2 - β€œWhitted”

Welcome!

slide-2
SLIDE 2

Today’s Agenda:

β–ͺ Introduction: Appel β–ͺ Whitted β–ͺ Cook β–ͺ Assignment 1

slide-3
SLIDE 3

Some Techniques for Shading Machine Renderings of Solids, Arthur Appel, 1964.

Idea: use rays to find geometry and shadows.

Appel

Advanced Graphics – Whitted 3

slide-4
SLIDE 4

Recap

Appel

Advanced Graphics – Whitted 4 𝑄0 𝑄

1

𝑄2 𝐹 u v Plane: 𝑄 βˆ™ 𝑂 + 𝑒 = 0 Ray: 𝑄(𝑒) = 𝑃 + 𝑒𝐸 Substituting for 𝑄(𝑒), we get 𝑃 + 𝑒𝐸 βˆ™ 𝑂 + 𝑒 = 0 𝑒 = βˆ’(𝑃 βˆ™ 𝑂 + 𝑒)/(𝐸 βˆ™ 𝑂) 𝑄 = 𝑃 + 𝑒𝐸

slide-5
SLIDE 5

Appel

Advanced Graphics – Whitted 5 Ray: 𝑄(𝑒) = 𝑃 + 𝑒𝐸

𝒖

slide-6
SLIDE 6

Appel

Advanced Graphics – Whitted 6

slide-7
SLIDE 7

Today’s Agenda:

β–ͺ Introduction: Appel β–ͺ Whitted β–ͺ Cook β–ͺ Assignment 1

slide-8
SLIDE 8

An Improved Illumination Model for Shaded Display

In 1980, β€œState of the Art” consisted of: β–ͺ Rasterization β–ͺ Shading: either diffuse (N Β· L) or specular ((N Β· H)n), both not taking into account fall-off (Phong) β–ͺ Reflection, using environment maps (Blinn & Newell *) β–ͺ Stencil shadows (Williams **)

Whitted

** : Williams, L. 1978. Casting curved shadows on curved surfaces.. * : Blinn, J. and Newell, M. 1976. Texture and Reflection in Computer Generated Images.

Advanced Graphics – Whitted 8

slide-9
SLIDE 9

An Improved Illumination Model for Shaded Display

In 1980, β€œState of the Art” consisted of: β–ͺ Rasterization β–ͺ Shading: either diffuse (N Β· L) or specular ((N Β· H)n), both not taking into account fall-off (Phong) β–ͺ Reflection, using environment maps (Blinn & Newell) β–ͺ Stencil shadows (Williams) Goal: β–ͺ Solve reflection and refraction Improved model: β–ͺ Based on classical ray optics

Whitted

Advanced Graphics – Whitted 9

slide-10
SLIDE 10

An Improved Illumination Model for Shaded Display*

Physical basis of Whitted-style ray tracing: Light paths are generated (backwards) from the camera to the light sources, using rays to simulate optics.

Color Trace( ray r ) I, N, mat = NearestIntersection( scene, r ) return mat.color * DirectIllumination( I, N )

Whitted

* : T. Whitted. An Improved Illumination Model for Shaded Display.

  • Commun. ACM, 23(6):343–349, 1980.

Advanced Graphics – Whitted 10

slide-11
SLIDE 11

An Improved Illumination Model for Shaded Display

Color Trace( ray r ) I, 𝑂, mat = NearestIntersection( scene, r ) return mat.color * DirectIllumination( I, 𝑂 )

Direct illumination: Summed contribution of unoccluded point light sources, taking into account: β–ͺ Distance to I β–ͺ Angle between 𝑀 and 𝑂 β–ͺ Intensity of light source Note that this requires a ray per light source.

Whitted

Advanced Graphics – Whitted 11

slide-12
SLIDE 12

An Improved Illumination Model for Shaded Display

Color Trace( ray r ) I, 𝑂, mat = NearestIntersection( scene, r ) if (mat == DIFFUSE) return mat.color * DirectIllumination( I, 𝑂 ) if (mat == MIRROR) return mat.color * Trace( I, reflect( r.𝐸, 𝑂 )

Indirect illumination: For perfect specular object (mirrors) we extend the primary ray with an extension ray: β–ͺ We still modulate transport with the material color β–ͺ We do not apply 𝑂 βˆ™ 𝑀 β–ͺ We do not calculate direct illumination

Whitted

Advanced Graphics – Whitted 12

slide-13
SLIDE 13

Reflection

Given a ray direction 𝐸 and a normalized surface normal 𝑂, the reflected vector 𝑆 = 𝐸 βˆ’ 2(𝐸 βˆ™ 𝑂)𝑂. Derivation: π‘Š = 𝑂(𝐸 βˆ™ 𝑂) 𝑉 = 𝐸 βˆ’ Τ¦ 𝑀 𝑆 = 𝑉 + (βˆ’π‘Š) 𝑆 = 𝐸 βˆ’ 𝑂 𝐸 βˆ™ 𝑂 βˆ’ 𝑂(𝐸 βˆ™ 𝑂) 𝑆 = 𝐸 βˆ’ 2(𝐸 βˆ™ 𝑂)𝑂

Whitted

𝑆 𝐸 𝑢 π‘Š 𝑉 Advanced Graphics – Whitted 13

slide-14
SLIDE 14

Question 1: For direct illumination, we take into account: β–ͺ Material color β–ͺ Distance to light source β–ͺ 𝑂 βˆ™ 𝑀 Why? Question 2: We use the summed contribution of all light sources. Is this correct? Question 3: Why do we not sample the light sources for a pure specular surface? (can you cast a shadow on a bathroom mirror?) Question 4: Prove geometrically that, for normalized vectors 𝐸 and 𝑂, 𝑆 = 𝐸 βˆ’ 2 𝐸 βˆ™ 𝑂 𝑂 yields a normalized vector.

Whitted

Advanced Graphics – Whitted 14

slide-15
SLIDE 15

An Improved Illumination Model for Shaded Display

Handling partially reflective materials:

Color Trace( ray r ) I, 𝑂, mat = NearestIntersection( scene, r ) s = mat.specularity d = 1 – mat.specularity return mat.color * ( s * Trace( ray( I, reflect( r.𝐸, 𝑂 ) ) ) + d * DirectIllumination( I, 𝑂 ) )

Note: this is not efficient. (why not?)

Whitted

Advanced Graphics – Whitted 15

slide-16
SLIDE 16

An Improved Illumination Model for Shaded Display

Dielectrics

Color Trace( ray r ) I, 𝑂, mat = NearestIntersection( scene, r ) if (mat == DIFFUSE) return mat.color * DirectIllumination( I, 𝑂 ) if (mat == MIRROR) return mat.color * Trace( I, reflect( r.𝐸, 𝑂 ) if (mat == GLASS) return mat.color * ?

Whitted

Advanced Graphics – Whitted 16

slide-17
SLIDE 17

Dielectrics

The direction of the transmitted vector π‘ˆ depends on the refraction indices π‘œ1, π‘œ2 of the media separated by the surface. According to Snell’s Law: π‘œ1π‘‘π‘—π‘œπœ„1 = π‘œ2π‘‘π‘—π‘œπœ„2

  • r

π‘œ1 π‘œ2 π‘‘π‘—π‘œπœ„1 = π‘‘π‘—π‘œπœ„2 Note: left term may exceed 1, in which case πœ„2 cannot be computed. Therefore:

π‘œ1 π‘œ2 π‘‘π‘—π‘œπœ„1 = π‘‘π‘—π‘œπœ„2 ⟺ π‘‘π‘—π‘œπœ„1 ≀ π‘œ2 π‘œ1 βž” πœ„π‘‘π‘ π‘—π‘’π‘—π‘‘π‘π‘š = arcsin π‘œ2 π‘œ1 sin πœ„2

Whitted

π‘ˆ 𝐸 𝑢 π‘œ1 π‘œ2 πœ„2 πœ„1 Advanced Graphics – Whitted 17

slide-18
SLIDE 18

Dielectrics

π‘œ1 π‘œ2 π‘‘π‘—π‘œπœ„1 = π‘‘π‘—π‘œπœ„2 ⟺ π‘‘π‘—π‘œπœ„1 ≀ π‘œ2 π‘œ1

𝑙 = 1 βˆ’ π‘œ1 π‘œ2

2

1 βˆ’ π‘‘π‘π‘‘πœ„1

2

π‘ˆ = ࡞ π‘ˆπ½π‘†, 𝑔𝑝𝑠 𝑙 < 0 π‘œ1 π‘œ2 𝐸 + 𝑂 π‘œ1 π‘œ2 π‘‘π‘π‘‘πœ„1 βˆ’ 𝑙 , 𝑔𝑝𝑠 𝑙 β‰₯ 0 Note: π‘‘π‘π‘‘πœ„1 = 𝑂 βˆ™ βˆ’πΈ, and π‘œ1

π‘œ2 should be calculated only once.

* For a full derivation, see http://www.flipcode.com/archives/reflection_transmission.pdf

Whitted

π‘ˆ 𝐸 𝑢 π‘œ1 π‘œ2 πœ„2 πœ„1 Advanced Graphics – Whitted 18

slide-19
SLIDE 19

Dielectrics

A typical dielectric transmits and reflects light.

Whitted

π‘ˆ 𝐸 𝑢 𝑆 Advanced Graphics – Whitted 19

slide-20
SLIDE 20

Dielectrics

A typical dielectric transmits and reflects light. Based on the Fresnel equations, the reflectivity of the surface for non-polarized light is formulated as:

𝐺

𝑠 = 1

2 π‘œ1π‘‘π‘π‘‘πœ„π‘— βˆ’ π‘œ2 cos πœ„π‘’ π‘œ1π‘‘π‘π‘‘πœ„π‘— + π‘œ2 cos πœ„π‘’

2

+ π‘œ1 cos πœ„π‘’ βˆ’ π‘œ2 cos πœ„π‘— π‘œ1 cos πœ„π‘’ + π‘œ2 cos πœ„π‘—

2 Where: cos πœ„π‘’ = 1 βˆ’

π‘œ1 π‘œ2 sin πœ„π‘— 2

Whitted

Advanced Graphics – Whitted 20

Reflectance for s-polarized light Reflectance for p-polarized light Reflectance for unpolarized light

slide-21
SLIDE 21

Dielectrics

𝐺

𝑠 = β‹―

Based on the law of conservation of energy: 𝐺𝑒 = 1 βˆ’ 𝐺

𝑠

Whitted

π‘ˆ 𝐸 𝑢 𝑆 Advanced Graphics – Whitted 21

slide-22
SLIDE 22

Ray Tracing

World space β–ͺ Geometry β–ͺ Eye β–ͺ Screen plane β–ͺ Screen pixels β–ͺ Primary rays β–ͺ Intersections β–ͺ Point light β–ͺ Shadow rays Light transport β–ͺ Extension rays Light transport Advanced Graphics – Whitted 22

Whitted

slide-23
SLIDE 23

Ray Tree

Using Whitted-style ray tracing, hitting a surface point may spawn: β–ͺ a shadow ray for each light source; β–ͺ a reflection ray; β–ͺ a ray transmitted into the material. The reflected and transmitted rays may hit another object with the same material. βž” A single primary ray may lead to a very large number of ray queries. Advanced Graphics – Whitted 23

Whitted

slide-24
SLIDE 24

Question 5: imagine a scene with several point lights and dielectric materials. Considering the law of conservation of energy, what can you say about the energy transported by each individual ray? Advanced Graphics – Whitted 24

Whitted

slide-25
SLIDE 25

Beer’s Law

Advanced Graphics – Whitted 25

Whitted

slide-26
SLIDE 26

Beer’s Law

Light travelling through a medium loses intensity due to absorption. The intensity 𝐽(𝑒) that remains after travelling 𝑒 units through a substance with absorption 𝑏 is: 𝐽 𝑒 = 𝐽 0 π‘“βˆ’ ln 𝑏 𝑒 In pseudocode:

I.r *= exp( -a.r * d ); I.g *= exp( -a.g * d ); I.b *= exp( -a.b * d );

Advanced Graphics – Whitted 26

Whitted

slide-27
SLIDE 27

Whitted - Summary

A Whitted-style ray tracer implements the following optical phenomena: β–ͺ Direct illumination of multiple light sources, taking into account

Visibility Distance attenuation A shading model: N dot L for diffuse

β–ͺ Pure specular reflections, with recursion β–ͺ Dielectrics, with Fresnel, with recursion β–ͺ Beer’s Law The ray tracer supports any primitive for which a ray/primitive intersection can be determined. Advanced Graphics – Whitted 27

Whitted

slide-28
SLIDE 28

Today’s Agenda:

β–ͺ Introduction: Appel β–ͺ Whitted β–ͺ Cook β–ͺ Assignment 1

slide-29
SLIDE 29

’Distributed Ray Tracing’

Whitted-style ray tracing does not handle glossy reflections, depth of field, motion blur. Advanced Graphics – Whitted 29

Cook

slide-30
SLIDE 30

’Distributed Ray Tracing’

Whitted-style ray tracing does not handle glossy reflections, depth of field, motion blur: Ray tracing is a point sampling process. Cook et al.*: Replace point sampling by integrals: β–ͺ Perform anti-aliasing by integrating over the pixel β–ͺ Add motion blur by integrating over time β–ͺ Calculate depth of field by integrating over the aperture. Advanced Graphics – Whitted 30

Cook

* : Cook et al., 1984. Distributed Ray Tracing.

slide-31
SLIDE 31

Today’s Agenda:

β–ͺ Introduction: Appel β–ͺ Whitted β–ͺ Cook β–ͺ Assignment 1

slide-32
SLIDE 32

Adding a Core to Lighthouse (in 5 minutes)

New: RenderCore_Minimal Advanced Graphics – Whitted 32

Assignment 1

slide-33
SLIDE 33

Advanced Graphics – Whitted 33

Assignment 1

RenderCore_Minimal

A core implements the low-level rendering functionality. To build your own: start by copying an existing one. (project folder βž” docs βž” cloning a core.docx) A core receives raw geometry from the RenderSystem:

void RenderCore::SetGeometry( const int meshIdx, const float4* vertexData, const int vertexCount, const int triangleCount, const CoreTri* triangles, const uint* alphaFlags ) { }

No Note: The core is expected to copy the data it

  • receives. There is no guarantee at all

that the RenderSystem leaves the provided data intact after SetGeometry returns. float4: x, , y, z, z, pa padding also also co contain ver ertices. . raw verts ar are for

  • r in

intersection; tri tris ar are for

  • r sh

shading.

slide-34
SLIDE 34

Advanced Graphics – Whitted 34

Assignment 1

Adding a Core to Lighthouse (in 5 minutes)

New: RenderCore_Minimal float4* vertexData; βž” for( int y = 0; y < 512; y++ ) for( int x = 0; x < 800; x++ ) Plot( x, y, Trace( ray( origin, direction ) ) ); Color Trace( ray r ) I, 𝑂, mat = NearestIntersection( scene, r ) if (mat == DIFFUSE) return mat.color * DirectIllumination( I, 𝑂 ) if (mat == MIRROR) return mat.color * Trace( I, reflect( r.𝐸, 𝑂 ) if (mat == GLASS) return mat.color * ?

slide-35
SLIDE 35

Today’s Agenda:

β–ͺ Introduction: Appel β–ͺ Whitted β–ͺ Cook β–ͺ Assignment 1

slide-36
SLIDE 36

INFOMAGR – Advanced Graphics

Jacco Bikker - November 2019 – February 2020

END of β€œWhitted”

next lecture: β€œAcceleration Structures”