CS488 - Introduction to Computer Graphics - Lecture 22
Ray Tracing
Transforming Surface Normals
The tangent plane (space)
Implicit surfaces, i.e., given by f(Q) = 0.
- Normal is perpendicular to the tangent space: n \dot (Q' - Q) as Q'
-> Q for all Q' on the surface.
- Normal is grad f(Q) = i df/dx + j df/dy + k df/dz
Calculating the tangent plane in practice
Either
Or
- Choose two points, Q1 & Q2, slighty away from Q in different
directions
- The points must lie on the surface: f(Q1) = f(Q2) = 0
- The plane spanned by Q-Q1 and Q-Q2 is an approximation to the tangent
plane
The normal vector
The normal vector is the outward facing unit vector perpendicular to the
tangent plane.
It is defined by
- |n| = 1
- n \dot t1 = 0
- n \dot t2 = 0
t1 & t2 can be the vectors Q-Q1 & Q-Q2.
In practice
- 2 & 3 are linear equations
- Solve them up to a constant
- That is, solve for nx/nz and ny/nz
- Use 1 to set the overall normalization
Transformations
Transforming the normal vector
- Under an affine transformation, M, Q goes to MQ, and Q' goes to
MQ'.
- The new tangent, n1, is defined by n1.M(Q'-Q) = 0.
- u \dot Mv = 0 if and only if inv(transposeM)u \dot v = 0.
- Therefore n' = inv(transposeM)n is the transformed normal vector.
Most of the time this doesn't matter, but ...
Speeding Up Intersection Tests
- Bounding Volumes (usually Boxes)
- Find the smallest - or close to smallest - regular volume that
encloses the object
- Use ray-intersect-volume as a pretest for fast negative
results.
- Trade-off between
- benefit of quicker `miss'detection
- cost of getting a good bounding surface
- Both increase as complexity of primitive increases
Scene subdision
- Divide the scene volume into sub-volumes: many ways to do it, such
as
- quad-trees
- oct-trees
- BSP trees
- ...
- List all primitives by sub-volume.
- Only test primitives in the sub-volumes through which a ray
passes.
- Solid Textures
- Solution to mapping texture onto curved surfaces
- Usually procedural
Anti-aliasing
Two different, but linked, types of artifacts
- Spatial (or temporal) frequency aliasing,
- image features appear at innappropriate sizes
- Reconstruction aliasing
- totally new features, like jaggedness, appear.
Exact solutions are simple in principle
- Remove high spatial frquencies by filtering
- Fourier transform in image space: remember that you need to keep
both amplitude and phase.
- Filter
- Inverse transform in image space
Filtering is the tricky part.
- Use a sampling filter that is the inverse of the reconstruction filter
- For the display to be used find the pixel shape
- Construct a sampling filter appropriate for the pixel shape
- Do ray-tracing calculating over a weighted area
Finding the pixel shape is the hard part.
In practice
- Beam tracing
- Super-sampling
- Stochastic super-sampling
Modelling
Constructive Solid Geometry (CSG)
Geometric primitives can make other geometric primitives by
- union
- intersection
- subtraction
The result is like sculpting; the problem is that describing the result is
very difficult; the solution is
- Keep the combined primitives uncombined in the model
- Do the set operations on the ray
Texture Mapping
- Basic
- Start with a 2D image: pixellated or procedural
- Map 2D image onto primitive using a 2D affine transformation
- Simple if the surface of the primitive is flat
- otherwise, ...
- Backwards map intersection point with ray into the image to get the
surface properties
- Normal Mapping (Bump mapping)
- Start with a difference surface, defined with respect to the
surface
- Calculate the normals to the difference surface and map them onto
the surface of the primitive
- Use the mapped surface models for lighting
- No occlusion, shadows are wrong, silhouettes are wrong, nobody
notices!
- Solid Textures
- Solution to mapping texture onto curved surfaces
- Usually procedural
Return to: