+ All Categories
Home > Documents > 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals...

590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals...

Date post: 09-May-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
20
© Bedrich Benes CS 590 – CGS Procedural Methods Fractals Bedrich Benes, Ph.D. Purdue University Department of Computer Science 1 © Bedrich Benes The Mandelbrot Set – the big logo The Mandelbrot set Discovered in 1970 by Benoit Mandelbrot It is a nonlinear deterministic fractal It is graph of a solution of a dynamic system Benoit Mandelbrot 2 © Bedrich Benes The Mandelbrot Set Take the equation ାଵ where: and are complex numbers and Explore complex numbers from the complex plane Measure the speed of divergence of the i.e., measure when (predefined value) 3 © Bedrich Benes The Mandelbrot Set there are two kinds of points: for , (stable points) for certain and greater (unstable points) 4
Transcript
Page 1: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

CS 590 – CGSProcedural MethodsFractalsBedrich Benes, Ph.D.Purdue UniversityDepartment of Computer Science

1© Bedrich Benes

The Mandelbrot Set – the big logoThe Mandelbrot set• Discovered in 1970 by  Benoit Mandelbrot

• It is a non‐linear deterministic fractal

• It is graph of a solution of a dynamic systemBenoit Mandelbrot

2

© Bedrich Benes

The Mandelbrot SetTake the equation

where: 𝑖 and  are complex numbers and 

Explore  complex numbers from the complex plane Measure the speed of divergence of the  𝑛i.e., measure when  𝑛 (predefined value)

3© Bedrich Benes

The Mandelbrot Set

there are two kinds of points:𝑛 for  ,  (stable points)𝑛 for certain  and  greater    (unstable points)

4

Page 2: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

The Mandelbrot Seta) stable points  displayed in blackb) unstable points

for every point c in the plane <-2-2i>, <2+2i> doset z=0+i0set n=0while (n<MAX) and (|z|<2) do

z=z2+cend of whileif (n==MAX) Draw Point(Black)

else Draw Point(Color(n))end of for

5© Bedrich Benes

The Mandelbrot SetZooming into the Mandelbrot set

6

© Bedrich Benes

The Mandelbrot SetZooming into the Mandelbrot set

7© Bedrich Benes

The Mandelbrot SetZooming into the Mandelbrot set

8

Page 3: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

The Mandelbrot SetZooming into the Mandelbrot set

9© Bedrich Benes

The Mandelbrot SetZooming into the Mandelbrot set

10

© Bedrich Benes

The Mandelbrot Set

http://www.youtube.com/watch?v=0jGaio87u3A11

© Bedrich Benes

DimensionsDimension ‐ how long is the coast of Corsica?A stick of 500m will give 700km (not very precise)A stick of 100m will give 1200km (?)

What if we use length equal to  ?The length will be…

12

Page 4: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

DimensionsHow long is the coast of Corsica?applied  sticks of length  timesthe total length is stick of the length  and we need  piecesif  we need 

13© Bedrich Benes

Dimensions

In the case of Corsica we need to use formula𝐷to get reasonable results…

What is this “D”? (Richardson)

14

© Bedrich Benes

DimensionsHow long is the coast of Corsica?

Having  we get   𝐷

with  (i.e., getting the stick shorter) we get 

→15

© Bedrich Benes

Dimensions

For a line segment we need to set it the case of Corsica  needs to be non‐integer…

The D is so called Hausdorff dimensionSometimes called fractal dimensionFractals (usually) do not have dimensions 

16

Page 5: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

FractalsFractalsfractal is a set that is self‐similar,

it is a set that is copy of itselfhere 𝑖 is transformation scales downScale  must be average contraction 

Fractal is a set that has  Hausdorff’s dimension greater than its dimension topological

17© Bedrich Benes

FractalsVaguely

Fractal is a set that is geometrically complex and its structure is given by repetition of a certain shape at different scales.

18

© Bedrich Benes

Fractals Classification

Linear Deterministic

Non-linear Non-deterministic

Fractals

19© Bedrich Benes

Fractals Classification• Deterministic (or exact) fractals• Non‐deterministic or random fractalsDepends on the type of self‐similarity (exact, random)

• Linear – rotation, scale, translation, shear• Non‐linear – the othersDepends on the used transformations

20

Page 6: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

DimensionsSpecial casesIf we use just ONE transformation with fixed  and  repetitionsthe fractal dimension is

21© Bedrich Benes

Linear Deterministic FractalsThe Cantor’s discontinuum(published in 1883)

(Georg Cantor - 1845 - 1918)

1) Take a line segment2) Sale it 1/3x3) Make two copies at the ends4) Do it recursively

22

© Bedrich Benes

Linear Deterministic FractalsWhat is the dimension of the Cantor’s discontinuum? scale 

new piecesfor this we can use formula

this object is something between a point and a line

23© Bedrich Benes

Linear Deterministic FractalsThe Koch’s snowflake

Scale  ,  , Properties: does not have derivativeinfinite lengthzero areathe area inside is non‐zero and non‐infinity

(Helge von Koch 1870 –1924)

1) Take a line segment2) Erase the mid third (similar to Cantor)3) Create equilateral triangle4) Repeat this recursively

24

Page 7: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Linear Deterministic FractalsThe Sierpinsky gasket 

not plane, not lineNote the similarity with Pascal triangle

1) Take a triangle2) Erase mid triangle3) Repeat this recursively

(Wacław Franciszek Sierpiński 1882-1969)

25© Bedrich Benes

Linear Deterministic FractalsThe Menger sponge

Scale 

Dust of points.

1) Take a cube2) Erase mid cross of cubes3) Repeat this recursively

(Karl Menger 1902 - 1985)

26

© Bedrich Benes

Linear Deterministic FractalsThe Peano curve

space filling curve

1) Take a line segment 2) Substitute it by the lines from the image3) Repeat recursively on each line segment

(Guiseppe Peano 1858-1932)

27© Bedrich Benes

Non‐Linear Deterministic FractalsQuaternionsif we apply the formula

in quaternion space(hypercomplex numbers ‐ 4D) 

28

Page 8: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Non‐Linear Deterministic Fractals

© Daniel White29

© Bedrich Benes

Linear Non‐Deterministic FractalsInvolve random numbers and linear transformationsMotivation:What would you hear if you increase the speed of playing music? Noise?The speed change is scaling

In other words:How large is this stone?10cm?1m?10m?

30

© Bedrich Benes

Linear Non‐Deterministic Fractals

31© Bedrich Benes

Linear Non‐Deterministic FractalsThe way to model random features in natureis capturing the self‐similarity with stochastic processes

The key for these modelsare noise functionsNoise is (usually) self‐similar

32

Page 9: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Brownian MotionBrownian motion (Bm)Particles of pollen in water

They move because of random hits of molecules of water 

This is also special case of the random walk

Bm app

33© Bedrich Benes

Brownian Motion1D Bm simulation:Random hits have Gaussian random number distribution

34

© Bedrich Benes

Brownian MotionHow to get Gaussian Random numbers?

the rand() function generates 

suppose we have  of such numbers  𝑖the Gaussian random number  is:

35© Bedrich Benes

N=1 N=2 N=3 N=4 N=5 N=10

Brownian Motiondetermines how steep the curve is

Gauss app

36

Page 10: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Brownian MotionWhite noise is a random function with a constant power density

Discrete samples are uncorrelated with  and 

Gaussian white noise is one of them

We will call it 

37© Bedrich Benes

Brownian Motion1D Bm simulation (contd.):

Let’s have  that moves a point in the  directionit has Gaussian random numbers distribution 

38

© Bedrich Benes

Brownian Motionthe Bm (Brownian function)  is

we accumulate the perturbations

W(t)

X(t)The fractal dimension is D=1.5

Bm app

39© Bedrich Benes

Fractional Brownian Motion (fBm)fBmif we scale the Bm in the axis  by coefficient we have to scale in the y axis by  𝐻,where  is so called then the fractal dimension of the curve is

this curve is called Fractional Brownian Motion or fBm

(this is NOT Fractal Brownian Motion)

40

Page 11: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Fractional Brownian Motion (fBm)fBm• fBm has  i.e., it is Bm• fBm has • fBm has higher D means “wilder”

H=0.5 autocorrelation is 0H<0.5 autocorrelation is positiveH>0.5 autocorrelation is negative

41© Bedrich Benes

Fractional Brownian Motion (fBm)

42

© Bedrich Benes

Linear Non‐Deterministic Fractals

• In order to generate nice fractals, we need fBm

• The above described function is good

• But it does not provide adaptive results 

43© Bedrich Benes

The Midpoint Displacement Algorithm• the MDP is the key algorithm for fractals

1) Take a line segment2) Find its midpoint (center)3) Move it randomly in the 𝑦 direction4) Apply this step to all lines recursively

44

Page 12: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

The Midpoint Displacement Algorithm• The random numbers distribution has its  and  .• Scale down the  by two in every iteration.• Divide the Gaussian random numbers by two

45© Bedrich Benes

The Midpoint Displacement Algorithm• If we divide in each step by  𝐻

is the Hurst exponent

• we will get fBm with dimension 

46

© Bedrich Benes

The Midpoint Displacement AlgorithmProperties• easy to implement• it is interpolation of two points, so it is also called

Fractal interpolation

• just division by two and random numbers call• quite realistic

47© Bedrich Benes

The Midpoint Displacement AlgorithmTwo dimensional fBmworks with 2D arraysit is called fBm surfacedimension is 

,

where so the 

48

Page 13: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

The Midpoint Displacement Algorithm2D fBm on quadrilaterals (diamond‐square)having four points P0,P1,P2,P3 1) Evaluate the midpoint2) Evaluate points on the edges3) Evaluate points in the middle4) Ad 2) etc...

49© Bedrich Benes

The Midpoint Displacement Algorithm• 2D fBm on quadrilaterals (diamond‐square)

MDP app

50

© Bedrich Benes

Random FaultsAnother method for generating fBm1. take an object2. divide it into two parts3. increase the elevation of one and decrease the 

other one  (change color, etc.)4. apply this step many times5. in each decrease the intensity of changes 2x6. the limit of this process is fBm

51© Bedrich Benes

Random Faults

Cuda random faults

52

Page 14: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Random FaultsImplementationData: 2D arrayAlgorithm:Do this many times:

1) Generate random line (get two random points)2) For each point in the 2D array

I. Check if it is on the left or right (dot product)II. Increase/decrease the value

53© Bedrich Benes

Random FaultsVariationsUse any 2D object (circle, square)Randomly alter the area inside/outside

54

© Bedrich Benes

Random Faults on a Sphere1) Take sphere and divide it randomly into two hemispheres

2) Assign to each hemisphere different color

3) Apply the step 1 recursively, but decrease the intensity in each step with  𝐻

55© Bedrich Benes

Random Faults on a Sphere

56

Page 15: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Perlin NoiseKen Perlin 1985, 2002Perlin, K. (1985). An image synthesizer. ACM Siggraph Computer Graphics, 19(3), 287‐296.

Perlin, K. (2002). Improving noise. ACM Trans. Graph. 21, 3 (July 2002), 681‐682.

Academy Award for Technical Achievement 1997

57© Bedrich Benes

Perlin Noise• Properties:

• Statistically invariant to rotation and translation• Continuous• Perlin Noise is 1D, 2D, 3D, … nD, • Limited frequency spectrum• Repeatable (returns the same value for the parameters)

double noise(double t) //1D casedouble noise(double x, double y) //2D casedouble noise(double x, double, y, double z)//3D case

58

© Bedrich Benes

Perlin Noise• Limited frequency spectrum means we can chose 

the maximum desirable detail

• Returns value from 

• It is seeded by the input parameter

59© Bedrich Benes

Perlin Noise ‐ Algorithm• Initialization

• Divide the space to 𝑛𝐷 equally distributed cells with integer coordinates

• Each cell has a predefined pseudorandom gradient

© Matt Zucker

© Matt Zucker

60

Page 16: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Perlin Noise ‐ Algorithm• Call:

• By calling with non‐integer coordinates  𝑥,𝑦, 𝑧• Find the corresponding cell  𝑖, 𝑗,𝑘 𝑥 , 𝑦 , 𝑧• Calculate the vector from𝑥,𝑦, 𝑧 to each vertex• The influence of each vertex

is given by its distance• Sum the contributions by 

using sigmoid weighting function𝑓 𝑡 3𝑡 2𝑡• For large tables hash function is used

© Matt Zucker

© Matt Zucker

61© Bedrich Benes

Perlin Noise

62

© Bedrich Benes

Summing Noise Functions

where

is called persistenceis called noise frequency

63© Bedrich Benes

Summing Noise Functions• Maintains the overall shape• Add details and higher frequencies

64

+

Page 17: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Summing Noise Functionsoctaves=1 octaves=2

octaves=7octaves=3

65© Bedrich Benes

Summing Noise Functions

© Paul Bourke

66

© Bedrich Benes

Turbulence• Start with a simple color ramp

67© Bedrich Benes

Turbulence ‐marble• Perturb it by Perlin noise

defines the influence (amplitude) of each octave

3  6  10 octaves 

68

Page 18: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Turbulence ‐ wood• Subtract the integer part of Perlin noise:

69© Bedrich Benes

Hypertexture• Defines properties close to the object surface• It is a procedural definition, just perturbs the space• Can be displayed by raycasting

70

© Bedrich Benes

Hypertexture

© Ken Perlin71K. Perlin and E. M. Hoffert. 1989. Hypertexture. SIGGRAPH Comput. Graph. 23, 3 (July 1989), 253–262.

© Bedrich Benes

libnoiselibnoise is an opensource library for C++

http://libnoise.sourceforge.net/index.html

72

Page 19: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Diffusion Limited Aggregation – DLA1) Particles (molecules) are floating in the water2) When a particle approaches 

an condensation centerit is aggregated

3) The process is repeated for many particles

The important part is the way the particles traveli.e., random walkCorals, lightings, frozen ice on a window, etc.

73© Bedrich Benes

Diffusion Limited Aggregation – DLA

74

© Bedrich Benes

Diffusion Limited Aggregation – DLA

75© Bedrich Benes

Diffusion Limited Aggregation – DLA

Corals app

76

Page 20: 590 –CGS Procedural Fractalshpcg.purdue.edu/.../lectures/CS590-CGS-07-Fractals.pdf · Fractals Classification • Deterministic (or exact) fractals • Non‐deterministic or random

© Bedrich Benes

Diffusion Limited Aggregation – DLA

77

https://softologyblog.wordpress.com/2017/05/22/pushing-3d-diffusion-limited-aggregation-even-further/© softologyblog


Recommended