Title: Computer Graphics Ray Tracing I
1Computer Graphics- Ray Tracing I -
2Advertisement I
- We are looking for 2 good HiWis
- Your job
- Help setting up our Visual Computing Lab
- Your qualities
- Fun tinkering with cameras, hardware
- C/C programming
- Your pay
- 20 hours/month, 7.72 EUR/hour
- If youre interested
- Send your application to cg_at_tu-bs.de
3Advertisement II
- Presentation of AMIRA visualization software
- Today, 2 pm
- Seminarraum Rechenzentrum
4Overview
- Today
- Ray tracing I
- Pinhole camera model
- Basic ray tracing
- Ray-primitive intersection
- Basic acceleration
- Next lecture
- Ray tracing II
5E-Mail List
- Register with
- http//europa.cg.cs.tu-bs.de/mailman/
- Lv
- Mailing list lv_at_cg.cs.tu-bs.de
6Radiance Recap
- Thought experiment
- Large, evenly lit surface
- Black cardboard with small hole in it
- Brightness of hole
7Radiance Recap
- Thought experiment
- Large, evenly lit surface
- Black cardboard with small hole in it
- Brightness of hole
8Radiance Recap
- Thought experiment
- Large, evenly lit surface
- Black cardboard with small hole in it
- Brightness of hole
9Radiance Recap
- Thought experiment
- Large, evenly lit surface
- Black cardboard with small hole in it
- Brightness of hole
10Camera
11Ray Optics Pinhole Camera / Camera Obscura
Goal convert light propagation direction to
position in film plane
- Pinhole small
- image sharp
- image dark
12Wave Optics Airy Disk
The smaller the aperture, the larger the image
spot
13Optimal 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
14Ray Optics Depth of Field I
15Ray Optics Depth of Field II
?s
The smaller the aperture, the larger the depth of
field
16Depth of Field Example
Large Aperature
Small Aperature
17Aberrations Radial Distortion
18Radial Lens Distortion
Short focal length
Long focal length
19Radial Distortion Correction
- Non-linear optimization
- Iterative error minimization in tandem with
calibration matrix estimation
20Spherical Aberration
21Chromatic Aberration
22Lens Flare
Flare due to reflections on optical surfaces
23Vignetting
- 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
24Shutter Speed - Motion Blur
25Tracing the Path of Light
26Ray Tracing Ingredients
- Assumption air/empty space totally transparent
- Surfaces
- 3D geometry models of objects
- solid
- 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
27Ray Tracing
- Highly Realistic Images
- Ray tracing enables correct simulation of light
transport
Internet Ray Tracing Competition, June 2002
28Light 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
29Ray Tracing
- One of two fundamental rendering paradigms
- Other one is rasterization (CG II - 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
30Ray 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
31Fundamental 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
32Ray 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
33Primary 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
34Perspective 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
35Intersection 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
36Intersection 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
37Intersection 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.
382D 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
393D 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
40Precision Problems
41Wrap-Up
- Forward Light Transport in Nature vs. Backward
Propagation in Ray Tracing - Ray tracing physical quantity radiance
- Ray Tracer
- primary ray, ray-object intersection, shading
- Ray-Geometry Intersection Calculation