Ray Tracing CS 148: Summer 2016 Introduction of Graphics and - - PowerPoint PPT Presentation

ray tracing
SMART_READER_LITE
LIVE PREVIEW

Ray Tracing CS 148: Summer 2016 Introduction of Graphics and - - PowerPoint PPT Presentation

Ray Tracing CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain https://en.wikipedia.org/wiki/Ray_tracing_%28graphics%29 Paths of Light http://software.intel.com/file/37491 2 CS 148: Introduction to Computer Graphics and


slide-1
SLIDE 1

CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain

Ray Tracing

https://en.wikipedia.org/wiki/Ray_tracing_%28graphics%29

slide-2
SLIDE 2

Paths of Light

http://software.intel.com/file/37491

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 2

slide-3
SLIDE 3

Paths of Light

Light source

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3

http://software.intel.com/file/37491

slide-4
SLIDE 4

Paths of Light

Light interacts with

  • bjects in scene

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 4

http://software.intel.com/file/37491

slide-5
SLIDE 5

Paths of Light

Image plane

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 5

http://software.intel.com/file/37491

slide-6
SLIDE 6

Problem

??

Most light do not reach the camera

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 6

http://software.intel.com/file/37491

slide-7
SLIDE 7

Forward Ray Tracing

Trace rays from light to camera

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 7

slide-8
SLIDE 8

Backward Ray Tracing

Trace rays from light to camera

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 8

slide-9
SLIDE 9

Ray Tracing Algorithm

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 9

  • Trace a ray through each pixel
  • Intersect with geometry
  • Trace a shadow ray to the light
  • Shade the pixel

http://www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-ray-tracing/implementing-the-raytracing-algorithm

slide-10
SLIDE 10

Ray Tracing Algorithm

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 10 http://www.scratchapixel.com

  • Trace a ray through each pixel
  • Intersect with geometry
  • Trace a shadow ray to the light
  • Shade the pixel
  • Shadow if light not visible
slide-11
SLIDE 11

Simple to implement

  • For a simple case:
  • http://www.scratchapixel.com/code.php?id=3&origin=/l

essons/3d-basic-rendering/introduction-to-ray-tracing

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 11

Few lines of code; already impressive

slide-12
SLIDE 12

Recursive Ray Tracing

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 12 http://www.scratchapixel.com/images/upload/ray-tracing-refresher/rt-whitted-example.png?

slide-13
SLIDE 13

Whitted Ray Tracing

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 13

  • T. Whitted, Communications of ACM, 1980

Render Time: 74 minutes

slide-14
SLIDE 14

Today: nVidia OptiX

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 14

Render Time: 16 ms ! (60 fps): my Macbook Pro nVidia GTX M750

slide-15
SLIDE 15

Today: Realism

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 15 http://images.povcomp.com/entries/images/105_main.jpg

slide-16
SLIDE 16

Today: Realism

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 16 http://images.povcomp.com/entries/images/105_main.jpg

slide-17
SLIDE 17

Rasterizer Vs Ray-Tracing

Rasterization

for (each object in scene) drawObject();

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 17

slide-18
SLIDE 18

Rasterizer Vs Ray-Tracing

Rasterization Ray Tracing

for (each object in scene) drawObject(); for (each pixel in image) sendRay();

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 18

slide-19
SLIDE 19

Rasterization Vs Ray Tracing

Rasterization Ray Tracing

for (each object in scene) drawObject(); for (each pixel in image) sendRay();

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 19

slide-20
SLIDE 20

Math for Ray Tracing

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 20

slide-21
SLIDE 21

Ray

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 21

slide-22
SLIDE 22

Ray

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 22

slide-23
SLIDE 23

Ray

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 23

slide-24
SLIDE 24

Generating a Ray

No perspective transformation needed!

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 24

slide-25
SLIDE 25

Ray Intersection With a Sphere

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 25

slide-26
SLIDE 26

Ray Intersection With a Sphere

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 26

slide-27
SLIDE 27

Ray Intersection with a Sphere

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 27

slide-28
SLIDE 28

Ray Intersection with a Sphere

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 28

slide-29
SLIDE 29

Ray Intersection With a Sphere

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 29

slide-30
SLIDE 30

Ray Intersection With a Sphere

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 30

slide-31
SLIDE 31

Ray Intersection With a Sphere

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 31

If t* < 0 then what ?

slide-32
SLIDE 32

Sphere Surface Normal

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 32

slide-33
SLIDE 33

Surface Normal

http://designjk.files.wordpress.com/2011/12/teapot-decorated.png CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 33

slide-34
SLIDE 34

Shadow Ray / Light Ray

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 34

slide-35
SLIDE 35

Reflection Vector (Recap)

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 35

Note the directions !

http://graphics.stanford.edu/courses/cs148-10-summer/docs/2006--degreve--reflection_refraction.pdf

~ vi

slide-36
SLIDE 36

Refraction Vector (Extra)

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 36

~ vi

http://graphics.stanford.edu/courses/cs148-10-summer/docs/2006--degreve--reflection_refraction.pdf

slide-37
SLIDE 37

Shadows

http://2.bp.blogspot.com/-2CpxoSdtNE8/T5nMClgobpI/AAAAAAAAAJ4/XgaZ168HpKg/s1600/P0008_I004.png CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 37

slide-38
SLIDE 38

Shadow Acne / Peter Panning

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 38

Real life issues !

slide-39
SLIDE 39

Object-Oriented Ray Tracing

abstract class surface virtual hit-record hit(ray, t0, t1) virtual box bounding-box() struct hit-record vector3d position, normal surface hit-surface … abstract class material color evaluate(in-ray, normal, pos) …

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 39

slide-40
SLIDE 40

Recursive Ray Tracing

color ray-trace(ray r) hit-record record = intersect(r); … if (record.hit-surface.is-reflective) ray reflected-ray = reflect(r,record.normal); color reflected-color = ray-trace(reflected-ray); compute-spectral-component( reflected-color); …

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 40

slide-41
SLIDE 41

Recursion Depth

Lots of bounces Fewer bounces

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 41

Avoid infinite recursion: stop after nth depth (typically n=5)

slide-42
SLIDE 42

Aliasing: Still Problematic!

http://www.hackification.com/2008/08/31/experiments-in-ray-tracing-part-8-anti-aliasing/

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 42

slide-43
SLIDE 43

Distribution Ray Tracing

Scatter rays to make ray tracing less crisp.

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 43

slide-44
SLIDE 44

Distribution Antialiasing

Multiple rays per pixel

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 44

slide-45
SLIDE 45

Distribution Antialiasing

Moiré pattern

http://upload.wikimedia.org/wikipedia/commons/f/fb/Moire_pattern_of_bricks_small.jpg CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 45

Patterned Noise

slide-46
SLIDE 46

Random Sampling

http://en.wikipedia.org/wiki/File:Moire_pattern_of_bricks.jpg CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 46

We are less sensitive to granular noise

slide-47
SLIDE 47

Not Enough Samples!

? ? ?

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 47

slide-48
SLIDE 48

Stratified (Jittered) Sampling

One ray per box

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 48

slide-49
SLIDE 49

Accelerated Ray Tracing

http://sopra.le-gousteau.de/images/2/2e/Bv_bvh_bspheres.jpg http://graphics.ucsd.edu/courses/rendering/2004/ssaha/index_files/finalbvh.jfif

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 49

Bounding Volume Hierarchy (BVH)

slide-50
SLIDE 50

Accelerated Ray Tracing

http://sopra.le-gousteau.de/images/2/2e/Bv_bvh_bspheres.jpg http://graphics.ucsd.edu/courses/rendering/2004/ssaha/index_files/finalbvh.jfif

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 50

Bounding Volume Hierarchy (BVH)

slide-51
SLIDE 51

Asymptotic Speed

  • Rasterization:

O(bm)

  • Ray tracing:

O(bp)

  • Accelerated ray tracing:

O(p log b)

Value Variable

p Pixels on screen b Objects in scene m Average pixels/object

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 51

slide-52
SLIDE 52

Some Real-life Effects

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 52

slide-53
SLIDE 53

Soft Shadows

http://erich.realtimerendering.com/shadow_comparison.html

Hard shadows Soft shadows

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 53

slide-54
SLIDE 54

Soft Shadows

http://user.online.be/felixverbelen/lunecl.jpg

Lights aren’t all point sources

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 54

slide-55
SLIDE 55

Distribution Soft Shadows

Randomly sample light rays: Area Light

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 55

slide-56
SLIDE 56

Distribution Soft Shadows

Shadow computed per ray: Average intensity

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 56

Shadow Caster

slide-57
SLIDE 57

Distribution Soft Shadows

Shadow computed per ray: Average intensity

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 57

Shadow Caster

slide-58
SLIDE 58

Depth of Field

http://liam887.files.wordpress.com/2010/08/weaver.jpg CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 58

slide-59
SLIDE 59

Distribution Depth of Field

Randomly sample eye positions

Square lens

“Focus plane”

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 59

slide-60
SLIDE 60

Distribution Glossy Reflection

https://graphics.stanford.edu/wikis/cs148-11-fall/RaytracingResults http://www.baylee-online.net/Projects/Raytracing/Algorithms/Glossy-Reflection-Transmission

Randomly sample reflected rays

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 60

slide-61
SLIDE 61

Motion Blur

http://www.matkovic.com/anto/3dl-test-balls-01.jpg

Randomly sample positions

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 61

slide-62
SLIDE 62

Advanced Ray-Tracing

  • Image Synthesis Technique: CS 348b

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 62

slide-63
SLIDE 63

Rendering Equation (Holy Grail)

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 63

slide-64
SLIDE 64

Global Illumination

Account for indirect lighting

http://en.wikipedia.org/wiki/Global_illumination CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 64

slide-65
SLIDE 65

Global Illumination

Diffuse inter-reflection

http://en.wikipedia.org/wiki/Global_illumination CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 65

slide-66
SLIDE 66

Global Illumination

http://en.wikipedia.org/wiki/Global_illumination CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 66

Color Bleed

slide-67
SLIDE 67

Global Illumination

http://en.wikipedia.org/wiki/Global_illumination CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 67

Caustics

slide-68
SLIDE 68

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 68

Difficult Paths

http://candela.stanford.edu/cs348b-14/doku.php?id=lectures:lecture17:slide6

Bi-Directional Path Tracing

slide-69
SLIDE 69

Bi-directional Path Tracing

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 69

slide-70
SLIDE 70

Challenge: Real-Time Ray Tracing

“Embarrassingly parallel,” but not SIMD?

[NVIDIA, SIGGRAPH 2008] CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 70

slide-71
SLIDE 71

Remarks

  • Debugging: One solution
  • https://github.com/zdevito/vdb
  • PBRT : Physically Based Rendering Toolkit
  • http://www.pbrt.org

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 71

CS 348b

slide-72
SLIDE 72

CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain

Ray Tracing

https://en.wikipedia.org/wiki/Ray_tracing_%28graphics%29