# CS488 - Introduction to Computer Graphics - Lecture 33

## Review

1. Human skin
2. Mown grass
3. Return preliminary proposal

## Modelling

#### Particle Systems

What are they?

1. Collections of particles that taken together represent something
• plants like grasses
• hair or fur
• fire
• splashing water
• etc.
2. Each particle has
1. an initial state
• position
• velocity
• size
• colour and/or luminosity
• etc
2. an update function
• changes the state
• can have random perturbations
3. Dynamics has
• transient properties

How to use them for animation.

1. Something starts emitting particles at time t0
2. At each subsequent time step
1. Existing particles are updated
3. New particles are created
4. All particles are rendered.
3. Until it stops emitting particles at t1.

How to use them for visualization.

1. Example. For visualizing motion in a fluid
2. Let them be carried by the fluid
3. Until the fluid flows out of the scene.

How to use them for ray-tracing.

Two ways

1. Let the particle system get into a steady state, then freeze and put into the scene.
• fire, cloud
2. Accumulate the path of each particle, then use it as the shape of a linear primitive
• hair, fur, grass

#### Fractal Terrain Generation

What is it?

• A way of getting not-too-regular, not-too-random terrain,
• without positioning every vertex yourself.

How is it done?

• height at each vertex is average height + h(n) with n = 1
• h(n) is a random function with expectation zero
2. Divide each edge in two by positioning a new vertex in its middle.
• new vertex height is average edge height + h(n = n+1)
• magnitude of h(n) probably decreases with n
4. Iterate to 2 until it's good enough.

Tricks.

1. Gets expensive fast. Do as few iterations as possible.
2. Don't look directly down on it. Why?
3. h(n) will need extensive tweaking. Don't get discouraged if you don't get the results you want right away.
4. You could do the first few iterations by hand to control the large-scale result.

What is it good for?

1. Mountains
2. Rolling hills
3. Sand dunes. You will want h(n) to depend on the direction of the edge.
4. etc.

## Polyhedra and Meshes

What is a polyhedron?

1. A set of vertices
2. Connected by edges
3. Which define faces

Ray Tracer format

1. Array of edges (3 floats)
2. Array of faces (pointers to vertices, needs to know number of vertices)
3. Build the arrays as you read the input.

1. Finding the faces that surround a vertex, or the edges that emanate from a vertex
2. Modifying the mesh.
1. Add a vertex and a face, easy.
2. Add a vertex, split a face, need to find the face.
3. What's hard is finding the face to delete. ( O(nFaces) )

An improved solution

1. Build a list of faces for each vertex when reading the input
2. Can now find faces from vertices. To split a vertex
• Overwrite the deleted face with one of the new faces
• Add the other new faces to the end of the face array.
3. General deletion is still hard, unless you are willing to tolerate holes in the array.