Modeling (01) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk - - PowerPoint PPT Presentation

modeling 01
SMART_READER_LITE
LIVE PREVIEW

Modeling (01) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk - - PowerPoint PPT Presentation

Principles of Computer Graphics and Image Processing Modeling (01) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk Computer Graphics Image processing Representing and manipulation of 2D images Modeling Representing and


slide-1
SLIDE 1

Principles of Computer Graphics and Image Processing

Modeling (01)

  • RNDr. Martin Madaras, PhD.

martin.madaras@stuba.sk

slide-2
SLIDE 2

Computer Graphics

2

 Image processing

 Representing and manipulation of 2D images

 Modeling

 Representing and manipulation of 2D and 3D objects

 Rendering

 Constructing images from virtual models

 Animation

 Simulating changes over time

slide-3
SLIDE 3

3

  • Ask questions, please!!!
  • Be communicative
  • www.slido.com #PPGSO01
  • More active you are, the better for you!
  • We will go into depth as far, as there are no questions

How the lectures should look like #1

slide-4
SLIDE 4

What is Modeling?

4

 Representation and manipulation of objects

 Acquire  Edit  Transform  Smooth  Render  Deform  Morph  Compress  Transmit  Analyze

slide-5
SLIDE 5

What is Modeling?

5

 Representation and manipulation of objects

 Acquire  Edit  Transform  Smooth  Render  Deform  Morph  Compress  Transmit  Analyze

slide-6
SLIDE 6

Modeling

6

 How to represent ..

 2D and 3D objects in a computer?  Acquire computer representations of objects?  Manipulate representations of objects?

slide-7
SLIDE 7

Quick test #1

7

 Describe the picture

slide-8
SLIDE 8

Quick test #2

8

 Describe the picture

slide-9
SLIDE 9

Quick test #3

9

 Volunteers:

Describe the image to others

 Others:

Reproduce the image

slide-10
SLIDE 10

Semantic vs. numeric

10

 Humans – semantic representation

 concepts, notions, meanings, emotions...  imprecise, ambiguous

 Computers – numeric representation

 exact, mathematical, straightforward

slide-11
SLIDE 11

Detailed representation

11

slide-12
SLIDE 12

2D Object Representations

12

 How to define 2D shapes?

slide-13
SLIDE 13

2D Object Representations

13

 Let’s define these objects

slide-14
SLIDE 14

2D Object Representations

14

 How to make 2D representation smooth at any scale?

Bitmaps, raster, pixels, explicit Shapes, vectors, curves, parametric, implicit

slide-15
SLIDE 15

2D Object Representations

15

 Lines  Polygon (set of lines)  Curves  Vector image (set of curves)

slide-16
SLIDE 16

2D Object Representations

16

 Vector Images

slide-17
SLIDE 17

3D Object Representations

17

 How to represent a 3D object?

slide-18
SLIDE 18

3D Object Representations

18

 Polygons…

slide-19
SLIDE 19

3D Object Representations

19

 Voxels…

slide-20
SLIDE 20

3D Object Representations

20

 Recreating artwork

slide-21
SLIDE 21

3D Object Representations

21

 Mechanical objects

slide-22
SLIDE 22

3D Object Representations

22

 Maps, Cities, Landscape

slide-23
SLIDE 23

3D Object Representations

23

 Clouds, Smoke, Fog, Water

slide-24
SLIDE 24

2D Object Representations

24

 Pixels

 Images

 Lines

 Curves

 Polygons

 Discrete,

Vector graphics

slide-25
SLIDE 25

3D Object Representations

25

 Points

 Range Image, Point Cloud

 Surfaces

 Polygonal, Subdivision, Parametric, Implicit

 Solids

 Voxels, BSP Tree, CSG, Sweep, etc.

 Hierarchical Structures

 Scene graph, Application specific…

slide-26
SLIDE 26

Why so many representation?

26

 Efficiency for different tasks

 Rendering  Acquisition  Manipulation  Animation  Analysis

 Data structures determine algorithms

slide-27
SLIDE 27

Outline

27

 Points

 Range Image, Point Cloud

 Surfaces

 Polygonal, Subdivision, Parametric, Implicit

 Solids

 Voxels, BSP Tree, CSG, Sweep

 Hierarchical Structures

 Scene graph, Application specific

slide-28
SLIDE 28

Range Image

28

 Set of 3D points mapping to pixels of depth image  Structured Point Cloud

 Acquired using a range scanner (eg. Kinect)

slide-29
SLIDE 29

Point Cloud

29

 Unstructured set of 3D point samples

 Acquired from multiple range scans, vision, etc.

slide-30
SLIDE 30

Point Cloud Animation: Road Survey

30

https://www.youtube.com/watch?v=f_ng212b-UM

slide-31
SLIDE 31

Outline

31

 Points

 Range Image, Point Cloud

 Surfaces

 Polygonal, Subdivision, Parametric, Implicit

 Solids

 Voxels, BSP Tree, CSG, Sweep

 Hierarchical Structures

 Scene graph, Application specific

slide-32
SLIDE 32

Polygonal Mesh

32

 Connected mesh of polygons (usually triangles)

 Most common representation, supported in OpenGL

slide-33
SLIDE 33

Subdivision Surface

33

 Coarse mesh with subdivision rule  Smooth surfaces are defined as sequences of refinement

slide-34
SLIDE 34

Subdivision Surface

34

 Properties

 Accurate  Concise  Intuitive specification  Local support  Affine invariant  Arbitrary topology  Guaranteed continuity  Natural parametrization  Efficient display  Efficient intersections Geri’s game, Pixar, 1997: https://www.youtube.com/watch?v=kweN7VLx-JE

slide-35
SLIDE 35

Subdivision Surfaces: Overview

35

https://www.youtube.com/watch?v=ckOTl2GcS-E&t=26s

slide-36
SLIDE 36

Subdivision Surfaces: Overview

36

 Subdivision surfaces

 Loop subdivision  Catmull-Clark  Butterfly, Doo-Sabin, etc.

slide-37
SLIDE 37

Example: Loop subdivision

37

 How to refine mesh ?

 Refine each triangle into 4 triangles by splitting each edge and

connecting the vertices

slide-38
SLIDE 38

Example: Loop subdivision

38

 How position new vertices?

 Choose location of the vertices as weighted average of original

vertices in local neighborhood

 Rules for extraordinary vertices and boundaries:

slide-39
SLIDE 39

Key Questions

39

 How to refine mesh ?

 Aim for properties like smoothness

 How to store mesh ?

 Aim for efficiency of implementing subdivision rules

slide-40
SLIDE 40

Polygonal meshes

40

 V, E, F  P, S

slide-41
SLIDE 41

Polygonal Meshes

41

 Mesh Representations

 Independent faces  Vertex and face tables  Adjacency lists  Winged-Edge

slide-42
SLIDE 42

Independent Faces

42

 Each face lists vertex coordinates

 Redundant vertices  No topology information

slide-43
SLIDE 43

Vertex and Face Tables

43

 Each face lists vertex references

 Shared vertices  Still no topology information

slide-44
SLIDE 44

Adjacency Lists

44

 Store all vertex, edge and face adjacency

 Efficient topology traversal  Extra storage

slide-45
SLIDE 45

Partial Adjacency Lists

45

 Can we can store only some adjacency information and

derive others?

slide-46
SLIDE 46

Winged Edge

46

 Adjacency encoded in edges

 All adjacencies in O(1) time  Little extra storage  Arbitrary polygons

slide-47
SLIDE 47

Winged Edge Example

47

slide-48
SLIDE 48

Parametric Surface

48

 Defined using control points  Surfaces are defined using parametric functions  m × n control points  parameters u,v http://cadauno.sourceforge.net/

slide-49
SLIDE 49

Parametric Surface

49

 Cubic Bezier surface, NURBS

slide-50
SLIDE 50

Implicit Surface

50

 Surface satisfying function F(x,y,z) = 0

Polygonal model Implicit model

slide-51
SLIDE 51

Question

51

What happens if we turn F(x,y,z) = 0 into F(x,y,z) ≤ 0 ?

surface → volume

slide-52
SLIDE 52

Outline

52

 Points

 Range Image, Point Cloud

 Surfaces

 Polygonal, Subdivision, Parametric, Implicit

 Solids

 Voxels, BSP Tree, CSG, Sweep

 Hierarchical Structures

 Scene graph, Application specific

slide-53
SLIDE 53

Volumetric representation

53

 not only boundary

but also the insides

  • f the object

 Medicine  Physics  Simulations  Animation

slide-54
SLIDE 54

Voxels

54

 Uniform grid of volumetric samples  Acquired using CAT, MRI scans etc.  Volume elements, “3D pixels”  Discrete

slide-55
SLIDE 55

Volume Rendering Demo

55

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

slide-56
SLIDE 56

BSP Trees

56

 Binary space partition

 Constructed from polygonal representations

slide-57
SLIDE 57

Constructive Solid Geometry

57

 Hierarchy of boolean operations

 Union, Difference, Intersect applied to simple shapes

slide-58
SLIDE 58

Functional Representation

58

 F-rep ~ generalization of CSG  More node functions – operators

 e.g. object blending

slide-59
SLIDE 59

59

Mesh reconstruction

 Conversion into an implicit function

 Poisson reconstruction

slide-60
SLIDE 60

60

Mesh reconstruction

 Isosurface extraction

 Marching cubes

slide-61
SLIDE 61

61

Marching cubes

 Create cubes  Classify vertices  Build indices  Lookup edge list

slide-62
SLIDE 62

62

Marching cubes

 Create cubes  Classify vertices  Build indices  Interpolate Triangle

Vertices

slide-63
SLIDE 63

63

Marching cubes

 Create cubes  Classify vertices  Build indices  Interpolate Triangle

Vertices

 Calculate normals

slide-64
SLIDE 64

64

Marching cubes

slide-65
SLIDE 65

65

Marching cubes

slide-66
SLIDE 66

66

Marching cubes

slide-67
SLIDE 67

67

Marching cubes

slide-68
SLIDE 68

68

Marching cubes

slide-69
SLIDE 69

Outline

69

 Points

 Range Image, Point Cloud

 Surfaces

 Polygonal, Subdivision, Parametric, Implicit

 Solids

 Voxels, BSP Tree, CSG, Sweep

 Hierarchical Structures

 Scene graph, Application specific

slide-70
SLIDE 70

Scene Graph

70

 Objects organized in a hierarchical structure

slide-71
SLIDE 71

Application Specific

71

 Specific for given application domain

slide-72
SLIDE 72

Taxonomy of 3D representations

72

slide-73
SLIDE 73

Computational Differences

73

 Efficiency

 Computational complexity ( O(n log n) )  Space/Time trade-off  Numerical stability/accuracy

 Simplicity

 Hardware acceleration  Ease of acquisition  Software creation and maintenance

 Usability

 Designer vs. computational engine

slide-74
SLIDE 74

Parametric vs. polygonal

74

 Parametric

 smooth, reparametrizable  harder rendering  precise rendering

 Polygonal

 discrete, hard to reparametrize  faster rendering or rasterization  approximative rendering

slide-75
SLIDE 75

75

  • Ask questions, please!!!
  • Be communicative
  • www.slido.com #PPGSO01
  • More active you are, the better for you!

How the lectures should look like #2

slide-76
SLIDE 76

Fast Forward to Practical Assignment

76

Drawing a Line

slide-77
SLIDE 77

Drawing a Line

77

slide-78
SLIDE 78

Drawing a Line

78

slide-79
SLIDE 79

Drawing a Line

79

 Some things to consider

 Which pixels are to be drawn?  How thick the lines are?  How to join lines?

slide-80
SLIDE 80

Drawing a Line

80

slide-81
SLIDE 81

Drawing a Line

81

 We need some basic math:

slide-82
SLIDE 82

Drawing a Line

82

 We need some basic math:

x=x1 y=y1 while(x<x2) plot(x,y) x++ y+=Dy

slide-83
SLIDE 83

Drawing a Line

83

 After rounding

slide-84
SLIDE 84

Drawing a Line

84

 Great, but what about accumulated error?

slide-85
SLIDE 85

Drawing a Line

85

 What about steep lines?

|m|≤ 𝟐 |m|> 𝟐

slide-86
SLIDE 86

Drawing a Line

86

 First code

void drawLine(int x1, int x2, int y1, int y2) { float m = (y2-y1)/(x2-x1); int x = x1; float y = y1; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; y += m; } }

slide-87
SLIDE 87

Drawing a Line

87

 It has some issues

void drawLine(int x1, int x2, int y1, int y2) { float m = (y2-y1)/(x2-x1); not exact! int x = x1; float y = y1; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; y += m; accumulates error! } }

slide-88
SLIDE 88

Drawing a Line

88

 First changes, use error threshold

void drawLine(int x1, int x2, int y1, int y2) { float m = (y2-y1)/(x2-x1); int x = x1; int y = y1; float e = 0.0f; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; e += m; if(e>0.5f) { y += 1; e -= 1.0f; } } }

slide-89
SLIDE 89

Drawing a Line

89

 More changes, error condition to 0

void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; float e = -0.5f; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; e += (y2-y1)/(x2-x1); if(e>0.0f) { y += 1; e -= 1.0f; } } }

slide-90
SLIDE 90

Drawing a Line

90

 More changes, splitting up the fraction

void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; float e = -0.5f*(x2-x1); while(x<=x2) { setPixel(x, y, PIXEL_ON); x += 1; e += y2-y1; if(e>0.0f) { y += 1; e -= x2-x1; } } }

slide-91
SLIDE 91

Drawing a Line

91

 More changes, get rid of floats

void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; int e = -(x2-x1); while(x<=x2) { setPixel(x, y, PIXEL_ON); x += 1; e += 2*(y2-y1); if(e>0) { y += 1; e -= 2*(x2-x1); } } }

slide-92
SLIDE 92

Drawing a Line

92

 Jack E. Bresenham, 1962  Fast, no floating points, only for |𝑛| < 1 and 𝑦1 < 𝑦2

void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; int e = -(x2-x1); while(x<=x2) { setPixel(x, y, PIXEL_ON); x += 1; e += 2*(y2-y1); if(e>0) { y += 1; e -= 2*(x2-x1); } } }

slide-93
SLIDE 93

93

OpenGL Project (simple demo / scene / game )

PPGSO Project

slide-94
SLIDE 94

94

  • No engines allowed (NO Unity, Unreal engine etc.)
  • You can cooperate, help each other
  • Libraries for resource loading are allowed
  • Evaluated is graphical output, interaction and animation
  • Gameplay is secondary (is not scope of this lecture)

OpenGL Project

slide-95
SLIDE 95

95

 Specification [6p]

 Data structures (1p)  Class diagrams (1p)  Pseudocodes (1p)  User interaction diagrams (1p)  Structure rendering algorithms (1p)  Modul connection diagrams (1p)

 Use of texture mapping on 3D geometry [4p]

 Unique 3D meshes (2p)  Unique texturing using uv coordinates (2p)

 Camera transformations [6p]

 Camera with perspective projection (1p)  Animated camera (2p)  Interactive camera (2p)  Use of multiple camera view positions (1p)

OpenGL Project

slide-96
SLIDE 96

96

 Scene logic [5p]

 Implementation of a scene with logically relative objects (1p)  Changing scenes and multiple areas/scenes (2p)

 At least 2 different scenes

 Scene has a logical ground and background (sky, ceiling, walls…) (1p)  Presented demo must have a beginning and a logical ending (1p)

 Objects and interactions [6b]

 Dynamic scene with objects being created and destroyed during demo

simulation (1p)

 At least 2 different types of objects

 Procedurally generated scene (2b)

Constraints and deterministic definitions for object localization

 Effective object to object collisions and interactions (3p)

 Dynamic response to collisions

OpenGL Project

slide-97
SLIDE 97

97

 Transformations and animation [9b]

 Procedurally driven animation (2p)

 Encapsulated method with parameters  Logical branching

 Basic simulated animation with at least 2 forces using matrix algebra (2p)

  • Eg. gravity + wind

 Hierarchical object transformation (2p)

 At least 2 levels with 3 objects  Using the aggregation and transformation matrices

 Data driven animations, recommended using key-frames (3p)

 Key-frame sequence represented by code structure of transformation matrix

and time information

 Interpolation using curves or quaternions and spherical linear interpolation

OpenGL Project

slide-98
SLIDE 98

98

 Lighting with multiple light sources [7b]

 Diffuse scene lighting with materials (2p)  Changeable color of light (1b)  Correct Phong lighting with multiple light sources (2p)

 Correct depth-based attenuation  At least 3 material and light components  Correctly combine material and light components

 Correct shadows or reflections using any approach you can think of (2p)

 Project report (pdf) [7b]

 1xA4 description of the project manual + runnable package (1b)  2xA4 screens from the projects + game video (2b)  Critical evaluation and update of the specification (4b)

OpenGL Project

slide-99
SLIDE 99

99

 Get a project!

 https://tinyurl.com/y3jdfms4

 Subject information:

 https://tinyurl.com/y6244wyn

OpenGL Project

slide-100
SLIDE 100

100

2D Transformations 3D Transformations Projections

Next Week

slide-101
SLIDE 101

101

Acknowledgements

 Thanks to all the people, whose work is shown here and whose

slides were used as a material for creation of these slides:

Matej Novotný, GSVM lectures at FMFI UK Peter Drahoš, PPGSO lectures at FIIT STU

slide-102
SLIDE 102

102

www.slido.com #PPGSO01 martin.madaras@stuba.sk

Questions ?!