Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Computer Graphics: Ray Tracing

Similar presentations


Presentation on theme: "Advanced Computer Graphics: Ray Tracing"— Presentation transcript:

1 Advanced Computer Graphics: Ray Tracing
James Gain Department of Computer Science University of Cape Town Advanced Computer GraphicsCollaborative Visual Computing Laboratory

2 Advanced Computer Graphics
Objectives To compare and contrast all the fundamental rendering techniques. To cover basic ray tracing in detail. To introduce advanced (distributed and recursive) ray tracing. 18/11/2018 Advanced Computer Graphics

3 Advanced Computer Graphics
Aims of Rendering Criteria for Rendering: Speed: Some applications (e.g. flight simulation) require interactive (> 10 Hz) rendering updates. Aesthetics: A subjective value attached by the viewer to the image. Difficult to measure. Visual Realism: An image that captures the effects of light interacting with objects (‘photorealism’). Information: How effectively the image conveys the required information. These criteria are often in conflict. 18/11/2018 Advanced Computer Graphics

4 Rendering in Computer Graphics
Principal Rendering Techniques: Polygon Scan Conversion Ray Tracing (Basic, Distributed, Recursive) Adjunct Rendering Techniques: Texture Radiosity Non-PhotoRealistic Rendering Evaluation: Realism Speed Memory Consumption ‘Real World’ choices 18/11/2018 Advanced Computer Graphics

5 Polygon Scan Conversion
Covered in 3rd year Gfx course. Final part of a typical graphics pipeline. Process of projecting, clipping, and scan line rendering a sequence of polygons with the correct relative occlusion. A Z-buffer approach is popular and often implemented in hardware on a graphics card. 18/11/2018 Advanced Computer Graphics

6 Advanced Computer Graphics
Ray Tracing A powerful alternative to polygon scan-conversion techniques. Given a set of 3D objects, shoot a ray from the eye through the centre of every pixel and see what it hits. Enables: reflection, shadows, refraction, transparency. BUT: there are tricks available in PSC to achieve similar effects. 18/11/2018 Advanced Computer Graphics

7 Advanced Computer Graphics
Texture Texture methods efficiently introduce surface detail. Multi-coloured (e.g. a painting, bottle label, page in a book), bumpy (e.g. almost every surface, few things are perfectly smooth), and textured (e.g. wood, leaves) shapes. Without Texture With Texture 18/11/2018 Advanced Computer Graphics

8 Advanced Computer Graphics
Radiosity A method which takes the diffuse interaction between surface areas into account unlike standard PSC and RT. First developed in the context of heat transfer equations. Surfaces are treated as collectors and radiators of light energy. Light is propagated between surfaces until a stable solution is achieved. The solution is independent of viewpoint and need only be calculated once for a given scene (fortunately!) Oven Door Analogy From the 1988 research paper “A Progressive Refinement Approach to Fast Radiosity Image Generation”. The factory model contains 30,000 patches, and was the most complex radiosity solution computed at that time. The radiosity solution took approximately 5 hours, and the image generation required 190 hours. 18/11/2018 Advanced Computer Graphics

9 Non-PhotoRealistic Rendering
Computer Graphics has generally striven for heightened realism. An alternative: concentrate on the aesthetics of the final image. Artistic effects: loosely simulate oil or pastel paintings, woodcuts, or pen and ink illustrations. Important to establish coherence between rendered frames of an animation. Used in the film “What Dreams May Come”. 18/11/2018 Advanced Computer Graphics

10 Advanced Computer Graphics
Direct Illumination Light may reflect off many surfaces on its way from the light to the camera. Standard ray tracing and polygon scan conversion can handle a single diffuse or specular bounce. Direct Diffuse Reflection Assumes that the object is a perfect Lambertian (diffuse) reflector. Direct Specular Reflection Use Phong approximation to true specular (highlight) reflection. 18/11/2018 Advanced Computer Graphics

11 Indirect Illumination
Distributed recursive ray tracing can handle multiple specular bounces. Recursion halts when a diffuse surface is encountered. Radiosity can handle multiple diffuse bounces. The general case (combination of diffuse and specular): Some research into this area but results tend to be very inefficient. [1] Diffuse Specular [2] SpecularSpecular [3] DiffuseDiffuse [4] SpecularDiffuse 18/11/2018 Advanced Computer Graphics

12 Advanced Computer Graphics
Rendering Evaluation PSC RT Illumination diffuse  specular specular  specular diffuse  diffuse (+ Radiosity) specular  diffuse Effects motion blur refraction reflection shadows PSC is capable of emulating many of the effects but not illumination of RT. Costs: ray tracing is significantly more computationally costly 18/11/2018 Advanced Computer Graphics

13 Advanced Computer Graphics
What is Actually Used? Visualization: Clarity over realism = PSC Sometimes volumetric rendering is required. Simulation, 3D Games: Speed over realism = PSC + (Sprites, Ray Traced backdrops, Radiosity) Extensive pre-processing is acceptable. Special Effects: Realism over speed BUT high resolution (6000x4000) = Mostly PSC + some RT for ‘beauty’ shots. Example: Toy Story (proprietary PSC required 1-3 hours per frame). Not all SFX are computer generated. Use Models, mattes (hand-painted backgrounds) and pyrotechnics. 18/11/2018 Advanced Computer Graphics

14 Advanced Computer Graphics
Ray Tracing From the Computer Animated Short Film “Tin Toy” (© Pixar) 18/11/2018 Advanced Computer Graphics

15 Advanced Computer Graphics
Ray Tracing Algorithm Select an eye point and a screen plane FOR every pixel in the screen plane [num. pixels depends on image resolution] determine the ray from the eye through the pixel’s centre FOR every object in the scene [num. objects depends on scene size] IF the object is intersected by the ray THEN IF the intersection is the closest (so far) to the eye THEN record the intersection point and object ENDIF ENDFOR set pixel’s colour to that of the object at the closest intersection point 18/11/2018 Advanced Computer Graphics

16 Intersection of a ray with a sphere
Ray (parametric): Sphere (implicit): Trick: substitute a parametric ray equation into an implicit sphere equation. Derivation: Result: real – two intersections, imaginary – no intersection, – one intersection Cylinder, cone, torus are treated similarly 18/11/2018 Advanced Computer Graphics

17 Intersection of a ray with a polygon
Plane: Ray: Derivation: Does fall inside the polygon (check by clipping against its edges). Box, polygon, polyhedron are treated as a set of bounded planes. 18/11/2018 Advanced Computer Graphics

18 Advanced Computer Graphics
Ray Tracing: shading Once , the intersection point of ray with the closest object has been found it is possible to: Find the object’s surface normal at Shoot rays from to all light sources Calculate the diffuse and specular lighting at Along with ambient illumination this gives the colour of the object at 18/11/2018 Advanced Computer Graphics

19 Advanced Computer Graphics
Ray Tracing: shadows If an object blocks the ray from the intersection point to a light source then it is casting a shadow over that point. Also need to watch out for self-shadowing. 18/11/2018 Advanced Computer Graphics

20 Recursive Ray Tracing: reflection
By spawning secondary (recursive) rays from a point of intersection reflection, transparency and refraction can be simulated. A new ray aligned with the angle of reflection enables perfect (mirror) reflection. Each new ray provides a scaled (distance attenuated) contribution to the pixel colour. 18/11/2018 Advanced Computer Graphics

21 Recursive Ray Tracing: refraction
Objects can be totally or partially transparent This allows objects behind the current one to be seen through it. Light rays which intersect transparent objects can have their contribution scaled. Transparent objects can have refractive indices Bending the rays as they pass through the objects. Supporting transparency and reflection requires that a ray be split into two parts. 18/11/2018 Advanced Computer Graphics

22 Exercise: Recursive Ray Tracing
Assuming all objects are perfect reflectors and have ambient, diffuse and specular (Phong model) lighting, show all rays and vectors needed to calculate the shading at P. 18/11/2018 Advanced Computer Graphics

23 Solution: Recursive Ray Tracing
[A] Primary Intersection [B] Secondary Intersection 18/11/2018 Advanced Computer Graphics

24 Sampling in Ray Tracing
Single Point Shoot a single ray through the pixel’s centre. Prone to aliasing problems. Super-sampling for anti-aliasing Shoot multiple rays through the pixel and average the results. Can use a regular grid, random, jittered or Poisson disc distribution of rays. Adaptive super-sampling Shoot a few rays through the pixel, check the variance of the resulting values. If sufficiently similar then stop. Otherwise, shoot some more rays. Trade-off the objectionable artefacts of aliasing for the less objectionable artefacts of noise. 18/11/2018 Advanced Computer Graphics

25 Distributed Ray Tracing
Super-sampling (and anti-aliasing) is only one reason for taking multiple samples per pixel. Many effects can be achieved by distributing multiple ray samples over some range. Called distributed ray tracing. The term distributed refers to the stochastic distribution of rays. Examples of distributed ray tracing: Distribute the rays from a light source over an area. Allows area light sources and produces soft shadows with penumbrae. Distribute the camera position over an area. Allows simulation of a camera with a finite aperture lens and produces depth of field effects. Distribute the samples in time. Produces motion blur effects on moving objects. 18/11/2018 Advanced Computer Graphics

26 Distributed Ray Tracing: area lights
Light rays coming from an area light source are distributed. If some are blocked then the point is in a penumbrae. If all are blocked then the point is in umbrae. Allows area light sources, in addition to point and directional light. 18/11/2018 Advanced Computer Graphics

27 Advanced Computer Graphics
Improving Efficiency Ray tracing (especially when distributed or recursive) is computationally costly. Naively, require a minimum of intersection tests. A small proportion of objects are intersected by a given ray. So, quickly identifying non-intersected objects is important. Speedups: Intersect bounding boxes or spheres first. Only need to test the full object if the bounding sphere is intersected. Spatial subdivision. Group objects into cells. If a ray does not pass through a particular cell it cannot intersect the objects belonging to that cell. Use Visibility pre-processing to cull out all objects and polygons invisible along a particular viewing direction. 18/11/2018 Advanced Computer Graphics


Download ppt "Advanced Computer Graphics: Ray Tracing"

Similar presentations


Ads by Google