Procedural Modeling Peter Borovský borovsky@sccg.sk borovsky@sccg.skborovsky

Preview:

Citation preview

ProcedurProceduraal l ModelingModeling

Peter BorovskýPeter Borovský

borovsky@sccg.sk

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

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 / …

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

ExamplesExamples

Procedural Scene ExampleProcedural Scene Example

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

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

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

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

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

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

Recommended