11
Procedur Procedur a a l l Modeling Modeling Peter Borovský Peter Borovský borovsk [email protected] www.sccg.sk/~borovsky www.sccg.sk/~borovsky

Procedural Modeling Peter Borovský [email protected] [email protected]

Embed Size (px)

Citation preview

Page 1: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

ProcedurProceduraal l ModelingModeling

Peter BorovskýPeter Borovský

[email protected]

www.sccg.sk/~borovskywww.sccg.sk/~borovsky

Page 2: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

ModeliModeling ng a and Simulation Theorynd Simulation Theory

• Continuous Continuous Discrete systems Discrete systems• Deterministic Deterministic Stochastic systems Stochastic systems

• Real SystemReal System system analysissystem analysis

• Abstract ModelAbstract Model model implementationmodel implementation

• Computer ModelComputer Model

• Description language:Description language:verbal / schematic / math / flowchart / …verbal / schematic / math / flowchart / …

Page 3: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Procedural ModelingProcedural Modeling

• Algorithmic creation of models for CGAlgorithmic creation of models for CG

• ParametrizationParametrization

• Labor savingLabor saving

• ComplexityComplexity

• Memory and Time issuesMemory and Time issues

• SimulationSimulation

Page 4: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

ExamplesExamples

Page 5: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Procedural Scene ExampleProcedural Scene Example

Page 6: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Course OverviewCourse Overview• Pseudorandom GeneratorsPseudorandom Generators• Procedural Geometry ModelingProcedural Geometry Modeling• Noises & TurbulencesNoises & Turbulences• FractalsFractals• Terrain / City ModelingTerrain / City Modeling• Reaction–DiffusionReaction–Diffusion• Cellular AutomataCellular Automata• Procedural TexturesProcedural Textures• Procedural ShadingProcedural Shading• Particle SystemsParticle Systems• Physically-Based ModelingPhysically-Based Modeling• Genetic & Evolutionary AlgorithmsGenetic & Evolutionary Algorithms• Behavioral ModelsBehavioral Models

Page 7: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Random NumbersRandom Numbers

• Base of the stochastic algorithmsBase of the stochastic algorithms• Random sequences, not numbers aloneRandom sequences, not numbers alone• Computers are deterministic Computers are deterministic

pseudorandom sequencespseudorandom sequences

• Algorithm control:Algorithm control:• Seed = 1Seed = 1stst number from the sequence number from the sequence• Random function generates next numberRandom function generates next number• Usually random function output Usually random function output 0,10,1 with with

normal distributionnormal distribution

Page 8: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Random Generators HistoryRandom Generators History

• Prehistoric: throwing a cube, coin, …Prehistoric: throwing a cube, coin, …• L. H. C. Tippet (1927):L. H. C. Tippet (1927):

table with 40 000 random numbers from census formstable with 40 000 random numbers from census forms

• RAND Corporation (1955):RAND Corporation (1955):table with 1 000 000 random numberstable with 1 000 000 random numbers

• Physical random number generators:Physical random number generators:– British lottery engine ERNIE British lottery engine ERNIE

• 50-ties: fixed random tables in the computer 50-ties: fixed random tables in the computer memorymemory

Page 9: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

First Random AlgorithmFirst Random Algorithm

• Square Middle – J. von Neumann 1946Square Middle – J. von Neumann 1946• Select digits from the 2Select digits from the 2ndnd power of the power of the

numbernumber• 10 digit numbers example:10 digit numbers example:

– seed = 5 772 156 649seed = 5 772 156 649– square = 33 317 792 380 594 909 201square = 33 317 792 380 594 909 201– selection = 7 923 805 949selection = 7 923 805 949

• Disadvantage: cyclingDisadvantage: cycling– 0 never disappears0 never disappears

Page 10: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Linear CongruenceLinear Congruence

• D.H. Lerner 1948D.H. Lerner 1948• sequencesequence X Xnn+1+1 = ( = (aa XXnn + + cc) mod ) mod mm• requirements for long period:requirements for long period:

– Starting value Starting value XX00 0 0– Coeficient Coeficient a a 0 0 ::

• aa > > mm ( (aa > > mm/100 /100 aa < < mm--mm),),• various digits, e.g. various digits, e.g. aa = 3 141 592 653 = 3 141 592 653

– Increment Increment cc 0 must be an odd number 0 must be an odd number– Modulo Modulo mm XX00 , , mm > > cc, as largest as possible, as largest as possible

Page 11: Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Linear Congruence in PracticeLinear Congruence in Practice

• D. MacLaren, G. Marsagliu 1965D. MacLaren, G. Marsagliu 1965

• 2 congruent generators {X2 congruent generators {Xnn}, {Y}, {Ynn}}

• Array V[0],V[1], …, V[Array V[0],V[1], …, V[kk-1], -1], kk ~ 100 ~ 100

• Algorithm:Algorithm:1.1. Generate next X, Y values from {XGenerate next X, Y values from {Xnn}, {Y}, {Ynn}}

2.2. Index Index jj = = kkY/Y/m, m m, m = modulo from {Y= modulo from {Ynn}}

3.3. Output = V[Output = V[jj], swap V[], swap V[jj] with X, goto 1.] with X, goto 1.

• Seed = date / time / computer stateSeed = date / time / computer state