CPSC GLOBAL ILLUMINATION

Similar documents
Shading, Advanced Rendering. Week 7, Wed Feb 28

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

Computer Graphics Ray Casting. Matthias Teschner

CS5620 Intro to Computer Graphics

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

Sung-Eui Yoon ( 윤성의 )

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

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

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

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

Computer Graphics. Ray Tracing. Copyright Gotsman, Elber, Barequet, Karni, Sheffer. Page 1. Ray-Tracing. Illumination Models

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

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

Lecture 11: Ray tracing (cont.)

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

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

Ray Tracing. Outline. Ray Tracing: History

Ray Tracing. Kjetil Babington

Intro to Ray-Tracing & Ray-Surface Acceleration

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

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

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

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

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

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

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

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

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

Spatial Data Structures

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

Review for Ray-tracing Algorithm and Hardware

Spatial Data Structures

Graphics 2009/2010, period 1. Lecture 8: ray tracing

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

Spatial Data Structures

Topics and things to know about them:

6. Illumination, Lighting

Supplement to Lecture 16

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

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

Level of Details in Computer Rendering

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

Raytracing CS148 AS3. Due :59pm PDT

Interpolation using scanline algorithm

Ray Casting. Outline in Code. Outline. Finding Ray Direction. Heckbert s Business Card Ray Tracer. Foundations of Computer Graphics (Fall 2012)

Ray Tracing. Foley & Van Dam, Chapters 15 and 16

Ray Tracing Foley & Van Dam, Chapters 15 and 16

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Virtual Reality for Human Computer Interaction

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

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

Lighting and Shading

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

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

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

COMPLETION OF Z-buffer Graphics Pipeline

Questions??? Announcements Assignment 3 due today

The Traditional Graphics Pipeline

Single Scattering in Refractive Media with Triangle Mesh Boundaries

Ray Tracer Due date: April 27, 2011

Introduction to Visualization and Computer Graphics

Advanced Ray Tracing

COMPUTER GRAPHICS AND INTERACTION

The Rendering Equation & Monte Carlo Ray Tracing

CS 465 Program 5: Ray II

Ray Casting. To Do. Outline. Outline in Code. Foundations of Computer Graphics (Spring 2012) Heckbert s Business Card Ray Tracer

03 RENDERING PART TWO

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

Assignment 6: Ray Tracing

COMP371 COMPUTER GRAPHICS

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

The Traditional Graphics Pipeline

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

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

Advanced Graphics. Path Tracing and Photon Mapping Part 2. Path Tracing and Photon Mapping

Implicit Surfaces & Solid Representations COS 426

CS 325 Computer Graphics

Introduction to Computer Graphics 7. Shading

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

CS 130 Exam I. Fall 2015

Photorealism: Ray Tracing

The Traditional Graphics Pipeline

Reflection and Shading

CPSC 314 LIGHTING AND SHADING

Lecture 11. More Ray Casting/Tracing

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

Chapter 7 - Light, Materials, Appearance

Ray Casting. Outline. Similar to glulookat derivation. Foundations of Computer Graphics

Advanced Shading I: Shadow Rasterization Techniques

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 exam begins at 2:40pm and ends at 4:00pm. You must turn your exam in when time is announced or risk not having it accepted.

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

CHAPTER 1 Graphics Systems and Models 3

Ray tracing. EECS 487 March 19,

Computer Graphics I Lecture 11

Mathematical Tools in Computer Graphics with C# Implementations Table of Contents

Transcription:

CPSC 314 21 GLOBAL ILLUMINATION Textbook: 20 UGRAD.CS.UBC.CA/~CS314 Mikhail Bessmeltsev

ILLUMINATION MODELS/ALGORITHMS Local illumination - Fast Ignore real physics, approximate the look Interaction of each object with light Compute on surface (light to viewer) Global illumination Slow Physically based Interactions between objects

ILLUMINATION MODELS/ALGORITHMS Local illumination - Fast Ignore real physics, approximate the look Interaction of each object with light Compute on surface (light to viewer) Global illumination Slow Physically based Interactions between objects

ILLUMINATION MODELS/ALGORITHMS Local illumination - Fast Ignore real physics, approximate the look Interaction of each object with light Compute on surface (light to viewer) Global illumination Slow Physically based Interactions between objects How?

WHAT WAS NON-PHYSICAL IN LOCAL ILLUMINATION?

HOW SHOULD GLOBAL ILLUMINATION WORK?

HOW SHOULD GLOBAL ILLUMINATION WORK? Simulate light As it is emitted from light sources Eye Image Plane Light Source As it bounces off objects / get absorbed / refracted Reflected Ray As some of the rays hit the camera Refracted Ray

PROBLEM?

RAY TRACING: IDEA Eye Image Plane Light Source Reflected Ray Refracted Ray

RAY TRACING: IDEA Eye Image Plane Light Source Reflected Ray Shadow Rays Refracted Ray

RAY TRACING Invert the direction of rays! Shoot rays from CAMERA through each pixel Trace the rays back Simulate whatever the light rays do: Reflection Refraction Each interaction of the ray with an object adds to the final color Those rays are never gonna hit the light source, so Shoot shadow rays to compute direct illumination

REFLECTION Mirror effects Perfect specular reflection n 2010 Jules Berman, http://julesberman.blogspot.ca/

REFRACTION Interface between transparent object and surrounding medium E.g. glass/air boundary c Snell s Law 2 sin 1 c1 sin 1 n 2 2 Light ray breaks (changes direction) based on refractive indices c 1, c 2

BASIC RAY-TRACING ALGORITHM RayTrace(r,scene) obj = FirstIntersection(r,scene) if (no obj) return BackgroundColor; else { if (Reflect(obj)) reflect_color = RayTrace(ReflectRay(r,obj)); else reflect_color = Black; if (Transparent(obj)) refract_color = RayTrace(RefractRay(r,obj)); else refract_color = Black; } return Shade(reflect_color, refract_color, obj);

WHEN TO STOP? Algorithm above does not terminate Termination Criteria No intersection Contribution of secondary ray attenuated below threshold each reflection/refraction attenuates ray Maximal depth is reached

SUB-ROUTINES ReflectRay(r,obj) computes reflected ray (use obj normal at intersection) RefractRay(r,obj) - computes refracted ray Note: ray is inside obj Shade(reflect_color,refract_color,obj) compute illumination given three components

SIMULATING SHADOWS Trace ray from each ray-object intersection point to light sources If the ray intersects an object in between point is shadowed from the light source shadow = RayTrace(LightRay(obj,r,light)); return Shade(shadow,reflect_color,refract_color,obj);

RAY TRACING: IDEA Eye Image Plane Light Source Reflected Ray Shadow Rays Refracted Ray

RAY-TRACING: PRACTICALITIES Generation of rays Intersection of rays with geometric primitives Geometric transformations Lighting and shading Speed: Reducing number of intersection tests E.g. use BSP trees or other types of space partitioning

RAY-TRACING: GENERATION OF RAYS Camera Coordinate System Origin: C (camera position) Viewing direction: w Up vector: v u direction: u= w v Corresponds to viewing transformation in rendering pipeline! C v w x

RAY-TRACING: GENERATION OF RAYS Distance to image plane: d Image resolution (in pixels): N x, N y Image plane dimensions: l, r, t, b Pixel at position i, j (i = 0,, N x 1; j = 0,, N y 1) O = C + dw + lu + tv C v w u P i, j = O + i + 0.5 r l N x u j + 0.5 t b N y v = O + i + 0.5 Δu u j + 0.5 Δv v

RAY-TRACING: GENERATION OF RAYS Parametric equation of a ray: R where t= 0 i, j ( t ) C t ( Pi, j C) C t vi, j

RAY-TRACING: PRACTICALITIES Generation of rays Intersection of rays with geometric primitives Geometric transformations Lighting and shading Speed: Reducing number of intersection tests E.g. use BSP trees or other types of space partitioning

RAY-OBJECT INTERSECTIONS In OpenGL pipeline, we were limited to discrete objects: Triangle meshes In ray tracing, we can support analytic surfaces! No problem with interpolating z and normals, # of triangles, etc. Almost

RAY-OBJECT INTERSECTIONS Core of ray-tracing must be extremely efficient Usually involves solving a set of equations Using implicit formulas for primitives Example: Ray-Sphere intersection x( t) p v t, y( t) p v t, z( t) p v t ray: (unit) sphere: x y z quadratic equation in t : x x y y z z 2 2 2 1 2 2 2 0 ( p v t) ( p v t) ( p v t) 1 x x y y z z 2 2 2 2 t ( v v v ) 2t( p v p v p v ) x y z x x y y z z 2 2 2 ( p p p ) 1 x y z p v

RAY INTERSECTIONS WITH OTHER PRIMITIVES Implicit functions: Spheres at arbitrary positions Same thing Conic sections (hyperboloids, ellipsoids, paraboloids, cones, cylinders) Same thing (all are quadratic functions!) Higher order functions (e.g. tori and other quartic functions) In principle the same But root-finding difficult Numerical methods

RAY INTERSECTIONS WITH OTHER PRIMITIVES Polygons: First intersect ray with plane linear implicit function Then test whether point is inside or outside of polygon (2D test) For convex polygons Suffices to test whether point in on the right side of every boundary edge

RAY-TRACING: PRACTICALITIES Generation of rays Intersection of rays with geometric primitives Geometric transformations Lighting and shading Speed: Reducing number of intersection tests E.g. use BSP trees or other types of space partitioning

RAY-TRACING: TRANSFORMATIONS Note: rays replace perspective transformation Geometric Transformations: Similar goal as in rendering pipeline: Modeling scenes convenient using different coordinate systems for individual objects Problem: Not all object representations are easy to transform This problem is fixed in rendering pipeline by restriction to polygons (affine invariance!)

RAY-TRACING: TRANSFORMATIONS Ray Transformation: For intersection test, it is only important that ray is in same coordinate system as object representation Transform all rays into object coordinates Transform camera point and ray direction by inverse of model/view matrix Shading has to be done in world coordinates (where light sources are given) Transform object space intersection point to world coordinates Thus have to keep both world and object-space ray

RAY-TRACING: PRACTICALITIES Generation of rays Intersection of rays with geometric primitives Geometric transformations Lighting and shading Speed: Reducing number of intersection tests E.g. use BSP trees or other types of space partitioning

RAY-TRACING: DIRECT ILLUMINATION Light sources: For the moment: point and directional lights More complex lights are possible Area lights Fluorescence

RAY-TRACING: DIRECT ILLUMINATION Local surface information (normal ) For implicit surfaces F(x,y,z)=0: normal n(x,y,z) is gradient of F: F(x, y, z)/ x n x, y, z = F x, y, z = F(x, y, z)/ y F(x, y, z)/ z Example: F 2 2 2 2 ( x, y, z) x y z r n( x, y, z) 2x 2y 2z Needs to be normalized!

RAY-TRACING: DIRECT ILLUMINATION For triangle meshes Interpolate per-vertex information as in rendering pipeline Phong shading! Same as discussed for rendering pipeline Difference to rendering pipeline: Have to compute Barycentric coordinates for every intersection point (e.g plane equation for triangles)

RAY-TRACING: PRACTICALITIES Generation of rays Intersection of rays with geometric primitives Geometric transformations Lighting and shading Speed: Reducing number of intersection tests

OPTIMIZED RAY-TRACING Basic algorithm is simple but VERY expensive Optimize Reduce number of rays traced Reduce number of ray-object intersection calculations Parallelize Cluster GPU Methods Bounding Boxes Spatial Subdivision Visibility, Intersection/Collision Tree Pruning

SPATIAL SUBDIVISION DATA STRUCTURES Goal: reduce number of intersection tests per ray Lots of different approaches: (Hierarchical) bounding volumes Hierarchical space subdivision Octree, k-d tree, BSP tree

BOUNDING VOLUMES: IDEA Don t test each ray against complex objects (e.g. triangle mesh) Do a quick conservative test first which eliminates most rays Surround complex object by simple, easy to test geometry (e.g. sphere or axis-aligned box) Reduce false positives: make bounding volume as tight as possible!

HIERARCHICAL BOUNDING VOLUMES Extension of previous idea: Use bounding volumes for groups of objects

SPATIAL SUBDIVISION DATA STRUCTURES Bounding Volumes: Find simple object completely enclosing complicated objects Boxes, spheres Hierarchically combine into larger bounding volumes Spatial subdivision data structure: Partition the whole space into cells Grids, octrees, (BSP trees) Simplifies and accelerates traversal Performance less dependent on order in which objects are inserted

SOFT SHADOWS: AREA LIGHT SOURCES So far: All lights were either point-shaped or directional Both for ray-tracing and the rendering pipeline Thus, at every point, we only need to compute lighting formula and shadowing for ONE direction per light In reality: All lights have a finite area Instead of just dealing with one direction, we now have to integrate over all directions that go to the light source

AREA LIGHT SOURCES Area lights produce soft shadows: In 2D: Area light Occluding surface Receiving surface Umbra (core shadow) Penumbra (partial shadow)

AREA LIGHT SOURCES Point lights: Only one light direction: I reflected V I light Point light V is visibility of light (0 or 1) is lighting model (e.g. diffuse or Phong)

AREA LIGHT SOURCES Area Lights: Infinitely many light rays Need to integrate over all of them: I reflected light directions Lighting model visibility and light intensity can now be different for every ray! ( ) V( ) I light ( ) d Area light

INTEGRATING OVER LIGHT SOURCE Rewrite the integration Instead of integrating over directions integrate over points on the light source I reflected I reflected light directions ( q) ( p q point on reflecting surface p= F(s,t) point on the area light We are integrating over p s, t ( ) V( ) I light ( ) d q) V ( p q) I light ( p) ds dt

INTEGRATION Problem: Except for basic case not solvable analytically! Largely due to the visibility term So: Use numerical integration = approximate light with lots of point lights

NUMERICAL INTEGRATION Regular grid of point lights Problem: Too regular see 4 hard shadows Area light Need LOTS of points to avoid this problem Solution: Monte-Carlo!

GLOBAL ILLUMINATION ALGORITHMS Ray Tracing Path Tracing Photon Mapping Radiosity Metropolis light transport