Title: Advanced Computer Graphics: Procedural Modelling
1Advanced Computer GraphicsProcedural Modelling
- Carl Hultquist
- Department of Computer ScienceUniversity of Cape
Town - chultqui_at_cs.uct.ac.za
2Objectives
- To introduce the field of procedural modelling
and what it means for a model to be procedurally
generated - To examine what techniques have been researched
thus far, including the following - Fractals
- Perlin noise
- Procedural texturing
- Cellular texturing
- Solid texturing
- L-Systems
- Subdivision surfaces
- Urban modelling
- Special effects
3Motivation
- Modelling every single object by hand is tedious!
- An easier alternative is to use a few parameters
to describe the object and allow the computer
to generate the object for the artist (computers
are built for doing tedious things) - If necessary, the artist can make small
modifications afterwards to get the perfect
object - Additionally, procedural methods are extremely
compact (no need to store explicit geometry or
texture information, only parameters to create
these) and can in some cases better represent
objects than explicit representations
4Fractals the Koch Curve
Images by Jim Loy (http//www.jimloy.com/fractals/
koch.htm)
5Fractals why theyre important
- Biggest reason is self-similarity. As seen with
the Koch Curve, fractals can contain entire
copies of themselves. More generally, fractals
are defined to have infinite resolution so no
matter how closely you zoom in to the fractal,
there will always be an immense amount of detail.
In this sense, you could also think of fractals
as having various levels of detail. - This has implications for modelling by simply
storing the parameters that characterise a
fractal, we can iterate and zoom in as much as we
need to get a suitable level-of-detail for
rendering.
63D Fractals Mountains
- Probably the most common use of fractals for
procedural modelling of 3D objects - Consider the 2D case of a slice through a
mountain - As can be seen, we progressively split up the
interval over which the mountain is defined, and
add random detail.
73D Fractals Mountains (2)
- So with 3D, we instead start with a sub-section
of the plane (usually a triangle, square or
hexagon), and progressively split up that
sub-section into smaller parts
8An alternative for creating fractalmountains
- Notice that at any stage, the mountain is simply
described by a regular grid of values, each of
which is the height at the given point. - Also notice that the mountains are smooth in the
sense that there are no irregular discontinuities
in their surface. - These properties allow us to describe fractal
mountains using a different procedural technique
Perlin Noise
9Perlin Noise
- Invented by Ken Perlin.
- Key idea is to take a set of noisy functions at
different scales, and blend them together.
10Perlin Noise Creating a NoiseFunction
- So how do we create a noisy function?
- The trick is to take a set of random values and
interpolate between them. Consider the 2D case
below - By interpolating these random values, we obtain a
smooth noise function
11Perlin Noise Scaling
- Suppose then we have a 2D noise function
noise(x,y), which returns the noise value at the
point (x,y). - We can scale the noise by defining a new noise
function like this - scaled_noise(x,y,freq) noise(x / freq, y /
freq) - Higher values of freq will then give much closer
views of the noise, thus scaling it.
12Perlin Noise Applications
- Fractal mountains
- Water displacement map (giving the appearance of
waves) - Simple clouds
- Procedural texturing
- Marble textures
- Wood textures
- Cellular texturing extend noise function to 2D.
Useful for most texturing applications. - Volumetric or solid texturing extend noise
function to 3D. Allows you to slice a geometric
object arbitrarily and still texture it
realistically.
13Lindenmayer-Systems
- Invented by Aristid Lindenmayer
- More commonly referred to as L-Systems
- In essence, L-Systems are a parallel string
rewriting mechanism, defined by an initial string
and a set of productions (or rules) to
iteratively rewrite the string. - A simple example
- ? A
- ?0 A ? xB
- ?1 B ? yA
14L-Systems basic form
- As has been shown, an L-System consists of an
initial string (typically called ?) and a set of
productions (usually called ?x for increasing
integers x) - Formally, the initial string in a simple L-System
is simply a sequence of symbols, and each
production has the following format - ?x pattern ? replacement
- where pattern is a single symbol, and replacement
is a sequence of symbols. For each iteration of
the L-System, every occurrence of pattern in the
string is replaced by replacement, and this is
done in parallel over the whole string.
15L-Systems Parallel Rewriting(1)
- Consider this L-System
- ? AB
- ?0 A ? xB
- ?1 B ? yA
- Parallel rewriting means that during the first
iteration, we simultaneously change the A to xB
and the B to yA, resulting in the string xByA. A
second iteration would then yield xyAyxB.
16L-Systems Parallel Rewriting(2)
- Theres one more catch though What happens if
more than one production could be applied to a
single symbol in the string? - ? A
- ?0 A ? xB
- ?1 B ? yA
- ?2 A ? zB
- It may seem silly for now (why would someone
write a system like this?) but its important to
deal with for simple cases like this L-System.
The answer is that the first matching production
is used, so in this case the first iteration
would result in the string xB, and not zB.
17L-Systems and Context (1)
- In the previous example, we had an L-System which
has two rules for rewriting a symbol. This may be
very necessary sometimes we might want to use
one production, but at other times we would want
to use the other production. How can we
distinguish between these? - The answer is to add a notion of context to the
L-System. This lets us examine the symbols before
and after the one were currently rewriting, and
base our rewriting decision on these symbols. - Each production in a context-sensitive L-System
has the following form - ?x left-context lt pattern gt right-context ?
replacement - and either or both of the left-context lt and
gt right-context parts may be omitted.
18L-Systems and Context (2)
- ? xA
- ?0 A gt y ? Bx
- ?1 B ? A
- ?2 x lt A ? By
- Here are the strings that emerge from iterations
of this L-System - xA
- xBy
- xAy
- xBxy
- xAxy
- xByxy
-
19L-Systems how is the resultingstring used?
- So you end up with some string of symbols then
what? - The usual course of action is to interpret the
string as a set of drawing commands, in a similar
fashion to Logo. For this reason, this is often
referred to as turtle interpretation. - Some common symbols used for 2D drawing are
- F - Move forward length d while drawing
- f - Move forward length d without drawing
- - Turn left by angle d
- - - Turn right by angle d
20L-Systems Turtle Interpretation(1)
- ? F-F-F-F
- ?0 F ? FF-F-F-F-F-FF
- d 90, 4 iterations
21L-Systems Turtle Interpretation(2)
- ? RF
- ?0 L ? RFLFR
- ?1 R ? LF-RF-L
- d 60, 6 iterations
22L-Systems more extensions!
- In previous examples, all turning and movement
commands used the same angle and the same
distance (respectively). - Would be nice to be able to adjust these values
the result is a parametric L-System. Each symbol
can have an associated bracketed list of values,
like this - ? A(2)
- ?0 A ? B(2.4, 3) x
- ?1 B ? y A(1.2, 2.2, 4)
23Parametric L-Systems
- You can then formulate more complex productions,
like this example - ? x F
- ?0 x lt F ? y F (30) x F
- ?1 (x) ? (x - 2)
- ?2 y lt F ? F F
24L-Systems Conditions andBranching
- In addition to allowing symbols to bear
parameters, parametric L-Systems also allow for
conditions to be placed on productions. - ?1 (x) x gt 20 ? (x - 2)
- For example, the above production will only occur
if the parameter x has value greater than 20. - Branching is another useful technique used by
most turtle interpretation systems the symbol
is used to push the turtles state onto a stack,
and the symbol is used to pop the turtles
state off the stack.
25L-Systems what about 3D?
- 2D turtle examples are all well and good, but
lots of computer graphics applications require
3D! How do L-Systems help here? - Extend the turtle interpretations to include
rotation about three axes (the up, left and
heading axes). This allows us to rotate in 3D
space.
26L-Systems Applications
- Parametric, context-sensitive L-Systems with
branching are most typically used for modelling
plants and flowers. Some more recent applications
have been to model road networks.
27Subdivision Surfaces (1)
- Some objects are incredibly geometrically
complex, and may require extraordinary amounts of
storage space. Such a problem is exacerbated when
the geometry needs to be transferred to another
user, since the transfer of all this data may not
be practical. - Subdivision surfaces allow for some geometrically
complex objects to be represented using a much
simpler control mesh. The actual object can then
be reconstructed through the process of
subdivision, whereby the vertices in the control
mesh are used to generate new vertices. - (See, for example, Subdivision Surfaces in
Character Animation, by Tony DeRose, Michael Kass
and Tien Truong).
28Subdivision surfaces (2)
- Positives
- Only a simple mesh is stored
- Can subdivide to any arbitrary level of detail
quick and easy way of allow support for multiple
LODs without the need of a decimation algorithm
(see Hugues Hoppes paper on Progressive Meshes
for an example of such a decimation scheme) - Negatives
- Not all complex objects can be represented like
this - Can be difficult to work out what control mesh
will result in the final object were trying to
model
29Procedural Modelling of Cities (1)
- Paper by Yoav Parish and Pascal Müller for
SIGGRAPH 2001. - Describes a composite procedural modelling system
for generating an entire city. Makes use of the
following techniques - L-Systems a variant of L-Systems is used that
allows for what are called query modules, which
are used to query the environment and receive
feedback from the environment before a production
is executed. These create the road network for
the city. - Subdivision regions of land bounded by roads are
subdivided into allotments, each of which will
potentially contain a building.
30Procedural Modelling of Cities (2)
- L-Systems a variant known as parametric,
stochastic L-Systems are used to generate
buildings. The basic idea is that symbols in the
L-System are interpreted as a type of sculpting
command, eroding away from a solid block and
resulting in a shape resembling a building. - Procedural texturing a technique which the
authors call layered grids is used to generate a
2D texture for use on the buildings. The idea is
to use multiple semi-random layers and have these
layers interact in a number of semi-random ways
to generate the final building façade.
31Procedural Modelling of Cities (3)
32Special effects
- Many SFX can be considered procedural in the
sense that there is some computational procedure
which creates the effect, as opposed to the
effect either being captured from raw footage or
painstakingly created by an artist. - Examples of such effects include
- Morphing and warping
- Physics engines
- Animation of characters
- Smooth camera movement
- A good example of software that is widely used to
accomplish such effects is Houdini by Side
Effects Software (http//www.sidefx.com).
33Uses of Procedural Modelling
- Games most recent and most notable is kkrieger,
which is an FPS in 96 Kb! (complete with sound
effects, music, and good graphics) - Movies Primarily used for SFX, but can also be
used for generating large virtual environments
(VEs). Good examples include The Matrix trilogy,
Final Fantasy, anything by Pixar, The Day After
Tomorrow, The Lord of the Rings the list goes
on! - General VE design for designing large and
complex VEs, procedural modelling can save time
by doing lots of the work for you. The trick is
in developing a good interface to harness its
full power (see http//people.cs.uct.ac.za/chult
qui/masters!)
34Example kkrieger