1
play

1 Ray Tracing History Ray Tracing History Outline in Code Outline - PDF document

Effects needed for Realism Computer Graphics (Soft) Shadows Reflections (Mirrors and Glossy) CSE 167 [Win 17], Lecture 15: Ray Tracing Transparency (Water, Glass) Ravi Ramamoorthi Interreflections (Color Bleeding)


  1. Effects needed for Realism Computer Graphics § (Soft) Shadows § Reflections (Mirrors and Glossy) CSE 167 [Win 17], Lecture 15: Ray Tracing § Transparency (Water, Glass) Ravi Ramamoorthi § Interreflections (Color Bleeding) http://viscomp.ucsd.edu/classes/cse167/wi17 § Complex Illumination (Natural, Area Light) § Realistic Materials (Velvet, Paints, Glass) § And many more Ray Tracing § Different Approach to Image Synthesis as compared to Hardware pipeline (OpenGL) § Pixel by Pixel instead of Object by Object § Easy to compute shadows/transparency/etc Image courtesy Paul Heckbert 1983 Outline Ray Tracing: History § History § Appel 68 § Basic Ray Casting (instead of rasterization) § Whitted 80 [recursive ray tracing] § Comparison to hardware scan conversion § Landmark in computer graphics § Lots of work on various geometric primitives § Shadows / Reflections (core algorithm) § Lots of work on accelerations § Ray-Surface Intersection § Current Research § Optimizations § Real-Time raytracing (historically, slow technique) § Ray tracing architecture § Current Research 1

  2. Ray Tracing History Ray Tracing History Outline in Code Outline Image Raytrace (Camera cam, Scene scene, int width, int height) § History { § Basic Ray Casting (instead of rasterization) Image image = new Image (width, height) ; § Comparison to hardware scan conversion for (int i = 0 ; i < height ; i++) § Shadows / Reflections (core algorithm) for (int j = 0 ; j < width ; j++) { § Ray-Surface Intersection Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; § Optimizations image[i][j] = FindColor (hit) ; § Current Research } return image ; } Ray Casting Ray Casting Produce same images as with OpenGL § Visibility per pixel instead of Z-buffer § Find nearest object by shooting rays into scene § Shade it as in standard OpenGL Virtual Viewpoint Virtual Screen Objects Ray intersects object: shade using color, lights, materials Multiple intersections: Use closest one (as does OpenGL) Ray misses all objects: Pixel colored black 2

  3. Comparison to hardware scan-line Outline § Per-pixel evaluation, per-pixel rays (not scan-convert § History each object). On face of it, costly § Basic Ray Casting (instead of rasterization) § Comparison to hardware scan conversion § But good for walkthroughs of extremely large models § Shadows / Reflections (core algorithm) (amortize preprocessing, low complexity) § Ray-Surface Intersection § More complex shading, lighting effects possible § Optimizations § Current Research Shadows Shadows: Numerical Issues Light Source � Numerical inaccuracy may cause intersection to be below surface (effect exaggerated in figure) � Causing surface to incorrectly shadow itself � Move a little towards light before shooting shadow ray Virtual Viewpoint Virtual Screen Objects Shadow ray to light is blocked: object in shadow Shadow ray to light is unblocked: object visible Mirror Reflections/Refractions Recursive Ray Tracing For each pixel § Trace Primary Eye Ray, find intersection § Trace Secondary Shadow Ray(s) to all light(s) § Color = Visible ? Illumination Model : 0 ; § Trace Reflected Ray Virtual Viewpoint § Color += reflectivity * Color of reflected ray Virtual Screen Objects Generate reflected ray in mirror direction, Get reflections and refractions of objects 3

  4. Problems with Recursion § Reflection rays may be traced forever § Generally, set maximum recursion depth § Same for transmitted rays (take refraction into account) Turner Whitted 1980 Effects needed for Realism Outline � (Soft) Shadows § History � Reflections (Mirrors and Glossy) § Basic Ray Casting (instead of rasterization) � Transparency (Water, Glass) § Comparison to hardware scan conversion � Interreflections (Color Bleeding) § Shadows / Reflections (core algorithm) � Complex Illumination (Natural, Area Light) § Ray-Surface Intersection � Realistic Materials (Velvet, Paints, Glass) § Optimizations § Current Research Discussed in this lecture Not discussed but possible with distribution ray tracing Hard (but not impossible) with ray tracing; radiosity methods Ray/Object Intersections Ray-Sphere Intersection    ≡ P = 0 + ray P P 1 t § Heart of Ray Tracer     C ) − r 2 = 0 § One of the main initial research areas sphere ≡ ( P − P − C ) i ( § Optimized routines for wide variety of primitives § Various types of info § Shadow rays: Intersection/No Intersection § Primary rays: Point of intersection, material, normals § Texture coordinates C § Work out examples § Triangle, sphere, polygon, general implicit surface P 0 4

  5. Ray-Sphere Intersection Ray-Sphere Intersection             C ) − r 2 = 0 t 2 ( 1 ) + 2 t 0 − C ) + ( 0 − 0 − P 1 i P P 1 i ( P P C ) i ( P ≡ P = 0 + ray P P 1 t     C ) − r 2 = 0 Solve quadratic equations for t sphere ≡ ( P − C ) i ( P − Substitute § 2 real positive roots: pick smaller root    ≡ P = 0 + ray P P 1 t § Both roots same: tangent to sphere       C ) − r 2 = 0 sphere ≡ ( 0 + 1 t − 0 + 1 t − P P C ) i ( P P § One positive, one negative root: ray Simplify origin inside sphere (pick + root)          C ) − r 2 = 0 t 2 ( 1 ) + 2 t 0 − C ) + ( 0 − 0 − P 1 i P P 1 i ( P P C ) i ( P § Complex roots: no intersection (check discriminant of equation first) Ray-Sphere Intersection Ray-Triangle Intersection    ≡ P = 0 + ray P P 1 t § Intersection point: § One approach: Ray-Plane intersection, then check if inside triangle B § Normal (for sphere, this is same as coordinates A n = ( C − A ) × ( B − A ) in sphere frame of reference, useful other tasks) § Plane equation: ( C − A ) × ( B − A )     P − P i  A i  C plane ≡ n − n = 0 = normal   P − C C Ray-Triangle Intersection Ray inside Triangle § Once intersect with plane, still need to find if in § One approach: Ray-Plane intersection, then triangle check if inside triangle B A n = ( C − A ) × ( B − A ) § Many possibilities for triangles, general polygons § Plane equation: ( C − A ) × ( B − A ) (point in polygon tests)   P i  A i  plane ≡ n − n = 0 § We find parametrically [barycentric coordinates]. Also § Combine with ray equation: useful for other applications (texture mapping) C      A i  0 i  B ≡ P = 0 + ray P P 1 t n − P n P = α A + β B + γ C A    t =  β 1 t ) i  A i  1 i  α 0 + n = P n α ≥ 0, β ≥ 0, γ ≥ 0 ( P P n P α + β + γ = 1 γ C 5

  6. Ray inside Triangle Other primitives P = α A + β B + γ C § Much early work in ray tracing focused on ray-primitive B A β α ≥ 0, β ≥ 0, γ ≥ 0 intersection tests α α + β + γ = 1 P § Cones, cylinders, ellipsoids γ § Boxes (especially useful for bounding boxes) C § General planar polygons P − A = β ( B − A ) + γ ( C − A ) § Many more 0 ≤ β ≤ 1 , 0 ≤ γ ≤ 1 β + γ ≤ 1 § Many references. For example, chapter in Glassner introduction to ray tracing (see me if interested) Ray-Tracing Transformed Objects Transformed Objects § Consider a general 4x4 transform M We have an optimized ray-sphere test § Will need to implement matrix stacks like in OpenGL § But we want to ray trace an ellipsoid … § Apply inverse transform M -1 to ray Solution: Ellipsoid transforms sphere § Locations stored and transform in homogeneous § Apply inverse transform to ray, use ray-sphere coordinates § Allows for instancing (traffic jam of cars) § Vectors (ray directions) have homogeneous coordinate set to 0 [so there is no action because of translations] Mathematical details worked out in class § Do standard ray-surface intersection as modified § Transform intersection back to actual coordinates § Intersection point p transforms as Mp § Distance to intersection if used may need recalculation § Normals n transform as M -t n. Do all this before lighting Outline Acceleration § History Testing each object for each ray is slow § Fewer Rays § Basic Ray Casting (instead of rasterization) Adaptive sampling, depth control § Comparison to hardware scan conversion § Generalized Rays Beam tracing, cone tracing, pencil tracing etc. § Shadows / Reflections (core algorithm) § Faster Intersections § Optimized Ray-Object Intersections § Ray-Surface Intersection § Fewer Intersections § Optimizations § Current Research We just discuss some approaches at high level; chapter 13 briefly covers 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend