Procedural Geometry Jaanus Jaggo 1 Procedural geometry uses - - PowerPoint PPT Presentation

procedural geometry
SMART_READER_LITE
LIVE PREVIEW

Procedural Geometry Jaanus Jaggo 1 Procedural geometry uses - - PowerPoint PPT Presentation

Procedural Geometry Jaanus Jaggo 1 Procedural geometry uses Sprite fonts 2D sprites geometrization Procedural landscapes Procedural flora Procedural destruction Meshing point clouds Procedural growth 2


slide-1
SLIDE 1

Procedural Geometry

Jaanus Jaggo

1

slide-2
SLIDE 2

Procedural geometry uses

  • Sprite fonts
  • 2D sprites geometrization
  • Procedural landscapes
  • Procedural flora
  • Procedural destruction
  • Meshing point clouds
  • Procedural growth

2

Pandora from Avatar movie - uses a lot of procedural geometry

slide-3
SLIDE 3

Sprite Fonts

Blizzard’s TCG card

3

slide-4
SLIDE 4

Sprite fonts generation

4

slide-5
SLIDE 5

2D sprite geometrization

  • GPU can handle loads of vertices
  • limited in Pixel Fill-Rate

67% of pixels saved

Source: http://discuss.cocos2d-x.org/t/new-feature-meshsprite-polygonsprite-updated/21153

Performance: (number of sprites rendered within 40 FPS)

5

slide-6
SLIDE 6

2D sprite geometrization

Unity does it automatically Can we do better?

6

slide-7
SLIDE 7

How it’s done proceduraly?

https://unity3d.com/learn/resources/boosting-graphics-performance-2d-games Algorithm by Erik Grahm

7

slide-8
SLIDE 8

Edge detection

substracted

8

slide-9
SLIDE 9

Edge detection

9

slide-10
SLIDE 10

Find closed path around the object

Problems: loops and deadlocks

10

slide-11
SLIDE 11

Simplify the polygon

Convex hull algorithm

11

slide-12
SLIDE 12

Simplify the polygon

Convex hull algorithm

kick out points that produce triangles

12

slide-13
SLIDE 13

Triangulation

Computational Geometry (Springer, third edition, 2008) This algorithm can triangulate polygons with holes

13

slide-14
SLIDE 14

Triangulation complexity

  • Ear clipping method - O(n2)
  • Using monotone polygons O(n log n)
  • Can be done within O(n) <- some complicated algorithms

14

slide-15
SLIDE 15

UV’s

15

slide-16
SLIDE 16

Optimizing it further

2-layered approach 2 layers == 2 draw calls

16

slide-17
SLIDE 17

Procedural landscape

  • Height field terrain
  • Vector field terrain
  • Voxel based terrain

17

slide-18
SLIDE 18

Heightmap based landscapes

  • Main game engines -> built in

18

Halo Wars: The Terrain Of Next Gen - (vector field terrain) http://www.gdcvault. com/play/1277/HALO-WARS-The-Terrain-of

slide-19
SLIDE 19

Height field vs. Vector field

19

slide-20
SLIDE 20

Voxel based procedural landscapes

20

slide-21
SLIDE 21

Smooth Voxels

http://nerdkingdomofficial.tumblr.com/post/119558446658/dev-blog-44-voxelize-this

21

slide-22
SLIDE 22

Isosurface extraction

22

  • Marching cubes
  • Marching Tetrahedra
  • Surface nets
  • Dual contouring

Demo: http://mikolalysenko.github. io/Isosurface/ http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html

slide-23
SLIDE 23

Marching cubes

23

28 = 256 different possibilities Problem: some cases are ambigious

slide-24
SLIDE 24

Marching cubes

24

slide-25
SLIDE 25

Marching Tetrahedra

25

Solves ambigiouty problem 24 = 16 different possibilities Problem: may produce artificial “bumps”

slide-26
SLIDE 26

Surface nets

Minecraft ;)

26

slide-27
SLIDE 27

Comparison

  • Marching cubes

○ + pretty fast ○ + most widely known

  • Marching tetrahedra

○ + solves ambigouty problem ○

  • much slower

  • far larger meshes
  • Surface nets

○ + fast ○ + slightly smaller meshes than first two ○

  • non-manifold vertices

27

http://0fps.net/2012/07/12/smooth-voxel-terrain-part-2/ non-manifold vertices

slide-28
SLIDE 28

Procedural flora

  • L-systems
  • Superformula

No man sky

28

slide-29
SLIDE 29

L-systems

Formal method for describing self similar objects.

http://buildingindustry.org/l-systems

29

slide-30
SLIDE 30

Superformula

Mathematical formula used to describe many complex shapes in nature.

parameters: a = b = 1 m, n1, n2, n3

30

slide-31
SLIDE 31

Procedural destruction

31

Assets in Unity assets store

slide-32
SLIDE 32

Shattering glass

before: https://www.youtube.com/watch?v=eQXCHfmsHQA after: https://www.youtube.com/watch?v=7U6kPGgGe1s

32

slide-33
SLIDE 33

Shattering glass

33

http://cowboyprogramming.com/2007/01/05/shattering-reality/

slide-34
SLIDE 34

Voronoi diagrams

https://www.youtube.com/watch?v=XYs5WOc4Etg http://forum.unity3d.com/threads/fracture-dynamic-destruction-system.177066/

34

Partitioning of a plane into regions based on distance to points (any point inside a region is closest to the origin)

Euclidean distance Manhattan distance

slide-35
SLIDE 35

Fortune’s algorithm

Sweep line algorithm for making voronoi diagrams

  • Vertical sweep line moves left to right
  • Beach line is a curve left to sweep line
  • Left of beach line all points are known
  • beach line progresses by keeping each parabola base exactly half way

between points initially swept and the sweep line

  • Beach line is maintained in binary search tree
  • Future points are maintained in priority queue
  • Algorithm repeatedly removes next event from priority queue and updates the

data structure.

35

O(n) events & O(log n) time to process an event = O(n log n) time

https://en.wikipedia.org/wiki/Fortune%27s_algorithm

slide-36
SLIDE 36

More uses for voronoi

36

slide-37
SLIDE 37

More uses for voronoi

37

slide-38
SLIDE 38

Supernoi (multiple voronoi)

38

http://www.daxpandhi.com/post/Stark-Desert-Rocks

slide-39
SLIDE 39

Meshing point clouds

https://www.youtube.com/watch?v=_RHXqG7HlEM

39

1. Subsampling a. reducing the dataset 2. Normal reconstruction 3. Surface reconstruction a. marching cube algorithms b. quadric edge collapse simplification 4. Recovering original color 5. Cleaning up and assessing

http://meshlabstuff.blogspot.com.ee/2009/09/meshing-point-clouds.html There are also other methods for example Voronoi filtering for steps 2 and 3

slide-40
SLIDE 40

Procedural growth

https://www.youtube.com/watch?v=9HI8FerKr6Q

40

https://vimeo.com/27913396

slide-41
SLIDE 41

Growing citys

A roadmap generated:

41

https://josauder.github.io/procedural_city_generation/

slide-42
SLIDE 42

Growing citys

Rules:

42

slide-43
SLIDE 43

Growing rules

43

Rule Forward Turn pForward pTurn grid

vert + prev_vec

vert + rot 90

1 0.09

  • rganic

vert + random rot vert + rot (60,120)

1 0.8 radial

vert + adjust vec vert + adjust vec

1 0.07 minor road

vert + prev_vec vert + rot 90

0.05 0.85

slide-44
SLIDE 44

Vertex snapping

44

slide-45
SLIDE 45

Thank you for listening

Here is a kitten for you!

45