770 likes | 1.2k Views
Procedural Modeling. Slides for DDM by Marc van Kreveld. 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.
E N D
Procedural Modeling Slides for DDM by Marc van Kreveld
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
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, …)
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
Procedural terrain modeling • The random term decreases in every iteration, other-wise the terrain gets more and more steep/rugged • Ruggedness can beglobally controlled bythe standard deviationof the random term
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
Procedural terrain modeling • Overhangs and cliffs are not supported • No global user control
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
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, …
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
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)
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) L-systems, definition
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 L-systems, example 1 Intuition: - A is mature and spawns a young (B), but also stays- It takes young B one generation to mature (become A)
L-systems, example 1 A A B A B A A B A A B A B A A B A B A tree L-system
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: … L-systems, example 2 Intuition: - It takes B one or two generations to mature
A tree can be written using brackets [ and ] that enclose branches L-systems, bracket notation subbranch branch H F branch I E G D AB[CD[F]E]G[I]H C B A
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
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
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
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
L-systems, example 4 • Example of subapical growth mechanism: • new branches are created at apices (A) only • stems (S) only become longer
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
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
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] E J D B A C I H S K L G M N O
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 I I I J I I I J I I J J I I J J I J J J I J J J J J J J
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 J J J J I I I I I J J J I I I I I I J J I I I I I I I J
L-systems, signals • Example where the root structure and branch structure develop simultaneously (top) • Same L-system but starting with a severed branch
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)
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
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 6th generation
L-systems, 3D models • 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
L-systems, appearance • More symbols can be used to control color, and increase/decrease edge length and edge thickness color length thickness
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 full sparse