Computer Graphics Ray Tracing I - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Computer Graphics Ray Tracing I

Description:

Ray Optics: Depth of Field I. Lens Formula. Object center in focus. Object front in focus ... Depth of Field: Example. Large Aperature. Small Aperature ... – PowerPoint PPT presentation

Number of Views:123
Avg rating:3.0/5.0
Slides: 45
Provided by: marcus45
Category:

less

Transcript and Presenter's Notes

Title: Computer Graphics Ray Tracing I


1
Computer Graphics- Ray Tracing I -
  • Marcus Magnor

2
Overview
  • Today
  • Ray tracing I
  • Pinhole camera model
  • Basic ray tracing
  • Ray-primitive intersection
  • Basic acceleration
  • Next lecture
  • Ray tracing II

3
E-Mail List
  • Register with
  • http//europa.cg.cs.tu-bs.de/mailman/
  • Lv
  • Mailing list lv_at_cg.cs.tu-bs.de

4
Radiance Recap
  • Thought experiment
  • Large, evenly lit surface
  • Black cardboard with small hole in it
  • Brightness of hole

5
Radiance Recap
  • Thought experiment
  • Large, evenly lit surface
  • Black cardboard with small hole in it
  • Brightness of hole

6
Radiance Recap
  • Thought experiment
  • Large, evenly lit surface
  • Black cardboard with small hole in it
  • Brightness of hole

7
Radiance Recap
  • Thought experiment
  • Large, evenly lit surface
  • Black cardboard with small hole in it
  • Brightness of hole

8
Camera
9
Ray Optics Pinhole Camera / Camera Obscura
Goal convert light propagation direction to
position in film plane
  • Pinhole small
  • image sharp
  • image dark

10
Wave Optics Airy Disk
The smaller the aperture, the larger the image
spot
11
Optimal Imaging Resolution Matching
Given pixel size and focal length, what is the
optimal aperture ?
Optical aperture serves as low-pass filter
Aperture too small ? Airy Disk larger than pixel
? Image resolution wasted
Aperture too large ? Airy Disk smaller than pixel
? Aliasing
12
Ray Optics Depth of Field I
13
Ray Optics Depth of Field II
?s
The smaller the aperture, the larger the depth of
field
14
Depth of Field Example
Large Aperature
Small Aperature
15
Aberrations Radial Distortion
16
Radial Lens Distortion
Short focal length
Long focal length
17
Radial Distortion Correction
  • Non-linear optimization
  • Iterative error minimization in tandem with
    calibration matrix estimation

18
Spherical Aberration
19
Chromatic Aberration
20
Lens Flare
Flare due to reflections on optical surfaces
21
Vignetting
  • Cos-4th law oblique angle
  • lens aperature appears as ellipse
  • light strikes film at an angle
  • increased distance from aperture to off-axis
    portion of film

22
Shutter Speed - Motion Blur
23
Tracing the Path of Light
  • Some light rays (like A and E) never reach the
    image plane at all. Others follow simple (like C)
    or complicated routes. In general, it would be
    impractical to analyze all possible light paths
    because most of them do not have any practical
    influence on generated image (do not intersect
    the image plane). In ray tracing, light rays are
    processed in inverse direction. It is assumed
    that all rays start at the eye of an observer
    (the viewing point), pass through the image plane
    toward objects in a scene, and finally reach the
    light sources. This approach reduces the number
    of traced light rays.

24
Ray Tracing Ingredients
  • Assumption air/empty space totally transparent
  • Surfaces
  • 3D geometry models of objects
  • Surface reflectance characteristics
  • Color, absorption, reflection
  • Local property, may vary over surface
  • Mirror, glass, glossy, diffuse,
  • Illumination
  • Position, characteristics of light emitters
  • Multiply reflected light indirect light

25
Ray Tracing
  • Highly Realistic Images
  • Ray tracing enables correct simulation of light
    transport

Internet Ray Tracing Competition, June 2002
26
Light Transport
  • Light Distribution in a Scene
  • Dynamic equilibrium from
  • Newly created photons, reflected photons, and
  • absorbed photons
  • Forward Light Transport
  • Start at the light sources
  • Shoot photons into scene
  • Reflect at surfaces (according to some reflection
    model)
  • Wait until they are absorbed or hit the camera
    (very seldom)
  • ? Nature massive parallel processing at the
    speed of light
  • Backward Light Transport
  • Start at the camera
  • Trace only paths that transport light to the
    camera
  • ? Ray tracing

27
Ray Tracing
  • One of two fundamental rendering paradigms
  • Other one is rasterization (summer semester ?)
  • Simple and intuitive
  • Easy to understand and implement
  • Powerful and efficient
  • Offers more featuresshadows, reflection,
    refraction and other global effects
  • Efficient real-time implementation in SW and HW
  • Scalability
  • Can work in parallel and distributed environments
  • Logarithmic scalability with scene size O(log n)
    vs. O(n)
  • Output sensitive and demand-driven
  • Not new
  • Light rays Empedocles, renaissance, lens design,
    geometric optics

28
Ray Tracing
  • In the Past
  • Only used as an off-line technique
  • Was computationally far too demanding
  • Rendering times of minutes and hours
  • Can reproduce subtle effects for enhanced realism
  • Multiple bounces
  • Global illumination
  • Caustics
  • Recently
  • Interactive ray tracing on supercomputers
    Parker, U. Utah98
  • Interactive ray tracing on PCs Wald01
  • Distributed ray tracing on PC clusters Wald01

29
Fundamental Ray Tracing Steps
  • Primary ray generation
  • Rays from viewpoint along viewing directions into
    3D scene
  • (At least) one ray per picture element (pixel)
  • Ray tracing
  • Intersection of primary ray with scene geometry
  • Intersected object and intersection coordinates
    on object
  • Shading
  • From intersection, determine radiance along
    primary ray
  • Determines pixel color
  • Needed
  • Local material color and reflection properties
  • Object texture
  • Local illumination of intersection point
  • Can be impossible to determine correctly

30
Ray and Object Representations
  • Ray in space r(t)ot d
  • o(ox, oy, oz)
  • d(dx, dy, dz)
  • Scene geometry
  • Plane (p-a)n0
  • Implicit definition
  • n surface normal
  • a one given surface point
  • p any surface point
  • Sphere (p-c)(p-c)-r20
  • c sphere center
  • r sphere radius
  • p any surface point
  • Triangles barycentric coordinates
  • Later Intersection coordinates between ray and
    3D object geometry

31
Primary Ray Generation
  • Ray from viewpoint through pixel into scene
    pinhole camera model
  • Compute intersection of ray with scene geometry
  • Pixel color intersected object point color
    shading
  • Hidden surface detection consider only closest
    hit surface

32
Perspective Camera Model
  • Definition of the pinhole camera
  • o Origin (point of view)
  • f Vector to center of view, focal length
  • x, y Span half the viewing window (frustrum)
    or opening angle of frustrum
  • u Up-vector of camera orientation, in one
    plane with y vector
  • xres, yres Image resolution

for (x 0 x lt xres x) for (y 0 y lt yres
y) d f 2(x/xres - 0.5)?x
2(y/yres - 0.5)?y d d/d // Normalize
col trace(o, d) write_pixel(x,y,col)
x
y
d
f
u
o
33
Intersection Ray -Sphere
  • Sphere
  • Given a sphere at the origin
  • x2 y2 z2 - 10
  • Given a ray
  • r o td (rx ox tdx and so on)
  • o origin, d direction
  • Substituting the ray into the equation for the
    sphere gives
  • t2(dx2 dy2 dz2) 2t (dxox dyoy
    dzoz) (ox2 oy2 oz2) 1 0
  • Easily solvable with standard techniques
  • But beware of numerical imprecision
  • Alternative Geometric construction
  • Ray and center span a plane
  • Simple 2D construction
  • Requires only dot products

34
Intersection Ray - Plane
  • Plane
  • Plane Equation pn - D 0, n 1
  • Implicit representation (Hesse form)
  • Normal vector n
  • Normal distance from (0, 0, 0) D
  • Two possible approaches
  • Geometric
  • Mathematic
  • Substitute o td for p
  • (o td)n D 0
  • Solving for t gives

d
o
dn
n
on
D
p
35
Intersection Ray- Box
  • Ray/box intersections are important because
    boxes are used as bounding volumes, especially in
    hierarchical schemes. To check if a ray
    intersects a box, we treat each pair of parallel
    planes in turn, calculating the distance along
    the ray to the first plane tnear and the second
    plane tfar. If the value of tnear for one pair
    of planes is greater than tfar for another pair
    of planes, the ray cannot intersect the box.

36
2D Intersection Ray - Triangle
  • Barycentric coordinates
  • Non-degenerate triangle ABCP ?1A ?2B ?3C
  • ?1 ?2 ?3 1
  • areal barycentric coordinates?3 ?(APB) /
    ?(ACB) etc
  • For fixed ?3, P moves parallel to AB
  • For ?1 ?2 1P (1-?3) (?1A ?2B) ?3C (0 lt
    ?3 lt 1)
  • P moves between C and AB
  • Point is in triangle , iff all ?i greater or
    equal than zero

37
3D Intersection Ray - Triangle
  • Compute intersection with triangle plane
  • Given the 3D intersection point
  • Project point into xy, xz, yz coordinate plane
  • Use coordinate plane that is most aligned
  • xy if nz is maximal, etc.
  • Coordinate plane and 2D vertices can be
    pre-computed
  • Compute barycentric coordinates
  • Test for positive BCs

38
Precision Problems
  • Inaccuracies of the intersection points
    computations due to floating-point arithmetic can
    result in incorrect shadow rays (self-shadowing)
    or infinite loops for secondary rays which have
    origins at a previously found intersection point.
    A simple solution is to check if the value of
    parameter t (used for intersection point
    calculations) is within some tolerance. For
    example, if abs(t) lt 0.00001, then that t
    describes the origin of some ray as being on the
    object. The tolerance should be scaled to the
    size of the environment.

39
Shading
  • Intersection point determines primary rays
    radiancegt determines pixel color
  • Diffuse object color at intersection point
  • No variation with viewing angle diffuse,
    Lambertian
  • Must still be illuminated
  • Scales linearly with received radiosity
  • No illumination in shadow black
  • Non-Lambertian Reflectance
  • Surface point appearance depends on illumination
    direction and viewing direction
  • Local Bi-directional Reflectance Distribution
    Function (BRDF)
  • Simple cases
  • Mirror, glass secondary rays
  • Point light source shadow ray
  • Extended light sources, indirect illumination
    arbitrarily difficult

40
Recursive Ray Tracing
  • Searching recursively for paths to light sources
  • Interaction of light material at intersection
    points
  • Recursively trace new rays in reflection,
    refraction and light direction

shadow rays
reflected ray
refracted ray
pixel
image plane
primary ray
viewpoint
41
Recursive Ray Tracing
  • Pixel color depends on material property at
    ray-surface intersection point
  • Shading
  • Needs illumination at intersection point
  • of new rays depends on material properties
  • Mirror 1 ray
  • Semi-transparent 2 rays
  • Diffuse ??? Rays

42
Ray Tracing Algorithm
  • Trace(ray)
  • Search the next intersection point ? (hit,
    material)
  • Return Shade(ray, hit, material)
  • Shade(ray, hit, material)
  • For each light source
  • if ShadowTrace(ray to light source, distance)
  • Calculate reflected radiance (i.e. Phong)
  • Adding to the reflected radiance
  • If mirroring material
  • Calculate radiance in reflected direction
    Trace(R(ray, hit))
  • Adding mirroring part to the reflected radiance
  • Same for transmission
  • Return reflected radiance
  • ShadowTrace(ray, dist)
  • Return false, if intersection point with distance
    lt dist has been found

43
Ray Tracing Approximations
  • RGB instead of full spectrum
  • Finite number of point light sources instead of
    full hemisphere
  • Approximate material reflectance properties
  • ambient constant, non-directional, background
    light,
  • diffuse light reflected uniformly in all
    directions,
  • specular light of higher intensity in
    mirror-reflection direction.
  • All these approximations are based on purely
    empirical foundations

44
Wrap-Up
  • Forward Light Transport in Nature vs. Backward
    Propagation in Ray Tracing
  • Ray-traced Physical Quantity Radiance
  • Ray Tracer
  • primary ray, ray-object intersection, shading
  • Ray-Geometry Intersection Calculation
  • Recursive Ray Tracing Algorithm
  • Primary, secondary, shadow rays
Write a Comment
User Comments (0)
About PowerShow.com