COMP30019 Graphics and Interaction Ray Tracing Adrian Pearce - - PowerPoint PPT Presentation

comp30019 graphics and interaction ray tracing
SMART_READER_LITE
LIVE PREVIEW

COMP30019 Graphics and Interaction Ray Tracing Adrian Pearce - - PowerPoint PPT Presentation

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil COMP30019 Graphics and Interaction Ray Tracing Adrian Pearce Department of Computer Science and Software


slide-1
SLIDE 1

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

COMP30019 Graphics and Interaction Ray Tracing

Adrian Pearce

Department of Computer Science and Software Engineering University of Melbourne

The University of Melbourne

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-2
SLIDE 2

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Lecture outline

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil Buffer

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-3
SLIDE 3

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

What alternatives are there to the rendering pipeline approach?

Aim: understand the computational implications of ray tracing and the radiance illumination model. Reading:

◮ 13.4 Visible-surface ray tracing and 14.7 Recursive Ray

tracing and Foley Sections 12.4.8 Shadows.

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-4
SLIDE 4

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Alternative to rendering pipeline: Ray tracing

Idea is simple: tracing backwards the path of each ray of light entering the camera to find out what objects it encountered, and what light sources it came from!

  • 1. Each pixel in the created image corresponds to a line of

sight.

  • 2. Start from image not polygon or object as in rendering

pipeline approach.

  • 3. We can trace back this line of sight (ray) to find the nearest
  • bject surface it intersects.

At this inter point, we can check for visibility of light sources, and compute Lambertian, ambient, and specular contributions to our ray.

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-5
SLIDE 5

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Recursive rays

T2 N3 R3 N1 Viewpoint Point light source Ni Surface normal Ri Reflected ray Li Shadow ray Ti Transmitted ray R2 N2 R1 L2 L3 L1 T1

(Foley Figure 14.35) Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-6
SLIDE 6

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-7
SLIDE 7

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil fxguide: A SSS render using Lightstage data Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-8
SLIDE 8

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Real-time ray tracing?

The cardinality (or size) of the ray tracing problem is determined by the number of pixels in the image or viewport, as

  • pposed to the number of polygons in the scene as in the

rendering pipeline approach. In addition, ray tracing is made more computationally intensive by the recursive nature of ray tracing (depending upon what order you assume in terms of how many re-reflections of rays you cater for).

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-9
SLIDE 9

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil Octane Render: raltime ray tracing Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-10
SLIDE 10

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil Octane Render: realtime ray tracing Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-11
SLIDE 11

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Some real-time ray tracing techiques

Quite a large number of approaches to speed up.

◮ Pre-baking, ◮ OpenRL (low level interactive ray tracing API), ◮ Bounding volumes, e.g. Binary space parition trees (BSPs) ◮ . . .

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-12
SLIDE 12

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

World space scene intersection in Unity 5

http://www.gdcvault.com/play/1020688/ Practical-Techniques-for-Ray-Tracing

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-13
SLIDE 13

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Binary Space Partition (BSP) Trees

Binary partition sort (akin to quicksort):

◮ Choose a face ◮ Partition other faces into those closer or farther than the

plane of this face (cutting faces where they straddle the partitioning plane)

◮ Recursively work on the partitions, until single faces

Note: This partitioning structure (tree) is invariant to change of viewpoint

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-14
SLIDE 14

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

A BSP tree representation in two-dimensions (2D)

a b j c e k

  • ut

d

  • ut

in

  • ut

in

  • ut

in i in

  • ut

g h

  • ut

f in

  • ut

(b) (a) a b c d e f g h i j k

(a) A concave polygon bounded by black lines.(b) The BSP tree.

Foley Figure 10.19

◮ Lines defining the half-spaces are dark grey, and in cells

are light grey.

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-15
SLIDE 15

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

The BSP tree algorithm is an extremely efficient method for calculating the visibility relationships among a static group of 3D polygons as seen from an arbitrary viewpoint.

◮ Remarkably, the BSP tree can be traversed in a modified

in-order tree walk to yield a correct priority ordered polygon list.

◮ Based on relationship to polygons surface normal. ◮ unlike other approaches where data structures need

re-calculating (note, if using z-buffering, or scan-line variant rely on sortedness of polygons, and as viewpoint changes will need to re-sort these lists.

◮ Downside: need to pre-process all polygons.

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-16
SLIDE 16

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Refraction

When going from one medium to another, a ray of light will be bent at the intermediate surface. This bending, refraction, is governed by Snell’s Law: sin θi sin θt = ηtλ ηiλ where θi is the angle of incidence, θt is the angle of refraction and ηtλ and ηiλ are the indices of refraction of each material as a function of wavelength λ. Notice that, for a solid piece of transparent material, light will be refracted both on entering and leaving the material.

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-17
SLIDE 17

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Calculating the Refraction vector

N N cosθi θi sinθtM N cosθi – I θt –N –cos θtN I M = (N cosθi – I) /sinθi T = sinθt M – cosθtN (Foley Figure 14.32) Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-18
SLIDE 18

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Transparency

Some of this loss is from reflection at the surfaces as the light enters and leaves the object. This is the factor t. The rest of the loss is from absorption within the transparent material. A constant increase in path length within the material reduces the light by a constant factor, leading to an exponential behaviour. T = te−ad where a is parameter, and d is the distance travelled within the material. Note, because light may take an oblique path, the distance d is not usually the same as the thickness of the material.

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-19
SLIDE 19

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-20
SLIDE 20

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-21
SLIDE 21

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Shadow volumes & the Stencil Buffer

Light Object C B A

A front facing shadow polygon, A or B in above Figure, causes polygons behind it to be shadowed.

(Foley Figure 14.28) Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-22
SLIDE 22

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Scan-line generation of shadows

A′ a b c d B A Light Viewer Current scan line

(Foley Figure 14.27) Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing

slide-23
SLIDE 23

Ray tracing Recursive Ray Tracing Binary Space Partition (BSP) Trees Refraction Transparency Shadow volumes & the Stencil

Stencil buffer & Shadow Volumes toolkit - Unity

Adrian Pearce University of Melbourne COMP30019 Graphics and InteractionRay Tracing