procedural modeling slides for ddm by marc van kreveld 1

72
Procedural Modeling Slides for DDM by Marc van Kreveld 1

Upload: estefani-heady

Post on 01-Apr-2015

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural Modeling

Slides for DDMby Marc van Kreveld

1

Page 2: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

• Creating 3D models from a set of rules– L-systems– Fractals– Generative modeling

• Procedural modeling gives procedural content• Procedural modeling uses– many parameters that can be set– often randomness

2

Page 3: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

• Cheaper and faster than manual construction, especially when many similar models are needed

• Possible to generate– the geometry– the texture– the placement of the model in a scene– whole scenes

(e.g. urban: street pattern, buildings, trees, …)

3

Page 4: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

4

Page 5: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

5

Page 6: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

6

Page 7: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

7

Page 8: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

8

Page 9: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

9

Page 10: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

10

Page 11: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

11

Page 12: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

12

Page 13: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

13

Page 14: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

14

Page 15: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural modeling

15

Page 16: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

• Oldest, best known, for height maps: midpoint displacement algorithm

• New vertices get an elevation that is the interpolation of its neighbors, +/- some random term

16

Page 17: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

• The random term decreases in every iteration, other-wise the terrain gets more and more steep/rugged

• Ruggedness can beglobally controlled by the standard deviation of the random term

17

Page 18: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

• Looks good, but is not natural:– symmetric with respect to high and low, but real terrains

are not– real terrains are formed by erosion from wind, rain, water

flow, …– ridges and valleys are not realistic

• Possible solutions:– apply wind and rain erosion models to the generated

terrain– compute where rivulets/rivers would form based on local

gradient and apply river erosion models

18

Page 19: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

• Overhangs and cliffs are not supported• No global user control

19

Page 20: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

• A similar approach can be used for coastlines, but there are different coastline types

• Constraints are needed to ensure that the coastline does not self-intersect

20

Page 21: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

• For rivers, one must be aware that rivers and terrain height cannot be generated independently– generate a height map and determine where the rivers are– generate a river network and compute a consistent height

map– with little height influence, meandering must be modeled

• River deltas, waterfalls, cascades, …

21

Page 22: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

• For urban environments:– start with generating a dense road network– partition the resulting blocks into lots– (a) use the lots are building footprints and raise them

to random heights (skyscrapers, office buildings), or(b) place a building footprint of a house on the lot and generate the house by some scheme• extrusion plus roof generation• L-system or other grammar

22

Page 23: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

23

Page 24: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

24

Page 25: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

25

Page 26: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Procedural terrain modeling

26

Page 27: Procedural Modeling Slides for DDM by Marc van Kreveld 1

27

Page 28: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems

• Named after Aristid Lindenmayer• Parallel grammar: every non-terminal symbol is

rewritten simultaneously to get the next object• Models the growth of plants• Typically self-similar at different scales (like fractals)

28

Page 29: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, definition

• Grammar G = (V, , P) where– V is a set of symbols (terminals or non-terminals)– is a symbol or sequence of symbols that is the start– P is a set of production rules (rewriting rules)

Symbols that do not occur on the left-hand side of a production rule are terminals (constants)

29

Page 30: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 1

• Algae:– Variables: A B– Start: A– Rules: A AB , B A

• Start: A• 1st generation: AB• 2nd generation: ABA• 3rd generation: ABAAB• 4th Generation: ABAABABA• 5th Generation: ABAABABAABAAB

30

Intuition: - A is mature and spawns a young (B), but also stays- It takes young B one generation to mature (become A)

Page 31: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 1

A

B

A

AA

A AA

AA AA

B

B

BB

B

BA

tree L-system

31

Page 32: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 2

• Non-deterministic version of algae:– Variables: A B C– Start: A– Rules: A AB , B A , B C , C A

• Start: A• 1st generation: AB• 2nd generation: ABA or ABC• 3rd generation: ABAAB or ABCAB or ABAA or

ABCA• 4th Generation: …

32

Intuition: - It takes B one or two generations to mature

Page 33: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, bracket notation

• A tree can be written using brackets [ and ] that enclose branches

33

DC

FE

B

A

HI

Gbranch

branchsubbranch

AB[CD[F]E]G[I]H

Page 34: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 3

• Simple tree:– Variable: S– Start: S– Rule: S S[S]S[S]S

• Start: S• 1st generation: S[S]S[S]S• 2nd generation:

S[S]S[S]S[S[S]S[S]S]S[S]S[S]S[S[S]S[S]S]S[S]S[S]S

34

Page 35: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 3

• We can interpret the generated strings as drawing instructions like in Turtle Graphics:– S : draw line segment– [ : rotate by 45 degrees– ] : rotate by -45 degrees and use the

state from before the matching [

• S[S]S[S]S

35

Page 36: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 3

• S[S]S[S]S[S[S]S[S]S]S[S]S[S]S[S[S]S[S]S]S[S]S[S]S

36

Page 37: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 4

• Another tree:– Variables: A, S– Start: A– Rules: A S[A]S[A]A , S SS

• Start: A• 1st generation: S[A]S[A]A• 2nd generation:

SS[S[A]S[A]A]SS[S[A]S[A]A]S[A]S[A]A

37

Page 38: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 4

• Example of subapical growth mechanism:– new branches are created at apices (A) only– stems (S) only become longer

38

Page 39: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, control mechanisms

• Lineage: transfer of genetic information from an ancestor cell to its descendant cells

• Interactive: information (or nutrients) is exchanged between neighboring cells

• Lineage corresponds to context-free L-systems• Interaction corresponds to context-sensitive

L-systems

39

Page 40: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, context-sensitivity

• Context-sensitive L-systems have production rules with not just a single variable on the left side

• A<B>CD … is a production rule to rewrite B if it is preceded by A and succeeded by CD

• If a context-sensitive production rule can be applied and also a context-free rule, the context-sensitive one takes precedence

40

Page 41: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, context-sensitivity

• With brackets it gets complicated:a production rule BC<S>G[H]M … can be applied to the string ABC[DE][SG[HI[JK]L]MNO] because bracketed parts to the right may be skipped/ignored

ABC[DE][SG[HI[JK]L]MNO]

A

S

B C D EI

GH

K

J

LM N O 41

Page 42: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 5

• Context-sensitive L-system:– Start: J [ I ] I [ I ] I [ I ] I– Rule: J < I J

• Models a signal from the root upwards to the apices

J

I

I

I

I

I

I

J

I

J

I

I

J

I

J

J

J

J

I

J

I

J

J

J

J

J

J

J

42

Page 43: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 5

• Context-sensitive L-system:– Start: I [ I ] I [ I ] I [ I ] J– Rule: I > J J

• Models a signal from an apex downwards to the root

I

I

I

I

J

I

I

I

J

I

I

J

I

I

I

J

J

I

J

I

I

J

J

J

I

J

I

I

43

Page 44: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, signals

• Example where the root structure and branch structure develop simultaneously (top)

• Same L-system but starting with a severed branch

44

Page 45: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, geometry

• Branching as given by production rules is topological; no coordinates are involved yet

• We add symbols in the production rules that steer the process, they are ignored when applying rules

• The symbol “[” pushes a situation onto a stack, the symbol “]” recovers it (meaning: the branch has been drawn; continue with the stem)

45

Page 46: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, examples 3a and 3b

• Example: + rotates by +45 degrees, - by -45 degrees, variable S moves forward a fixed distance and draws

• Recall the rule S S[S]S[S]S

S S[+S]S[+S]S S S[-S]S[+S]S

46

Page 47: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, example 6

• Grassy plant:– Variables: X F– Start: X – Rules:

X F-[[X]+X]+F[+FX]-X , F FF

• + uses an angle of 25°; - uses an angle of -25°;F draws; X does not

47

6th generation

Page 48: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, 3D models

48

• The drawing state in 3D requires a position and a yaw, pitch and roll

• In 2D we had 2 rotation symbols, in 3D we need 6

• The symbol “[” pushes a state with position, yaw, pitch and roll onto a stack, the symbol “]” recovers it

Page 49: Procedural Modeling Slides for DDM by Marc van Kreveld 1

L-systems, appearance

• More symbols can be used to control color, and increase/decrease edge length and edge thickness

49

color

length

thickness

Page 50: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Extensions to L-systems

• Stochastic L-systems: – A rule is applied with a certain probability in every

generation– When multiple rules can be used for the same symbol, we

can assign relative probabilities describing which one to apply (cp. non-deterministic L-systems)

• Example:– Variable: A– Start: A– Rules: A(0.6) A[+A][-A]A , A(0.4) AA

50full sparse

Page 51: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Extensions to L-systems

• Differential L-systems (Prusinkiewicz, Hammel, Mjolsness 1993): – Rules as in L-systems combined with differential equations– Separates discrete changes (new branch) from continuous

changes (lengthening, thickening, bending)– Allows continuous growth, instead of discrete– Allows easier animations

51

Page 52: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Books

52

Page 53: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis

• Procedural modeling algorithm by Merrell and Manocha (2011)

• Useful for man-made structures• User-assisted generation• Starts with a simple model, user-defined input• Generates similar models with larger complexity• Uses neighborhoods and constraints

53

Page 54: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

• A model is a set of closed polyhedra• The input model is denoted by E, the generated

model by M• Vertices in E have a neighborhood; all vertices in M

should have a neighborhood that is the same as some vertex in E

Neighborhood of a vertex: adjacency of edges and facets around the vertex, directions of those edges and facets, and side of the polyhedron w.r.t. the vertex

• Also points on edges and facets have neighborhoods54

Page 55: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

55

input model E generated model M

Page 56: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

• The neighborhood of a vertex defines its state• Given an example model E:– Determine all different occurring states in E– Generate sets of parallel planes (planes supporting facets

from E), these form a 3D grid G– Loop: pick a vertex of G and assign it a possible state

(using states that occur in E and the previously assigned states of adjacent vertices in G)

– Until all vertices with an assigned state form a proper model in G

56

Page 57: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

57

parallel lines (planes)

Page 58: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

58

At a yellow vertex, we can have 16 different states in principle,2 of which do not give a vertex (all 4 incident cells inside/outside)

4 states occur in model E (like a’, b’, c’, ..) as vertices, 2 of them as edges (like e’, ..)

The remaining 8 states are not allowed at vertices in M

Page 59: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

59

• States described by half-planes: h1 = below green facet; h2 = behind blue facet; h3 = right of red facet

Page 60: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

60

• States described by half-planes: h1 = below green facet; h2 = behind blue facet; h3 = right of red facet

next vertex along this edge must have state that includes h1 h2

next vertex along this edge must have state that includes h1 h3

next vertex along this edge must have state that includes h2 h3

Page 61: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

• The algorithm again:– Determine all different occurring states in E– Generate sets of parallel planes (planes supporting facets

from E), these form a 3D grid G– Loop: pick a vertex of G and assign it a possible state

(using states that occur in E and the previously assigned states of adjacent vertices in G)

– Until all vertices with an assigned state form a proper model in G

a model growing approach with backtracking when the algorithm finds a vertex where no state is possible

61

Page 62: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

• Constraints are needed to capture the user’s intent• Constraints limit what the algorithm can generate

62

Page 63: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

• Dimensional constraints: limits on the lengths of features (width of roads, height of chairs, …)– all lengths will be multiples of the chosen plane spacing

• Algebraic constraints: limits on ratios of lengths

• Connectivity constraints: roads must all connect into a network; rooms in a house must all be connected– number of seeds influences number of components

• Large-scale constraints: more global constraints like the arrangement of buildings in a city

63

Page 64: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: approach

• Large-scale constraints– make locations in the space to be occupied– the state of a location is the object that is there– states are assigned with equal probabilities, but this can

also be influenced by the user

64

Page 65: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: output

65

Page 66: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: output

66

Page 67: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: output

67

Page 68: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: output

Page 69: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: efficiency

• Number of planes depends on number of plane normals in input and on plane spacing vs. extent

• Backtracking is limited, and local in practice• m normals and n planes per normal gives

proportional to m3 n3 vertices in the grid• Models shown have 60–400 polygons user-made

(in E) and 1000–8000 polygons generated (in M)• Computation time a few seconds to a few minutes

69

Page 70: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Model synthesis: limitations

• Needs a grid structure for the model• Not good for organic models (plants, trees)• Less good for curved models, but possible• Less good for a combination of small (detailed) and

large objects• Semi-automatic

70

Page 71: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Summary

• Procedural generation allows models to be generated rather than built manually by artists or reconstructed from scans

• There are considerable time and cost savings• L-systems work well for organic shapes, but they also

work for buildings, road networks, …• Model synthesis is a model growing technique that

can be used for semi-automatic generation of man-made structures

71

Page 72: Procedural Modeling Slides for DDM by Marc van Kreveld 1

Summary

• There is more to be said on placement of a model• Clouds, fire, movement like leaves blowing in the

wind, etc., has also been studied• Procedural generation of textures exists• There are various books on the topic• There are several software packages for procedural

generation• Convenient user control remains an issue; there is a

lot of trial-and-error in the generation

72