CS 551 / 645: Introductory Computer Graphics

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 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.
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.
Illumination Model & Surface-rendering Method 박 경 와.
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
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.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
Lecture 8 Advanced Rendering – Ray Tracing, Radiosity & NPR.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
CSC418 Computer Graphics n Raytracing n Shadows n Global Illumination.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
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.
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.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Global Illumination: Radiosity, Photon Mapping & Path Tracing Rama Hoetzlein, 2009 Lecture Notes Cornell University.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
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
David Luebke2/23/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
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.
Basic Ray Tracing CMSC 435/634.
3D Rendering 2016, Fall.
Advanced Computer Graphics
Rendering Pipeline Fall, 2015.
Bounding Volume Hierarchies and Spatial Partitioning
CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi
Global Illumination: Radiosity, Photon Mapping & Path Tracing
Bounding Volume Hierarchies and Spatial Partitioning
Ray Tracing Dr. Scott Schaefer.
3D Graphics Rendering PPT By Ricardo Veguilla.
RAY TRACING.
Mike Merchant Nicholas Hilbert
Jim X. Chen George Mason University
© University of Wisconsin, CS559 Fall 2004
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Path Tracing (some material from University of Wisconsin)
CMSC 635 Ray Tracing.
Lighting.
Visibility Computations
CSCE 441 Computer Graphics: Radiosity
Image synthesis using classical optics
CS5500 Computer Graphics May 29, 2006
Illumination and Shading
CSCE 441: Computer Graphics Ray Tracing
GR2 Advanced Computer Graphics AGR
Ray Tracing Sung-Eui Yoon (윤성의) CS580: Course URL:
Chapter 14 Shading Models.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CSC418 Computer Graphics Raytracing Shadows Global Illumination.
Presentation transcript:

CS 551 / 645: Introductory Computer Graphics Ray Tracing David Luebke 2/25/2019

Administrivia Assignment 5: Intel okay David Luebke 2/25/2019

Realism What is not realistic about the following images? David Luebke 2/25/2019

Realism? David Luebke 2/25/2019

Realism? David Luebke 2/25/2019

Realism? David Luebke 2/25/2019

Realism? David Luebke 2/25/2019

Realism? David Luebke 2/25/2019

Realism… A big part of realism is realistic lighting Is Phong’s lighting model realistic? Empirical specular term “Ambient” term No shadows No surface interreflection Crude light-surface interaction model Strictly local illumination model David Luebke 2/25/2019

Global Illumination Realistic lighting is global, not local Surfaces shadow each other Surfaces illuminate each other Two long-time approaches Ray-tracing: simulate light-ray optics Radiosity: simulate physics of light transfer David Luebke 2/25/2019

Ray Tracing Overview 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 This is called ray casting David Luebke 2/25/2019

Ray Casting An example: Eyepoint Screen Scene David Luebke 2/25/2019

Recursive Ray Tracing Obvious extension: Spawn additional rays off reflective surfaces Spawn transmitted rays through transparent surfaces Leads to recursive ray tracing Secondary Rays Primary Ray David Luebke 2/25/2019

Recursive Ray Tracing 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 Luebke 2/25/2019

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

Recursive Ray Tracing David Luebke 2/25/2019

Recursive Ray Tracing Pixel Image Plane David Luebke 2/25/2019

Recursive Ray Tracing “Direct” Ray To Eye David Luebke 2/25/2019

Recursive Ray Tracing “Indirect” Ray To Eye David Luebke 2/25/2019

Recursive Ray Tracing Physically, we’re interested in path of light rays from light source to eye. In practice, we trace rays backwards from eye to source (Why?) David Luebke 2/25/2019

Recursive Ray Tracing Physically, we’re interested in path of light rays from light source to eye. 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 Luebke 2/25/2019

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

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 Luebke 2/25/2019

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 Luebke 2/25/2019

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 Luebke 2/25/2019

Ray-Object Intersection Given a ray and a list of objects, what objects (if any) intersect the ray? Query: Does ray R intersect object O? How to represent ray? What kind of object? Sphere Polygon Box General quadric David Luebke 2/25/2019

R = O + tD Representing Rays O D How might we represent rays? We represent a ray parametrically: A starting point O A direction vector D A scalar t R = O + tD O t < 0 t = 1 t > 1 D David Luebke 2/25/2019

Ray-Sphere Intersection Ray R = O + tD x = Ox + t Dx y = Oy + t Dy z = Oz + t Dz Sphere at (l, m, n) of radius r is: (x - l)2 + (y - m)2 + (z - n)2 = r 2 Substitute for x,y,z and solve for t… David Luebke 2/25/2019

Ray-Sphere Intersection Works out as a quadratic equation: at2 + bt + c = 0 where a = Dx2 + Dy2 + Dz2 b = 2Dx (Ox - l) + 2Dy (Oy - m) + 2Dz (Oz - n) c = l2 + m2 + n2 + Ox2 + Oy2 + Oz2 - 2(l Ox + m Oy + n Oz + r2) David Luebke 2/25/2019

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

Ray-Sphere Intersection Find intersection point Pi = (xi, yi, zi) by plugging t back into ray equation Find normal at intersection point by subtracting sphere center from Pi and normalizing: When will we need the normal? When not? David Luebke 2/25/2019

Ray-Polygon Intersection Polygons are the most common model representation Can render in hardware Lowest common denominator Basic approach: Find plane equation of polygon Find point of intersection between ray and plane Does polygon contain intersection point? David Luebke 2/25/2019

Ray-Polygon Intersection Find plane equation of polygon: ax + by + cz + d = 0 Remember how? N = [a, b, c] d = N  P1 y N P2 P1 d x David Luebke 2/25/2019

Ray-Polygon Intersection Find intersection of ray and plane: t = -(aOx + bOy + cOz + d) / (aDx + bDy + cDz) Does polygon contain intersection point Pi ? One simple algorithm: Draw line from Pi to each polygon vertex Measure angles between lines (how?) If sum of angles between lines is 360°, polygon contains Pi Slow — better algorithms available David Luebke 2/25/2019

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

Shadow Rays Simple idea: Q: how much extra work is involved? 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 Q: how much extra work is involved? A: each ray-surface intersection now spawns n + 2 rays, n = # light sources Remember: intersections 95% of work David Luebke 2/25/2019

Shadow Rays Some problems with using shadow rays as described: Lots of computation Infinitely sharp shadows No semitransparent object shadows David Luebke 2/25/2019

Shadow Rays Some problems with using shadow rays as described: Lots of computation Infinitely sharp shadows No semitransparent object shadows David Luebke 2/25/2019

Shadow Ray Problems: Too Much Computation 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! Light Buffer Shadow Ray Occluding Polys Current Intersection Point David Luebke 2/25/2019

Shadow Rays Some problems with using shadow rays as described: Lots of computation Infinitely sharp shadows No semitransparent object shadows David Luebke 2/25/2019

Shadow Ray Problems: Sharp Shadows Why are the shadows sharp? A: Infinitely small point light sources What can we do about it? A: Implement area light sources How? David Luebke 2/25/2019

Shadow Ray Problems: Area Light Sources Could trace a conical beam from point of intersection to light source: Track portion of beam blocked by occluding polygons: 30% blockage David Luebke 2/25/2019

Shadow Ray Problems: Area Light Sources Too hard! Approximate instead: Sample the light source over its area and take weighted average: 50% blockage David Luebke 2/25/2019

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

Shadow Rays Some problems with using shadow rays as described: Lots of computation Infinitely sharp shadows No semitransparent object shadows David Luebke 2/25/2019

Shadow Ray Problems: Semitransparent Objects In principle: Translucent colored objects should cast colored shadows Translucent curved objects should create refractive caustics In practice: Can fake colored shadows by attenuating color with distance Caustics need backward ray tracing David Luebke 2/25/2019

Speedup Techniques Intersect rays faster Shoot fewer rays Shoot “smarter” rays David Luebke 2/25/2019

Speedup Techniques Intersect rays faster Shoot fewer rays Shoot “smarter” rays David Luebke 2/25/2019

Intersect Rays Faster Bounding volumes Spatial partitions Reordering ray intersection tests Optimizing intersection tests David Luebke 2/25/2019

7 7 9 9 5 5 8 8 Bounding Volumes 4 4 3 3 2 2 Bounding volumes Idea: before intersecting a ray with a collection of objects, test it against one simple object that bounds the collection 7 7 5 5 3 3 1 1 8 8 6 6 9 9 2 4 2 4 David Luebke 2/25/2019

Bounding Volumes Hierarchical bounding volumes Group nearby volumes hierarchically Test rays against hierarchy top-down David Luebke 2/25/2019

Bounding Volumes Different bounding volumes Spheres Cheap intersection test Poor fit Tough to calculate optimal clustering Axis-aligned bounding boxes (AABBs) Relatively cheap intersection test Usually better fit Trivial to calculate clustering David Luebke 2/25/2019

Bounding Volumes More bounding volumes Oriented bounding boxes (OBBs) Medium-expensive intersection test Very good fit (asymptotically better) Medium-difficult to calculate clustering Slabs (parallel planes) Comparatively expensive Very good fit Difficult to calculate good clustering David Luebke 2/25/2019

Spatial Partitioning Hierarchical bounding volumes surround objects in the scene with (possibly overlapping) volumes Spatial partitioning techniques classify all space into non-overlapping portions David Luebke 2/25/2019

Spatial Partitioning Example spatial partitions: Uniform grid (2-D or 3-D) Octree k-D tree BSP-tree David Luebke 2/25/2019

Uniform Grid Uniform grid pros: Uniform grid cons: Very simple and fast to generate Very simple and fast to trace rays across (How?) Uniform grid cons: Not adaptive Wastes storage on empty space Assumes uniform spread of data David Luebke 2/25/2019

Octree Octree pros: Octree cons: Simple to generate Adaptive Nontrivial to trace rays across Adaptive only in scale David Luebke 2/25/2019

k-D Trees k-D tree pros: k-D tree cons: Moderately simple to generate More adaptive than octrees k-D tree cons: Less efficient to trace rays across Moderately complex data structure David Luebke 2/25/2019

BSP Trees BSP tree pros: BSP tree cons: Extremely adaptive Simple & elegant data structure BSP tree cons: Very hard to create optimum BSP Splitting planes can explode storage Simple but slow to trace rays across David Luebke 2/25/2019

Reordering Ray Intersection Tests Caching ray hits (esp. shadow rays) Memory-coherent ray tracing David Luebke 2/25/2019

Optimizing Ray Intersection Tests Fine-tune the math! Share subexpressions Precompute everything possible Code with care Even use assembly, if necessary David Luebke 2/25/2019