Computer Graphics. - Introduction to Ray Tracing - Philipp Slusallek

Similar documents
Computer Graphics. - Ray Tracing I - Marcus Magnor Philipp Slusallek. Computer Graphics WS05/06 Ray Tracing I

CS348B Lecture 2 Pat Hanrahan, Spring Greeks: Do light rays proceed from the eye to the light, or from the light to the eye?

Intro to Ray-Tracing & Ray-Surface Acceleration

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

Computer Graphics Ray Casting. Matthias Teschner

Photorealism: Ray Tracing

CPSC GLOBAL ILLUMINATION

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Global Illumination The Game of Light Transport. Jian Huang

Sung-Eui Yoon ( 윤성의 )

Supplement to Lecture 16

Illumination Algorithms

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Global Illumination CS334. Daniel G. Aliaga Department of Computer Science Purdue University

Review for Ray-tracing Algorithm and Hardware

The Traditional Graphics Pipeline

Ray Tracing. Kjetil Babington

The Rendering Equation. Computer Graphics CMU /15-662

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

782 Schedule & Notes

The Traditional Graphics Pipeline

A Brief Overview of. Global Illumination. Thomas Larsson, Afshin Ameri Mälardalen University

Introduction to Visualization and Computer Graphics

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Lecture 10: Ray tracing

COMP371 COMPUTER GRAPHICS

MIT Monte-Carlo Ray Tracing. MIT EECS 6.837, Cutler and Durand 1

The Rendering Equation & Monte Carlo Ray Tracing

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

SUMMARY. CS380: Introduction to Computer Graphics Ray tracing Chapter 20. Min H. Kim KAIST School of Computing 18/05/29. Modeling

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015

rendering equation computer graphics rendering equation 2009 fabio pellacini 1

Lighting and Shading

Recursion and Data Structures in Computer Graphics. Ray Tracing

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

6. Illumination, Lighting

COMPUTER GRAPHICS AND INTERACTION

CHAPTER 1 Graphics Systems and Models 3

Global Illumination. COMP 575/770 Spring 2013

Introduction to Ray-tracing Objectives

Ray-Tracing. Misha Kazhdan

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

Topics and things to know about them:

The Traditional Graphics Pipeline

Raytracing & Epsilon. Today. Last Time? Forward Ray Tracing. Does Ray Tracing Simulate Physics? Local Illumination

Interactive Methods in Scientific Visualization

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Schedule. MIT Monte-Carlo Ray Tracing. Radiosity. Review of last week? Limitations of radiosity. Radiosity

Global Illumination. CSCI 420 Computer Graphics Lecture 18. BRDFs Raytracing and Radiosity Subsurface Scattering Photon Mapping [Ch

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

Raytracing. COSC 4328/5327 Scott A. King

Raytracing CS148 AS3. Due :59pm PDT

Geometric optics. The University of Texas at Austin CS384G Computer Graphics Don Fussell

Lecture 11: Ray tracing (cont.)

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

Shading. Brian Curless CSE 557 Autumn 2017

RAYTRACING. Christopher Peters INTRODUCTION TO COMPUTER GRAPHICS AND INTERACTION. HPCViz, KTH Royal Institute of Technology, Sweden

Monte Carlo Ray-tracing and Rendering

Other Rendering Techniques CSE 872 Fall Intro You have seen Scanline converter (+z-buffer) Painter s algorithm Radiosity CSE 872 Fall

Luxo Jr. (Pixar, 1986) Last Time. Real Cameras and Ray Tracing. Standard Rasterization. Lights, Cameras, Surfaces. Now Playing:

Questions??? Announcements Assignment 3 due today

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Lecture 11. More Ray Casting/Tracing

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Shading Models. Welcome!

Global Illumination. Why Global Illumination. Pros/Cons and Applications. What s Global Illumination

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Computer Graphics. Si Lu. Fall uter_graphics.htm 11/22/2017

A Little Background. Motivation. Motivation

Ray Tracing COMP575/COMP770

03 RENDERING PART TWO

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

The Rendering Equation. Computer Graphics CMU /15-662, Fall 2016

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

Final Project: Real-Time Global Illumination with Radiance Regression Functions

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

CS 6620 Shading. Steve Parker Peter Shirley

COMP environment mapping Mar. 12, r = 2n(n v) v

Shading, Advanced Rendering. Week 7, Wed Feb 28

Korrigeringar: An introduction to Global Illumination. Global Illumination. Examples of light transport notation light

MIT Ray Tracing Ray Tracing

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

Transcription:

Computer Graphics - Introduction to Ray Tracing - Philipp Slusallek

Rendering Algorithms Rendering Definition: Given a 3D scene as input and a camera, generate a 2D image as a view from the camera of the 3D scene Algorithms Ray Tracing Declarative scene description Physically-based simulation of light transport Rasterization Traditional procedural/imperative drawing of a scene content

Scene Surface Geometry 3D geometry of objects in a scene Geometric primitives triangles, polygons, spheres, Surface Appearance Color, texture, absorption, reflection, refraction, subsurface scattering Mirror, glass, glossy, diffuse, Illumination Position and emission characteristics of light sources Note: Light is reflected off of surfaces! Secondary/indirect/global illumination Assumption: air/empty space is totally transparent Simplification that excludes scattering effects in participating media volumes Later also volume objects, e.g. smoke, solid object (CT scan), Camera View point, viewing direction, field of view, resolution,

OVERVIEW OF RAY-TRACING

Ray Tracing Can Produce Realistic Images By simulating light transport

Light Transport (1)

Light Transport (2) Light Distribution in a Scene Dynamic equilibrium Forward Light Transport Shoot photons from the light sources into scene Reflect at surfaces and record when a detector is hit Photons that hit the camera produce the final image Most photons will not reach the camera Particle Tracing Backward Light Transport Start at the detector (camera) Trace only paths that might transport light towards it May try to connect to occluded light sources Ray Tracing

Ray Tracing Is Fundamental rendering algorithm Automatic, simple and intuitive Easy to understand and implement Delivers correct images by default Powerful and efficient Many optical global effects Perspective Machine, Albrecht Dürer Shadows, reflections, refractions, Efficient real-time implementation in SW and HW Can work in parallel and distributed environments Logarithmic scalability with scene size: O(log n) vs. O(n) Output sensitive and demand driven Concept of light rays is not new Empedocles (492-432 BC), Renaissance (Dürer, 1525), Uses in lens design, geometric optics,

Fundamental Ray Tracing Steps Generation of primary rays Rays from viewpoint along viewing directions into 3D scene (At least) one ray per picture element (pixel) Ray casting Traversal of spatial index structures Ray-primitive intersection Shading the hit point Determine pixel color Energy (color) travelling along primary ray Needed Local material color, object texture and reflection properties Local illumination at intersection point Compute through recursive tracing of rays Can be hard to determine correctly

Ray Tracing Pipeline (1) Ray Generation Ray Traversal Intersection Shading Pixel Color

Ray Tracing Pipeline (2) Ray Generation Ray Traversal Intersection Shading Pixel Color

Ray Tracing Pipeline (3) Ray Generation Ray Traversal Intersection Shading Pixel Color

Ray Tracing Pipeline (4) Ray Generation Ray Traversal Intersection Shading Pixel Color

Ray Tracing Pipeline (5) Ray Generation Ray Traversal Intersection Shading Pixel Color

Ray Tracing Pipeline (6) Ray Generation Ray Traversal Intersection Shading Pixel Color

Ray Tracing Pipeline (7) Ray Generation Ray Traversal Intersection Shading Pixel Color

Recursive Ray Tracing reflected ray primary ray pixel light source shadow rays refracted ray image plane Searching recursively for paths to light sources Interaction of light & material at intersections Recursively trace new rays in reflection, refraction, and light direction Reflected Eye Cube Refracted viewpoint Sphere Cylinder

Ray Tracing Algorithm Trace(ray) Search the next intersection point (hit, material) Return Shade(ray, hit, material) Shade(ray, hit, material) For each light source if ShadowTrace(ray to light source, distance to light) Calculate reflected radiance (i.e. Phong) Adding to the reflected radiance If mirroring material Calculate radiance in reflected direction: Trace(R(ray, hit)) Adding mirroring part to the reflected radiance Same for transmission Return reflected radiance ShadowTrace(ray, dist) Return false, if intersection with distance < dist has been found Can be changed to handle transparent objects as well But not with refraction

Shading Intersection point determines primary ray s color Diffuse object: color at intersection point No variation with viewing angle: diffuse (Lambertian) Perfect reflection/refraction (mirror, glass) Only one outgoing direction Trace one secondary ray Non-Lambertian Reflectance Appearance depends on illumination and viewing direction Local Bi-directional Reflectance Distribution Function (BRDF) Illumination Point/directional light sources Area light sources Approximate with multiple samples / shadow rays Indirect illumination See Realistic Image Synthesis (RIS) course in next semester More details later

Common Approximations Usually RGB color model instead of full spectrum Finite # of point lights instead of full indirect light Approximate material reflectance properties Ambient: constant, non-directional background light Diffuse: light reflected uniformly in all directions Specular: perfect reflection, refraction Reflection models are often empirical

Ray Tracing Features Incorporates into a single framework Hidden surface removal Front to back traversal Early termination once first hit point is found Shadow computation Shadow rays/ shadow feelers are traced between a point on a surface and a light sources Exact simulation of some light paths Reflection (reflected rays at a mirror surface) Refraction (refracted rays at a transparent surface, Snell s law) Limitations Many reflections (exponential increase in number of rays) Indirect illumination requires many rays to sample all incoming directions Easily gets inefficient for full global illumination computations Solved with Path Tracing ( later)

Ray Tracing Can Produce Realistic Images By simulating light transport

What is Possible? Models Physics of Global Light Transport Dependable, physically-correct visualization

VW Visualization Center

Realistic Visualization: CAD

Realistic Visualization: VR/AR

Lighting Simulation

What is Possible? Huge Models Logarithmic scaling in scene size 12.5 Million Triangles ~1 Billion Triangles

Outdoor Environments 90 x 10^12 (trillion) triangles

Boeing 777 Boeing 777: ~350 million individual polygons, ~30 GB on disk

Volume Visualization Iso-surface rendering

Games?

Ray Tracing in CG In the Past Only used as an off-line technique Was computationally far too demanding (minutes to hours per frame) Believed to not be suitable for a HW implementation More Recently Interactive ray tracing on supercomputers [Parker, U. Utah 98] Interactive ray tracing on PCs [Wald 01] Distributed Real-time ray tracing on PC clusters [Wald 01] RPU: First full HW implementation [Siggraph 2005] Commercial tools: Embree/OSPRey (Intel/CPU), OptiX (Nvidia/GPU) Complete film industry has switched to ray tracing (Monte-Carlo) Own conference Symposium on Interactive RT, now High-Performance Graphics (HPG) Ray tracing systems Research: PBRT (offline, physically-based, based on book, OSS), Mitsuba renderer (EPFL), imbatracer (SB), Commercial: V-Ray (Chaos Group), Corona (Render Legion), VRED (Autodesk), MentalRay/iRay (MI),

Ray Casting Outside CG Tracing/Casting a ray Type of query Is there a primitive along a ray How far is the closest primitive Other uses than rendering Volume computation Sound waves tracing Collision detection

RAY-PRIMITIVE INTERSECTIONS

Basic Math - Ray Ray parameterization r t = o + t d, t R; o, d R 3 : origin and direction Ray All points on the graph of r t, with t R 0+ t=3 o d t=1 t=2

Pinhole Camera Model // For given image resolution {resx, resy} // Loop over pixel raster coordinates [0, res-1] for(prcx = 0; prcx < resx; prcx++) for(prcy = 0; prcy < resy; prcy++) { // Normalized device coordinates [0, 1] ndcx = (prcx + 0.5) / resx; ndcy = (prcy + 0.5) / resy; // Screen space coordinates [-1, 1] sscx = ndcx * 2-1; sscy = ndcy * 2-1; // Generate direction through pixel center d = f + sscx x + sscy y; d = d / d ; // May normalize here // Trace ray and assign color to pixel color = trace_ray(o, d); write_pixel(prcx, prcy, color); d } Image plane y x spanning vectors u up-vector f focal vector o origin, POV

Basic Math - Sphere Sphere S c R 3, r R: center and radius p R 3 : p S p c p c r 2 = 0 The distance between the points on the sphere and its center equals the radius p 1 p 1 - c c p 2 - c p 2

Ray-Sphere Intersection Given Ray: r t = o + t d, t R; o, d R 3 Sphere: c R 3, r R: p R 3 : p S p c p c r 2 = 0 Find closest intersection point Algebraic approach: substitute ray equation p c p c r 2 = 0 with p = o + t d t 2 d d + 2t d o c + o c ( o c) r 2 = 0 Solve for t

Ray-Sphere Intersection (2) Given Ray: r t = o + t d, t R; o, d R 3 Sphere: c R 3, r R: p R 3 : p S p c p c r 2 = 0 Find closest intersection point Geometric approach Ray and center span a plane Solve in 2D Compute b o, b c OBC = 90 Intersection(s) if b c r r c Be aware of floating point issues if o is far from sphere o d o - c

Basic Math - Plane Plane P n, a R 3 : normal and point in P p R 3 : p P p a n = 0 The difference vector between any two points on the plane is either 0 or orthogonal to the plane s normal n a p 1 - a p 2 p 2 - a n p 1 a

Ray-Plane Intersection Given Ray: r t = o + t d, t R; o, d R 3 Plane: n, a R 3 : normal and point in P Compute intersection point Plane equation: p P p a n = 0 p n D = 0, with D = a n Substitute ray parameterization: ( o + t d) n D = 0 Solve for t 0,1 or infinitely many solutions

Ray-Disc Intersection Intersect ray with plane Discard intersection if p a > r

Basic Math - Triangle Triangle T a, b, c R 3 : vertices Affine combinations of a, b, c points in the plane Non-negative coefficients that sum up to 1 points in the triangle p R 3 : p T λ 1,2,3 R 0+, λ 1 + λ 2 + λ 3 = 1 and p = λ 1 a + λ 2 b + λ 3 c c Barycentric coordinates λ 1,2,3 λ 1 = S pbc /S abc S: signed area of triangles λ 2 λ 3 p λ 1 a b

Barycentric Coordinates Triangle T a, b, c R 3 : vertices λ 1,2,3 : barycentric coordinates λ 1 + λ 2 + λ 3 = 1 λ 1 = S pbc /S abc, etc. c (0, 0, 1) λ 3 = 1 2 ( 1 2, 0, 1 2 ) (0, 1 2, 1 2 ) λ 3 = 1 3 ( 1 3,1 3,1 3 ) a (1,0,0) (0, 1, 0) ( 1, 1, 0) b 2 2

Triangle Intersection: Plane-Based Compute intersection with triangle plane Compute barycentric coordinates Signed areas of subtriangles Can be done in 2D, after projection onto major plane, depending on largest normal vector component Test for positive BCs z o n d y x

Triangle Intersection Edge-Based (1) 3D linear function across triangle (3D edge functions) Ray: o + t d, t R; o, d R 3 Triangle: a, b, c R 3 c a b o d

Triangle Intersection Edge-Based (2) 3D linear function across triangle (3D edge functions) Ray: o + t d, t R; o, d R 3 Triangle: a, b, c R 3 n ab = b o (a o) n ab is the signed area of OAB (2 times) c n ab a b o d

Triangle Intersection Edge-Based (3) 3D linear function across triangle (3D edge functions) Ray: o + t d, t R; o, d R 3 Triangle: a, b, c R 3 n ab = b o (a o) n ab is the signed area of OAB (2 times) λ 3 (t) = n ab t d Volume of OABP (6 times) For t = t hit n ab p c a b o d

Triangle Intersection Edge-Based (4) 3D linear function across triangle (3D edge functions) Ray: o + t d, t R; o, d R 3 Triangle: a, b, c R 3 n ab = b o (a o) n ab is the signed area of OAB (2 times) λ 3 (t) = n ab t d Volume of OABP (6 times) For t = t hit λ 1,2 (t) = n bc,ac t d Normalize λ i = λ i (t) λ 1 (t)+λ 2 (t)+λ 3 (t), i = 1,2,3 Length of t d cancels out o n ab d a p c b

Triangle Intersection Edge-Based (5) 3D linear function across triangle (3D edge functions) Ray: o + t d, t R; o, d R 3 Triangle: a, b, c R 3 n ab = b o (a o) n ab is the signed area of OAB (2 times) λ 3 (t) = n ab t d Volume of OABP (6 times) For t = t hit λ 1,2 (t) = n bc,ac t d Normalize λ i = λ i (t) λ 1 (t)+λ 2 (t)+λ 3 (t), i = 1,2,3 n ab a p c b For positive BCs Compute p = λ 1 a + λ 2 b + λ 3 c o d

Quadrics Implicit f(x, y, z) = v Ray equation x = xo + t xd y = yo + t yd z = zo + t zd Solve for t Assignment

Axis Aligned Bounding Box Given Ray: o + t d, t R; o, d R 3 Axis aligned bounding box (AABB): p min, p max R 3 Bounded Volume p max p min

Ray-Box Intersection Given Ray: o + t d, t R; o, d R 3 Axis aligned bounding box (AABB): p min, p max R 3 Slabs test for ray-box intersection Ray enters the box in all dimensions before exiting in any max({t i near i = x, y, z}) < min({t i far i = x, y, z}) t x near o Bounded Volume t y near (smaller) t x far (larger) t x near o Bounded Volume t x far (smaller) t y near (larger) t y far t y far

History of Intersection Algorithms Ray-geometry intersection algorithms Polygons: [Appel 68] Quadrics, CSG: [Goldstein & Nagel 71] Recursive Ray Tracing: [Whitted 79] Tori: [Roth 82] Bicubic patches: [Whitted 80, Kajiya 82] Algebraic surfaces: [Hanrahan 82] Swept surfaces: [Kajiya 83, van Wijk 84] Fractals: [Kajiya 83] Deformations: [Barr 86] NURBS: [Stürzlinger 98] Subdivision surfaces: [Kobbelt et al 98]

Precision Problems Cause of surface acne