Computer Graphics 2 Lecture 13: Ray-Tracing Techniques - PowerPoint PPT Presentation

Loading...

PPT – Computer Graphics 2 Lecture 13: Ray-Tracing Techniques PowerPoint presentation | free to download - id: 69cb52-NmIxY



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Computer Graphics 2 Lecture 13: Ray-Tracing Techniques

Description:

Computer Graphics 2 Lecture 13: Ray-Tracing Techniques Dr. Benjamin Mora University of Wales Swansea * Benjamin Mora – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 55
Provided by: csSwanAc6
Learn more at: http://cs.swan.ac.uk
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Computer Graphics 2 Lecture 13: Ray-Tracing Techniques


1
Computer Graphics 2Lecture 13Ray-Tracing
Techniques
Dr. Benjamin Mora
University of Wales Swansea
1
Benjamin Mora
2
Content
  • What is Ray-Tracing?
  • Mathematics for ray-tracing intersections.
  • Common Ray-Tracing effects.
  • Other Ray-Tracing Algorithms.
  • Current Ray-Tracing Technology.

University of Wales Swansea
2
Benjamin Mora
3
What Is Ray-Tracing ?
University of Wales Swansea
3
Benjamin Mora
4
What is Ray Tracing ?
  • The alternative to rasterization-based methods
    (like OpenGL or DirectX).
  • Image-Order algorithm.
  • Every pixel is processed separately.
  • Slower than rasterization methods in the case of
    few primitives to render.
  • Rarely used in games, widely used for realistic
    computer graphics.
  • www.povray.org.

University of Wales Swansea
4
Benjamin Mora
5
What is Ray Tracing ?
Jaime Vives Piqueres (2004), http//www.povray.org
/i/hof/office-13.jpg
University of Wales Swansea
5
Benjamin Mora
6
What is Ray Tracing ?
Jaime Vives Piqueres (2001), http//www.povray.org
/i/hof/office-13.jpg
University of Wales Swansea
6
Benjamin Mora
7
What is Ray Tracing ?
University of Wales Swansea
7
Benjamin Mora
8
What is Ray Tracing ?
  • Basic (or Naïve )Algorithm (Whitted 1980)
  • FOR every pixel DO
  • FOR every primitive in the scene DO
  • IF there is a ray/primitive intersection
  • test if this is the closest intersection
    computed so far.
  • If this is the case,
  • keep this primitive as the closest
    primitive for the next tests.
  • Basic Complexity
  • O(number of raysnumber of primitives).
  • Optimized algorithms can do much better (See the
    next lectures)!

University of Wales Swansea
8
Benjamin Mora
9
Mathematics for Ray-Tracing intersections
University of Wales Swansea
9
Benjamin Mora
10
Parametric Ray/Plane Formulation
  • A ray can be described with a parametric
    formulation from a (starting) point and a
    direction
  • A parametric plane can be described from one
    point and two vectors
  • A plane can also be defined from a point and a
    normal vector (here P0 and Vz).

University of Wales Swansea
10
Benjamin Mora
11
Ray/Plane Intersection
  • We are looking for the point p(t) such that p(t)
    belong to the plane h.
  • h is defined with a point o and a normal n.
  • If vdir perpendicular to n, then either 0
    solution, or an infinite number of solutions if
    p0 belongs to h (the vector p0o perpendicular to
    n).

University of Wales Swansea
11
Benjamin Mora
12
Ray/Plane Intersection
  • Otherwise, there is only one point that is
    solution. We have to find out t.
  • The solution comes from the fact that the vector
    p(t)o is perpendicular to n

University of Wales Swansea
12
Benjamin Mora
13
Ray/Cube Intersection
p(t) p0 vt
v
The ray intersects the cell only if max(txmin,
tymin)ltmin(txmax, tymax). Finding out the exit
face consists of finding out the minimum of
(txmax, tymax).
University of Wales Swansea
13
Benjamin Mora
14
Ray/Cube Intersection
  • A cube can be defined with 6 planes (faces).
  • 3 pairs of opposite faces (lets reference them
    as x,y,z) .
  • A parametric ray p(t) intersects 2 opposite faces
    at 2 locations, with 2 respective parameters tmin
    and tmax. (lets suppose tminlttmax).
  • The 6 faces are intersected with 6 different
    parameters (txmin,txmax, tymin,tymax,
    tzmin,tzmax).
  • The ray intersects the cube only if
  • Max (txmin,tymin,tzmin)lt Min(txmax,tymax,tzmax).

University of Wales Swansea
14
Benjamin Mora
15
Ray/Sphere Intersection
  • A sphere can be defined by a center o and a
    radius r.
  • Looking for the points p(t) such as
    norm(p(t)o)r.

University of Wales Swansea
15
Benjamin Mora
16
Ray/Triangle Intersections
  • Several ways to achieve this goal.
  • Badouels Algorithm.
  • Mollers Algorithm (not shown).
  • Other Algorithm (close to Segura et al. 98).

University of Wales Swansea
16
Benjamin Mora
17
Badouels Algorithm
  • First, find the intersection p(t) between the ray
    and the plane containing the triangle.
  • Then use the barycentric coordinates of the point
    to sort the intersection out (2D algorithm).

University of Wales Swansea
17
Benjamin Mora
18
Other Ray/Triangle Algorithms
  • The edges of the triangles can be considered as
    oriented.
  • The Ray should always be on the same side of
    the edges
  • gt Three triple products with the same sign.

p
vdir
p0
p1
p(t)
p2
Segura, R.J., Feito, F.R. Segura, R.J., Feito,
F.R. An algorithm for determining intersection
segment-polygon in 3D. Computer Graphics,
Vol.22, No.5, pp.587-592, 1998.
University of Wales Swansea
18
Benjamin Mora
19
Other Ray/Triangle Algorithms
  • There is an intersection Ray/Triangle only if
  • Fast algorithm.
  • Can take advantage of SIMD instructions on
    processor.
  • But
  • Only in order to detect an intersection.
  • Extra work must be done in order to get the
    tri-linear interpolating weights (including a
    div) and the real intersection location if needed
    (but not always required).

University of Wales Swansea
19
Benjamin Mora
20
Triangle/Box Intersection
  • Why?
  • Bounding boxes are used much to speed-up
    intersections.
  • Standalone boxes.
  • Spatial subdivision techniques.
  • Therefore needed to construct such acceleration
    structures.

University of Wales Swansea
20
Benjamin Mora
21
Triangle/Box Intersection
  • Solution 1 Working in the triangle plane.
  • For every face of the cube
  • Find the face/triangle plane intersection.
  • A line!
  • Clip the triangle/polygon with this line.
    (Sutherland ).
  • Intersection occurs if result not NULL!
  • Complex and Costly.

University of Wales Swansea
21
Benjamin Mora
22
Triangle/Box Intersection
  • Solution 2 Use the Separating Axis Theorem.
    (Akenine-Moller)
  • No intersection occurs between 2 convex objects
    if there exists a separating plane.

University of Wales Swansea
22
Benjamin Mora
23
Triangle/Box Intersection (2D)
University of Wales Swansea
23
Benjamin Mora
24
Triangle/Box Intersection (2D)
University of Wales Swansea
24
Benjamin Mora
25
Triangle/Box Intersection (3D)
  • 13 planes to be tested in 3D.
  • For each plane
  • Compute distances to the triangle vertices
  • Using the plane equation.
  • Compute distances to the box vertices.
  • No intersection if MIN of one distance set
    greater than MAX of the other distance set.
  • If condition is false for all 13 cases, an
    intersection exists.

University of Wales Swansea
25
Benjamin Mora
26
Triangle/Box Intersection (3D)
  • Plane directions are determined from
  • Where Ei are the directions of the edges of the
    box, and Tj the directions of the edges of the
    triangle. (9 cases)
  • The faces of the box. (3 cases)
  • The triangle plane normal. (1 case)

University of Wales Swansea
26
Benjamin Mora
27
Simple Ray-Tracing Effects
University of Wales Swansea
27
Benjamin Mora
28
Simple Ray-Tracing Effects
  • The main operation is to find an intersection
    from a given ray.
  • This operation can be used (by casting secondary
    rays) to compute simple effects that are more
    difficult to implement with OpenGL like (but
    fog)
  • Reflection.
  • Refraction.
  • Shadows.
  • Fog.

Source Min Chen
University of Wales Swansea
28
Benjamin Mora
29
Simple Ray-Tracing Effects
  • Basic Lighting model

Rin
kt
Rfr
km
Rfl
University of Wales Swansea
29
Benjamin Mora
30
Simple Ray-Tracing Effects
  • Shading can be done in the same way as to OpenGL.
  • But better methods exist.

N
V (-Rin)
L
R
Source Min Chen
University of Wales Swansea
30
Benjamin Mora
31
Simple Ray-Tracing Effects
  • Reflection

University of Wales Swansea
31
Benjamin Mora
32
Simple Ray-Tracing Effects
  • Reflection

N
Vincident
Vreflected
?i
?i
L
University of Wales Swansea
32
Benjamin Mora
33
Simple Ray-Tracing Effects
  • Refraction

University of Wales Swansea
33
Benjamin Mora
34
Simple Ray-Tracing Effects
  • Total Internal Reflection

University of Wales Swansea
34
Benjamin Mora
35
Simple Ray-Tracing Effects
  • Taking into account reflection and refraction
    several times (recursively) requires an
    exponential number of rays!
  • The algorithm should stop after reaching a
    maximum number of consecutive reflections/refracti
    ons.
  • Only reduced to some specific lighting effects.

University of Wales Swansea
35
Benjamin Mora
36
Simple Ray-Tracing Effects
University of Wales Swansea
36
Benjamin Mora
37
Simple Ray-Tracing Effects
  • Fog effect (also possible with OpenGL).
  • Depth Cue
  • Fog

or
University of Wales Swansea
37
Benjamin Mora
38
Simple Ray-Tracing Effects
  • Super Sampling can be used in order to improve
    Anti-Aliasing.

University of Wales Swansea
38
Benjamin Mora
39
Simple Ray-Tracing Effects
University of Wales Swansea
39
Benjamin Mora
40
Simple Ray-Tracing Effects
  • The final color is the average of all the
    sub-sampled rays.
  • Uniform Super-Sampling
  • Nice but not always needed.
  • Adaptive Super-Sampling
  • Useful for the regions with large color
    transitions (high frequencies), like object
    boundaries.
  • Trade-off between quality and speed.
  • Stochastic Super-Sampling
  • Take advantage of the visual system limitations.

University of Wales Swansea
40
Benjamin Mora
41
Simple Ray-Tracing Effects
  • Stochastic Super-Sampling
  • Proposed by Robert L. Cook.
  • Stochastic Sampling in Computer Graphics, ACM
    transaction on Graphics No. 5(1), January 1986,
    pp. 51-72.
  • The ray location(s) are randomly chosen inside a
    pixel.
  • Our visual system is less sensitive to noise than
    to contours.

University of Wales Swansea
41
Benjamin Mora
42
Other Ray-Tracing Algorithms.
University of Wales Swansea
42
Benjamin Mora
43
Other Ray-Tracing Algorithms.
  • Pyramidal Ray-Tracing.
  • Cone Tracing.
  • Beam Tracing.

University of Wales Swansea
43
Benjamin Mora
44
Pyramidal Ray-Tracing.
  • Proposed by
  • And improved by
  • Main Idea Replacing Rays by Pyramids to improve
    aliasing.

Whitted, Turner. An Improved Illumination Model
for Shaded Display. C.A.C.M. vol. 23, no. 6, June
1980, pp. 343-319.
J. Genetti, D. Gordon and G. Williams. Adaptive
supersampling in object space using pyramidal
rays. Computer Graphics Forum 17 (1998) 29-54.
University of Wales Swansea
44
Benjamin Mora
45
Pyramidal Ray-Tracing.
J. Genetti, D. Gordon and G. Williams. Adaptive
supersampling in object space using pyramidal
rays. Computer Graphics Forum 17 (1998) 29-54.
University of Wales Swansea
45
Benjamin Mora
46
Pyramidal Ray-Tracing.
  • If a pyramid only partially intersects a graphics
    primitive (e.g., triangle), then the pyramid is
    subdivided until a given depth is reached.
  • The final pixel value is the (weighted) average
    of all the samples inside the triangle.
  • Non-intersecting pyramids keep on computing
    intersections with the rest of the scene.

University of Wales Swansea
46
Benjamin Mora
47
Cone Tracing.
  • Proposed by

John Amanatides. Ray Tracing with Cones. Siggraph
1984, pp. 129-135.
image plane
primary ray
viewlocation
Partial intersection
University of Wales Swansea
47
Benjamin Mora
48
Cone Tracing.
  • Similar to pyramidal ray-tracing, but the pyramid
    is now replaced by a cone.
  • Allows easier intersection computations.
  • 1 cone per pixel, no subdivision.
  • For a ray-triangle intersection
  • The cone is projected onto the triangle plane.
  • Circular projection.
  • If there is a partial intersection detected, the
    colour of the triangle is weighted by the
    corresponding covering percentage, and computing
    intersections will carry on.

University of Wales Swansea
48
Benjamin Mora
49
Cone Tracing Result
University of Wales Swansea
49
Benjamin Mora
50
Beam Tracing.
  • Proposed by
  • Takes advantages of spatial coherency between
    rays to group them and save computations.
  • Rays are distributed after Reflections and
  • Refractions according to the
  • reflection/refraction coefficients.
  • Constructs a beam tree.
  • Outdated.

Paul S. Heckbert and Pat Hanrahan. BEAM TRACING
POLYGONAL OBJECTS. Siggraph 1984, pp. 119-127.
University of Wales Swansea
50
Benjamin Mora
51
Current Ray-Tracing Technology
University of Wales Swansea
51
Benjamin Mora
52
Current Ray-Tracing Technology
  • Ray-Tracing is now used a lot for realistic
    rendering of scenes.
  • Not just Reflections/Refractions.
  • Has a better complexity than OpenGL based
    renderings (when optimized).
  • Scalable.
  • A simple ray representation (no cone or pyramid)
    is often used.
  • Therefore, researchers have recently tried to
    hardware accelerate it.

University of Wales Swansea
52
Benjamin Mora
53
Current Ray-Tracing Technology
  • 3 different approaches
  • Cluster based CPU approach.
  • Use SIMD instructions with packed rays.
  • A lot of threads in parallel.
  • GPU Based.
  • Not very efficient because not really designed
    for RT.
  • Hardware (FPGA) accelerated ray-tracing.
  • Seems to be efficient.
  • Need to compute a spatial subdivision tree first,
    which is not really appropriate to dynamic
    scenes.

Ingo Wald, Timothy J. Purcell, Jörg Schmittler,
Carsten Benthin and Philipp Slusallek. Realtime
Ray Tracing and its use for Interactive Global
Illumination. Eurographics 2003 State of the Art
Report.
Tim Foley, Jeremy Sugerman. KD-Tree Acceleration
Structures for a GPU Raytracer. In Proceedings of
Graphics Hardware 2005.
University of Wales Swansea
53
Benjamin Mora
54
Current Ray-Tracing Technology
  • The RPU unit. See Video !!!

Sven Woop, Jorg Schmittler, and Philipp
Slusallek. RPU A Programmable Ray Processing
Unit for Realtime Ray Tracing. Siggraph 2005.
University of Wales Swansea
54
Benjamin Mora
About PowerShow.com