David Luebke2/23/2016 CS 551 / 645: Introductory Computer Graphics David Luebke

Slides:



Advertisements
Similar presentations
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Advertisements

Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Ray Tracing CMSC 635. Basic idea How many intersections?  Pixels  ~10 3 to ~10 7  Rays per Pixel  1 to ~10  Primitives  ~10 to ~10 7  Every ray.
3D Graphics Rendering and Terrain Modeling
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
David Luebke1/19/99 CS 551/651: Advanced Computer Graphics David Luebke
Light Issues in Computer Graphics Presented by Saleema Amershi.
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Illumination Model & Surface-rendering Method 박 경 와.
Christian Lauterbach COMP 770, 2/11/2009
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Computer Graphics (Fall 2005) COMS 4160, Lecture 21: Ray Tracing
RAY TRACING.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 14: Ray Tracing
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
Lecture 8 Advanced Rendering – Ray Tracing, Radiosity & NPR.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 2: Basic Ray Tracing Ravi Ramamoorthi Some slides courtesy.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CSC418 Computer Graphics n Raytracing n Shadows n Global Illumination.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
1 Speeding Up Ray Tracing Images from Virtual Light Field Project ©Slides Anthony Steed 1999 & Mel Slater 2004.
Ray Tracing Sang Il Park SEjong University With lots of slides stolen from Jehee Lee, Doug James, Steve Seitz, Shree Nayar, Alexei Efros, Fredo Durand.
David Luebke10/9/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Collaborative Visual Computing Lab Department of Computer Science University of Cape Town Graphics Topics in VR By Shaun Nirenstein.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
04/30/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling We are now all done with modeling, the standard hardware pipeline.
Basic Ray Tracing CMSC 435/634.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
第五课 Ray Tracing. Overview of the Section Why Ray Tracing? What is Ray Tracing? How to tracing rays? How to accelerating ray-tracing?
Ray-tracing.
Monte-Carlo Ray Tracing and
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CSCE 441: Computer Graphics Ray Tracing
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
CS 551/651: Advanced Computer Graphics
Ray Tracing Optimizations
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
Global Illumination (3) Photon Mapping (1). Overview Light Transport Notation Path Tracing Photon Mapping –Photon Tracing –The Photon Map.
RENDERING : Global Illumination
Global Illumination (3) Path Tracing. Overview Light Transport Notation Path Tracing Photon Mapping.
David Luebke3/12/2016 Advanced Computer Graphics Lecture 3: More Ray Tracing David Luebke
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
CS552: Computer Graphics Lecture 33: Illumination and Shading.
CS552: Computer Graphics Lecture 36: Ray Tracing.
Basic Ray Tracing CMSC 435/634.
CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi
3D Graphics Rendering PPT By Ricardo Veguilla.
© University of Wisconsin, CS559 Fall 2004
CMSC 635 Ray Tracing.
Image synthesis using classical optics
CS 551 / 645: Introductory Computer Graphics
CSCE 441: Computer Graphics Ray Tracing
CSC418 Computer Graphics Raytracing Shadows Global Illumination.
Presentation transcript:

David Luebke2/23/2016 CS 551 / 645: Introductory Computer Graphics David Luebke

David Luebke2/23/2016 Administrivia l Upcoming graphics events –Graphics lunch: Olsson 236D n Ongoing, informal event; bring your lunch n Tomorrow’s topic: Art-Based Interactive Rendering by Derek Cornish (4th-year thesis proposal):

David Luebke2/23/2016 Adminstrivia l More upcoming graphics events –“Graphics week”: 2 upcoming colloquia n Dec 1: Dan Aliaga (Bell Labs), Image-Based Rendering n Dec 6: Ben Watson (U. Alberta), Level of detail control

David Luebke2/23/2016 Realism l What is not realistic about the following images?

David Luebke2/23/2016 Realism?

David Luebke2/23/2016 Realism?

David Luebke2/23/2016 Realism?

David Luebke2/23/2016 Realism?

David Luebke2/23/2016 Realism?

David Luebke2/23/2016 Realism… l A big part of realism is realistic lighting l Is OpenGL’s lighting model realistic? –Empirical specular term –“Ambient” term –No shadows –No surface interreflection Crude light-surface interaction model Strictly local illumination model

David Luebke2/23/2016 Global Illumination l Realistic lighting is global, not local –Surfaces shadow each other –Surfaces illuminate each other l Two long-time approaches –Ray-tracing: simulate light-ray optics –Radiosity: simulate physics of light transfer

David Luebke2/23/2016 Ray Tracing Overview l To determine visible surfaces at each pixel: –Cast a ray from the eyepoint through the center of the pixel –Intersect the ray with all objects in the scene –Whatever it hits first is the visible object l This is called ray casting

David Luebke2/23/2016 Ray Casting l An example: ScreenEyepointScene

David Luebke2/23/2016 Recursive Ray Tracing l Obvious extension: –Spawn additional rays off reflective surfaces –Spawn transmitted rays through transparent surfaces l Leads to recursive ray tracing Primary Ray Secondary Rays

David Luebke2/23/2016 Recursive Ray Tracing l Slightly less obvious extension: –Trace a ray from point of intersection to light source –If ray hits anything before light source, object is in shadow –These are called shadow rays

David Luebke2/23/2016 Ray Tracing Overview l Ray tracing is simple –No clipping, perspective projection matrices, scan conversion of polygons l Ray tracing is powerful –Hidden surface problem –Shadow computation –Reflection/refraction l Ray tracing is slow –Complexity proportional to # of pixels –Typical screen ~ 1,000,000 pixels –Typical scene « 1,000,000 polygons

David Luebke2/23/2016 Recursive Ray Tracing

David Luebke2/23/2016 Recursive Ray Tracing Pixel Image Plane

David Luebke2/23/2016 Recursive Ray Tracing “Direct” Ray To Eye

David Luebke2/23/2016 Recursive Ray Tracing “Indirect” Ray To Eye

David Luebke2/23/2016 Recursive Ray Tracing l Physically, we’re interested in path of light rays from light source to eye. l In practice, we trace rays backwards from eye to source (Why?)

David Luebke2/23/2016 Recursive Ray Tracing l Physically, we’re interested in path of light rays from light source to eye. l In practice, we trace rays backwards from eye to source (Why?) –Computational efficiency: we want the finite subset of rays that leave source, bounce around, and pass through eye –Can’t predict where a ray will go, so start with rays we know reach eye

David Luebke2/23/2016 Basic Algorithm Function TraceRay() Recursively trace ray R and return resulting color C –if R intersects any objects then n Find nearest object O n Find local color contribution Spawn reflected and transmitted rays, using TraceRay() to find resulting colors n Combine colors; return result –else n return background color

David Luebke2/23/2016 Basic Algorithm: Code Object allObs[]; Color image[]; RayTraceScene() allObs = initObjects(); for (Y  all rows in image) for (X  all pixels in row) Ray R = calcPrimaryRay(X,Y); image[X,Y] = TraceRay(R); display(image);

David Luebke2/23/2016 Basic Algorithm: Code Color TraceRay(Ray R) if rayHitsObjects(R) then Color localC, reflectC, refractC; Object O = findNearestObject(R); localC = shade(O,R); Ray reflectedRay = calcReflect(O,R) Ray refractedRay = calcRefract(O,R) reflectC = TraceRay(reflectedRay); refractC = TraceRay(refractedRay); return localC  reflectC  refractC else return backgroundColor

David Luebke2/23/2016 Refining the Basic Algorithm Color TraceRay(Ray R) if rayHitsObjects(R) then Color localC, reflectC, refractC; Object O = findNearestObject(R); localC = shade(O,R); Ray reflectedRay = calcReflect(O,R) Ray refractedRay = calcRefract(O,R) reflectC = TraceRay(reflectedRay); refractC = TraceRay(refractedRay); return localC  reflectC  refractC else return backgroundColor

David Luebke2/23/2016 Ray-Object Intersection l Given a ray and a list of objects, what objects (if any) intersect the ray? l Query: Does ray R intersect object O? –How to represent ray? –What kind of object? n Sphere n Polygon n Box n General quadric

David Luebke2/23/2016 Representing Rays l How might we represent rays? l We represent a ray parametrically: –A starting point O –A direction vector D –A scalar t O D t = 1t < 0 R = O + tD t > 1

David Luebke2/23/2016 Ray-Sphere Intersection Ray R = O + tD x = O x + t D x y = O y + t D y z = O z + t D z l Sphere at (l, m, n) of radius r is: (x - l) 2 + (y - m) 2 + (z - n) 2 = r 2 l Substitute for x,y,z and solve for t…

David Luebke2/23/2016 Ray-Sphere Intersection l Works out as a quadratic equation: at 2 + bt + c = 0 where a = D x 2 + D y 2 + D z 2 b = 2D x (O x - l) + 2D y (O y - m) + 2D z (O z - n) c = l 2 + m 2 + n 2 + O x 2 + O y 2 + O z 2 - 2(l O x + m O y + n O z + r 2 )

David Luebke2/23/2016 Ray-Sphere Intersection l If solving for t gives no real roots: ray does not intersect sphere l If solving gives 1 real root r, ray grazes sphere where t = r l If solving gives 2 real roots (r 1, r 2 ), ray intersects sphere at t = r 1 & t = r 2 –Ignore negative values –Smallest value is first intersection

David Luebke2/23/2016 Ray-Sphere Intersection l Find intersection point P i = (x i, y i, z i ) by plugging t back into ray equation l Find normal at intersection point by subtracting sphere center from P i and normalizing: l When will we need the normal? When not?

David Luebke2/23/2016 Ray-Polygon Intersection l Polygons are the most common model representation –Can render in hardware –Lowest common denominator l Basic approach: –Find plane equation of polygon –Find point of intersection between ray and plane –Does polygon contain intersection point?

David Luebke2/23/2016 Ray-Polygon Intersection Find plane equation of polygon: ax + by + cz + d = 0 l Remember how? N = [a, b, c] d = N  P 1 x y N P1P1 P2P2 d

David Luebke2/23/2016 Ray-Polygon Intersection l Find intersection of ray and plane: t = -(aO x + bO y + cO z + d) / (aD x + bD y + cD z ) Does polygon contain intersection point P i ? –One simple algorithm: Draw line from P i to each polygon vertex n Measure angles between lines (how?) If sum of angles between lines is 360°, polygon contains P i –Slow — better algorithms available

David Luebke2/23/2016 Ray-Box Intersection l Often want to find whether a ray hits an axis- aligned box (Why?) l One way: –Intersect ray with pairs of parallel planes that form box –If intervals of intersection overlap, the ray intersects the volume.

David Luebke2/23/2016 Shadow Rays l Simple idea: –Where a ray intersects a surface, send a shadow ray to each light source –If the shadow ray hits any surface before the light source, ignore light l Q: how much extra work is involved? l A: each ray-surface intersection now spawns n + 2 rays, n = # light sources –Remember: intersections 95% of work

David Luebke2/23/2016 Shadow Rays l Some problems with using shadow rays as described: –Lots of computation –Infinitely sharp shadows –No semitransparent object shadows

David Luebke2/23/2016 Shadow Rays l Some problems with using shadow rays as described: –Lots of computation –Infinitely sharp shadows –No semitransparent object shadows

David Luebke2/23/2016 Shadow Ray Problems: Too Much Computation l Light buffer (Haines/Greenberg, 86) –Precompute lists of polygons surrounding light source in all directions –Sort each list by distance to light source –Now shadow ray need only be intersected with appropriate list! Occluding Polys Shadow Ray Current Intersection Point Light Buffer

David Luebke2/23/2016 Shadow Rays l Some problems with using shadow rays as described: –Lots of computation –Infinitely sharp shadows –No semitransparent object shadows

David Luebke2/23/2016 Shadow Ray Problems: Sharp Shadows l Why are the shadows sharp? l A: Infinitely small point light sources l What can we do about it? l A: Implement area light sources l How?

David Luebke2/23/2016 Shadow Ray Problems: Area Light Sources 30% blockage l Could trace a conical beam from point of intersection to light source: l Track portion of beam blocked by occluding polygons:

David Luebke2/23/2016 Shadow Ray Problems: Area Light Sources l Too hard! Approximate instead: l Sample the light source over its area and take weighted average: 50% blockage

David Luebke2/23/2016 Shadow Ray Problems: Area Light Sources l Disadvantages: –Less accurate (50% vs. 30% blockage) –Oops! Just quadrupled (at least) number of shadow rays l Moral of the story: –Soft shadows are very expensive in ray tracing

David Luebke2/23/2016 Shadow Rays l Some problems with using shadow rays as described: –Lots of computation –Infinitely sharp shadows –No semitransparent object shadows

David Luebke2/23/2016 Shadow Ray Problems: Semitransparent Objects l In principle: –Translucent colored objects should cast colored shadows –Translucent curved objects should create refractive caustics l In practice: –Can fake colored shadows by attenuating color with distance –Caustics need backward ray tracing

David Luebke2/23/2016 Speedup Techniques l Intersect rays faster l Shoot fewer rays l Shoot “smarter” rays

David Luebke2/23/2016 Speedup Techniques l Intersect rays faster l Shoot fewer rays l Shoot “smarter” rays

David Luebke2/23/2016 Intersect Rays Faster l Bounding volumes l Spatial partitions l Reordering ray intersection tests l Optimizing intersection tests

David Luebke2/23/2016 Bounding Volumes l Bounding volumes –Idea: before intersecting a ray with a collection of objects, test it against one simple object that bounds the collection

David Luebke2/23/2016 Bounding Volumes l Hierarchical bounding volumes –Group nearby volumes hierarchically –Test rays against hierarchy top-down

David Luebke2/23/2016 Bounding Volumes l Different bounding volumes –Spheres n Cheap intersection test n Poor fit n Tough to calculate optimal clustering –Axis-aligned bounding boxes (AABBs) n Relatively cheap intersection test n Usually better fit n Trivial to calculate clustering

David Luebke2/23/2016 Bounding Volumes l More bounding volumes –Oriented bounding boxes (OBBs) n Medium-expensive intersection test n Very good fit (asymptotically better) n Medium-difficult to calculate clustering –Slabs (parallel planes) n Comparatively expensive n Very good fit n Difficult to calculate good clustering

David Luebke2/23/2016 Spatial Partitioning l Hierarchical bounding volumes surround objects in the scene with (possibly overlapping) volumes l Spatial partitioning techniques classify all space into non-overlapping portions

David Luebke2/23/2016 Spatial Partitioning l Example spatial partitions: –Uniform grid (2-D or 3-D) –Octree –k-D tree –BSP-tree

David Luebke2/23/2016 Uniform Grid l Uniform grid pros: –Very simple and fast to generate –Very simple and fast to trace rays across (How?) l Uniform grid cons: –Not adaptive n Wastes storage on empty space n Assumes uniform spread of data

David Luebke2/23/2016 Octree l Octree pros: –Simple to generate –Adaptive l Octree cons: –Nontrivial to trace rays across –Adaptive only in scale

David Luebke2/23/2016 k-D Trees l k-D tree pros: –Moderately simple to generate –More adaptive than octrees l k-D tree cons: –Less efficient to trace rays across –Moderately complex data structure

David Luebke2/23/2016 BSP Trees l BSP tree pros: –Extremely adaptive –Simple & elegant data structure l BSP tree cons: –Very hard to create optimum BSP –Splitting planes can explode storage –Simple but slow to trace rays across

David Luebke2/23/2016 Reordering Ray Intersection Tests l Caching ray hits (esp. shadow rays) l Memory-coherent ray tracing

David Luebke2/23/2016 Optimizing Ray Intersection Tests l Fine-tune the math! –Share subexpressions –Precompute everything possible l Code with care –Even use assembly, if necessary