1
play

1 Ray Tracing History Ray Tracing History From SIGGRAPH 18 - PDF document

Effects needed for Realism Computer Graphics (Soft) Shadows Reflections (Mirrors and Glossy) CSE 167 [Win 19], 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 19], Lecture 15: Ray Tracing § Transparency (Water, Glass) Ravi Ramamoorthi § Interreflections (Color Bleeding) http://viscomp.ucsd.edu/classes/cse167/wi19 § 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 From SIGGRAPH 18 Outline in Code Image Raytrace (Camera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = FindColor (hit) ; } return image ; } Real Photo: Instructor and Turner Whitted at SIGGRAPH 18 Outline Ray Casting § History Produce same images as with OpenGL § Visibility per pixel instead of Z-buffer § Basic Ray Casting (instead of rasterization) § Find nearest object by shooting rays into scene § Comparison to hardware scan conversion § Shade it as in standard OpenGL § Shadows / Reflections (core algorithm) § Ray-Surface Intersection § Optimizations § Current Research 2

  3. Ray Casting Comparison to hardware scan-line § Per-pixel evaluation, per-pixel rays (not scan-convert each object). On face of it, costly § But good for walkthroughs of extremely large models (amortize preprocessing, low complexity) Virtual Viewpoint § More complex shading, lighting effects possible Virtual Screen Objects Multiple intersections: Use closest one (as does OpenGL) Ray misses all objects: Pixel colored black Ray intersects object: shade using color, lights, materials Shadows Outline Light Source § History § Basic Ray Casting (instead of rasterization) § Comparison to hardware scan conversion § Shadows / Reflections (core algorithm) § Ray-Surface Intersection Virtual Viewpoint § Optimizations § Current Research Virtual Screen Objects Shadow ray to light is unblocked: object visible Shadow ray to light is blocked: object in shadow Shadows: Numerical Issues Mirror Reflections/Refractions � 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 Generate reflected ray in mirror direction, Get reflections and refractions of objects 3

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

  5. Ray-Sphere Intersection Ray-Sphere Intersection       ≡ P = 0 + ≡ P = 0 + ray P P 1 t ray P P 1 t         C ) − r 2 = 0 C ) − r 2 = 0 sphere ≡ ( P − C ) i ( P − sphere ≡ ( P − C ) i ( P − Substitute    ≡ P = 0 + ray P P 1 t       C ) − r 2 = 0 sphere ≡ ( 0 + 1 t − 0 + 1 t − P P C ) i ( P P C Simplify          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-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 § Intersection point: Solve quadratic equations for t § Normal (for sphere, this is same as coordinates in sphere frame of reference, useful other tasks) § 2 real positive roots: pick smaller root   P − C = normal   § Both roots same: tangent to sphere P − C § One positive, one negative root: ray origin inside sphere (pick + root) § Complex roots: no intersection (check discriminant of equation first) Ray-Triangle Intersection Ray-Triangle Intersection § One approach: Ray-Plane intersection, then § One approach: Ray-Plane intersection, then check if inside triangle B check if inside triangle B A A n = ( C − A ) × ( B − A ) n = ( C − A ) × ( B − A ) § Plane equation: § Plane equation: ( C − A ) × ( B − A ) ( C − A ) × ( B − A )     P i  A i  P i  A i  plane ≡ n − n = 0 plane ≡ n − n = 0 § Combine with ray equation: C C      A i  0 i  ≡ P = 0 + ray P P 1 t n − P n    t =  1 t ) i  A i  1 i  0 + n = P n ( P P n 5

  6. Ray inside Triangle Ray inside Triangle § Once intersect with plane, still need to find if in P = α A + β B + γ C B triangle A β α ≥ 0, β ≥ 0, γ ≥ 0 α α + β + γ = 1 P § Many possibilities for triangles, general polygons (point in polygon tests) γ § We find parametrically [barycentric coordinates]. Also C useful for other applications (texture mapping) P − A = β ( B − A ) + γ ( C − A ) B P = α A + β B + γ C A β 0 ≤ β ≤ 1 , 0 ≤ γ ≤ 1 α α ≥ 0, β ≥ 0, γ ≥ 0 P β + γ ≤ 1 α + β + γ = 1 γ C Other primitives Ray-Tracing Transformed Objects § Much early work in ray tracing focused on ray-primitive We have an optimized ray-sphere test intersection tests § But we want to ray trace an ellipsoid … Solution: Ellipsoid transforms sphere § Cones, cylinders, ellipsoids § Apply inverse transform to ray, use ray-sphere § Boxes (especially useful for bounding boxes) § Allows for instancing (traffic jam of cars) § General planar polygons Mathematical details worked out in class § Many more § Many references. For example, chapter in Glassner introduction to ray tracing (see me if interested) Transformed Objects Outline § Consider a general 4x4 transform M § History § Will need to implement matrix stacks like in OpenGL § Basic Ray Casting (instead of rasterization) § Apply inverse transform M -1 to ray § Comparison to hardware scan conversion § Locations stored and transform in homogeneous coordinates § Shadows / Reflections (core algorithm) § Vectors (ray directions) have homogeneous coordinate set to 0 [so there is no action because of translations] § Ray-Surface Intersection § Do standard ray-surface intersection as modified § Optimizations § Transform intersection back to actual coordinates § Current Research § 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 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