CS488 - Introduction to Computer Graphics - Lecture 19
Comments and Questions
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, ...
- Texture pixels normally do not match display pixels, so some
image processing may be needed.
- Backwards map intersection point with ray into the image to get the
surface properties
- Solid Textures
- Solution to mapping texture onto curved surfaces, or onto surfaces
where you see more than one side
- Usually procedural
- Normal Mapping (Bump mapping)
- Start with a difference surface, defined with respect to the surface
- Where does the difference surface come from?
- Geometric models
- Meshes,
- Scanning
- Calculate the normals to the difference surface and map them onto
the surface of the primitive
- How do you calculate the normals?
- Geometric models: differentiate analytically
- Meshes, scanned models: differentiate numerically
- Use the mapped surface models for lighting
- No occlusion, shadows are wrong, silhouettes are wrong, nobody
notices!
- Displacement Textures
- Solution to mapping texture onto curved surfaces
- Usually procedural
Modelling
Particle Systems
What are they?
- Collections of particles that taken together represent something
- plants like grasses
- hair or fur
- fire
- splashing water
- etc.
- Each particle has
- an initial state
- position
- velocity
- size
- colour and/or luminosity
- etc
- an update function
- changes the state
- can die
- can have random perturbations
- can leave stuff behind
- Dynamics has
- transient properties
- steady-state properties
How to use them for animation.
- Something starts emitting particles at time t0
- At each subsequent time step
- Existing particles are updated
- Dead particles are removed
- New particles are created
- All particles are rendered.
- Until it stops emitting particles at t1.
- Updates continue until they are all dead
How to use them for visualization.
- Example. For visualizing motion in a fluid
- Add particles upstream
- Let them be carried by the fluid
- Until the fluid flows out of the scene.
It's obvious how they are used for animation. They are also useful for
still images. How?
Two ways
- Let the particle system get into a steady state, then freeze and put
into the scene.
- Accumulate the path of each particle, then use it as the shape of a
linear primitive
Requires either garbage collection or good memory management.
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?
- Start with a polygon covering the terrain
- height at each vertex is average height + h(n) with n = 1
- h(n) is a random function with expectation zero
- Divide each edge in two by positioning a new vertex in its middle.
- new vertex height is average edge height + h(n = n+1)
- The h(n) function can vary drastically from level to level.
- The h(n) function can have other arguments.
- You will need to tune the h(n) function
- magnitude of h(n) probably decreases with n
- Add new edges.
- Iterate to 2 until it's good enough.
Tricks.
- Gets expensive fast. Do as few iterations as possible.
- Don't look directly down on it. Why?
- h(n) will need extensive tweaking. Don't get discouraged if you don't
get the results you want right away.
- You could do the first few iterations by hand to control the
large-scale result.
What is it good for?
- Mountains
- Rolling hills
- Sand dunes. You will want h(n) to depend on the direction of the
edge.
- etc.
Compound Modelling
Use several techniques together. For example,
- Model a terrain.
- Cover it with grass using a particle system.
- Render it.
- Use the rendering as a texture for a distant landscape.
Polyhedra and Meshes
What is a polyhedron?
- A set of vertices
- Connected by edges
- Which define faces
Ray Tracer format
- Array of edges (3 floats)
- Array of faces (pointers to vertices, needs to know number of
vertices)
- Build the arrays as you read the input.
Disadvantages
- Finding the faces that surround a vertex, or the edges that emanate
from a vertex
- Modifying the mesh.
- Add a vertex and a face, easy.
- Add a vertex, split a face, need to find the face.
- What's hard is finding the face to delete. ( O(nFaces) )
An improved solution
- Build a list of faces for each vertex when reading the input
- 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.
General deletion is still hard, unless you are willing to tolerate holes
in the array.
Winged Edge Data Structure
When we talk about polyhedra & meshes it seems most natural to talk
about vertices
- edges are vertex pairs,
- faces are vertex n-tuples n>2.
And we have been most interested in vertices and faces. Meshes are, of
course, graphs
- not just any graphs but ones that obey constraints
- for every constraint there is an invariant
- complete sets of invariants are not known: not for lack of trying to
find them
Every time we see a graph we should think,
In the dual edges are primary:
- vertices are where edges meet,
- faces are minimal closed paths
Winged edge data structure
- Where does the name come from?
Each edge has
- pointers to the faces it separates
- pointers to the vertices at its ends
- participates in a doubly linked list of edges at each of its ends
Each vertx has
- one pointer to an edge
- Exercise. Why do you only need one?
Each face has
- one pointer to an edge
- Exercise. Why do you only need one?
Issues to consider
- Traversal. Can you find all neighbours quickly?
- Vertex/edge addition. Can you do it in constant time?
- Vertex/edge deletion. Can you do it in constant time?
Return to: