E + t*(P - E)

Set of points {Q} satisfying

- f(Q) = 0
- Usually f(Q) is a distance function from the surface.
- f(Q) > 0 means outside,
- f(Q) < 0 means inside

- This is the surface of an object. (How do you know?)
- Why don't we care about inside points?

Solve the equation

- f(E + t*(P-E)) = 0 for t.

- In object coordinates each point is given by the object definition.
- In world coordinates each point in object coordinates is Q = MQ', where
Q' is the point in object coordinates
- M is the affine modelling transformation, therefore invertible
- f'(Q') is the object definition in object coordinates, which is usually known

- Use invM to transform E,P to E',P', then solve the equation for t
- Find intersection point in world coordinates as E + t*(P-E)

When we have found the intersection point we need to calculate a colour.

We know

- The eye ray, e = Q-E
- Surface properties
- The normal vector, n
- by interpolation from vertex normals
- by calculation from the equation of the surface

For each light

- Calculate illumination: RGB - the colour, l - the light ray
- Accumulate outgoing light

for ambient use surface RGB and illuminant RGB to calculate colour for each source of illumination calculate the illumination of the intersection point by the source: RGB calculate the direction of the illumination, l use e, n, l to calculate intensity of light along eye ray -- probably using Phong lighting model use surface RGB and illuminant RGB to calculate colour add to colour

Illumination may be blocked by occluding objects

In principle,

- Do an intersection test from the light
- in the direction of the eye ray intersection

- If it hits the eye ray intersection, then
- intersection illuminated by that light

else

- intersection in shadow from that light

Add the the code above

cast a ray from the illuminant in the direction of the intersection if first point intersected is the intersection then

In practice this means

- Translate the illuminant to the origin
- Run the usual intersection code using l

Just extent the eye ray into the virtual world behind the mirror

In practice this means

- Translate the intersection point on the mirror to the origin
- Run the usual intersection code using e = e - 2 n \dot e

Just what the name says, but why would you do it?

- Unusual light paths for illumination, such as colour bleeding, reflection

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

- Calculate the gradient

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 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

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 ...

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

- 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