ゲームグラフィックス特論 第1回

Post on 14-Jun-2015

7.210 views 3 download

description

レンダリングパイプライン

Transcript of ゲームグラフィックス特論 第1回

1

2

•  •  3DCG

•  •  OpenGL GLSL (OpenGL Shading Language)

• •  3D • 

•  3DCG

•  GPU

3

•  • 

•  : 0 : 2 : 3: 4 : 5

•  40% 60%• 

•  • 

•  • 

•  • 

4

• • 

• • 

• 

• • 

•  • …

5

•  •  (CG)

•  • 

•  • 

6

CG

7

•  (CG)•  3DCG

• • • 

• • • 

8

•  3DCG • 

• 

• • 

• 

• •  (interaction)

•  CG

9

CG

Interactive Phong

10

CG • 

• 

• •  3DCG

• • 

• • 

11

CG • 

•  …

• •  …

• • •  API •  …

12

• • 

• • 

• 

• •  API / •  / • 

• 

13

14

アプリケーション(やりたいこと)

ハードウェア(やれること)

アプリケーション(やりたいこと)

ハードウェア(やれること)

アルゴリズムセマンティックギャップ(隔たり)

15

•  • 

•  •  •  •  ACM CORE, ISO GKS, GKS-3D, PHIGS, PHIGS+, …

•  •  •  CPU (API - Application Program Interface) •  OpenGL, DirectX, …

• OpenGL/DirectX •  •  API

16

アプリケーション(やりたいこと)

ハードウェア(やれること)

アプリケーション(やりたいこと)

ハードウェア(やれること)

アルゴリズム

グラフィックスライブラリ

アルゴリズム

アプリケーション(やりたいこと)

ハードウェア(やれること)

グラフィックスライブラリ

アルゴリズム

アルゴリズム

17

GPU

CPU側に実装

GPU側に実装

アプリケーション(やりたいこと)

アルゴリズム

アルゴリズム

グラフィックスライブラリ

プログラマブルシェーダ

固定機能ハードウェア

グラフィックスライブラリは GPU を対象としたときに機能が整理された

ハードウェア APIとしての役割に集中する

ハードウェア(やれること)

アルゴリズム

18

API •  API

• 

•  •  •  • 

•  • 

•  API •  OpenSceneGraph, SceniX, OpenInventor (obsolete), …

•  •  CryENGINE, Unreal Engine, Unity, MascotCapsule, OROCHI, chidori, Irrlicht,

OGRE, Blender Game Engine, BISHAMON ( ) …

19

アプリケーション(やりたいこと)

アプリケーション(やりたいこと)

アプリケーション(やりたいこと)

ハードウェア(やれること)

アルゴリズム

アルゴリズム

アルゴリズム

ミドルウェア

ハードウェア API

プログラマブルシェーダ

固定機能ハードウェア

20

21

図形情報

材質情報

光源情報

視点情報

画像情報

22

•  •  • 

•  • 

• 

•  •  • 

•  • 

• 

• 

23

• • 

• 

•  •  fps (Frames Per Second)

•  1 fps – •  8 fps – •  15 fps – •  60 fps –

•  • 

•  •  •  …

24

•  fps • • 

• Hz • • 

•  60Hz •  fps 60

• 

•  fps 60Hz •  30fps, 20fps, 15fps, 12fps, 10fps, •  1 16ms 60fps 17ms 30fps

25

• • 

•  • 

•  •  • 

• •  PC •  3D

• GPU (Graphics Processing Unit) •  • 

26

• • 

• • • 

27

1 Cycle

1/3 Cycle 1/3 Cycle 1/3 Cycle

Not Pipelined

Pipelined

1 Operation/Cycle

3 Operations/Cycle

28

1/4 Cycle 1/2 Cycle 1/4 Cycle

2 Operations/Cycle

1/3 Cycle 1/3 Cycle 1/3 Cycle

3 Operations/Cycle

29

• 

30

CPU

31

• • 

• 

• • 

• 

• 

•  •  • 

32

• • 

• • 

•  • 

• 

•  • 

• 

• 

33

•  •  • 

•  CPU•  (GPU)

• 

• •  …

• • 

34

35

•  •  …

•  • 

• • 

• •  • 

36

37

Single-Pipe

Multi-Pipe

38

•  •  • 

• • • 

• • •  • 

• • 

39

40

41

x

y

z x

y

z

x

y

z

x

y

z

42

• • 

• • • • 

•  •  •  GPU

43

44

•  •  (Normalized Device Coordinate, NDC)

(-1,-1,-1), (1,1,1) x, y, z • 

• • 

• • 

45

標準ビューボリューム

視野錐台 (View Frustum)

直交投影(Orthographic Projection)

透視投影(Perspective Projection)

1

-1

1-1

1

-1

ビューボリューム (View Volume)

(Canonical View Volume)

46

47

1

-1 1

-1

O

1

-1 1

-1

O

48

49

50

1

-1 1

-1

O

x

y

w

hx�

y�

51

52

53

• • 

•  • 

•  •  → •  →

•  • 

•  • 

•  • 

•  …

54

y1 < y0

dy2 y2 − y0

N

Y

N

BEGIN

t� x0x0� x1x1� tt� y0y0� y1y1� t

y2 < y0Y

Nt� x0x0� x2x2� tt� y0y0� y2y2� t

y2 < y1Y

Nt� x1x1� x2x2� tt� y1y1� y2y2� t

dy2 > 0

Ydx2� x2 − x0

Y

mx2� dx2 / dy2N

mx2� dx2 − dy2 + 1 / dy2

ax2� 2 mx2dy2 − dx2bx2� 2dy2ex2� dy2

2

dx1� x1 − x0

Y

mx1� dx1 / dy1N

mx1� dx1 − dy1 + 1 / dy1

ax1� 2 mx1dy1 − dx1bx1� 2dy1ex1� dy1

dx1� x2 − x1

Y

mx1� dx1 / dy1N

mx1� dx1 − dy1 + 1 / dy1

ax1� 2 mx1dy1 − dx1bx1� 2dy1ex1� dy1

dy1� y1 − y0

dy1 > 0N

Y

dy1� y2 − y1

dy1 > 0N

Y

2 4

hline(hx1, hx2, y, c)

y� y + 1

hx1� hx1 + mx1ex1� ex1 + ax1

Y

Nhx1� hx1 + 1ex1� ex1 + bx1

Y

Nhx2� hx2 + 1ex2� ex2 + bx2

hx2� hx2 + mx2ex2� ex2 + ax2

dy1� dy1 − 1

dy1 > 0

Y

N 4

dx1 > 0=

hx1� x0 hx1� x1

dx2 > 0= dx1 > 0=

hx2� x0

ex1 < 0=

ex2 < 0=

y� y0

4

hline(hx1, hx2, y, c)

y� y + 1

hx1� hx1 + mx1ex1� ex1 + ax1

Y

Nhx1� hx1 + 1ex1� ex1 + bx1

Y

Nhx2� hx2 + 1ex2� ex2 + bx2

hx2� hx2 + mx2ex2� ex2 + ax2

dy1� dy1 − 1

dy1 > 0

Y

ex1 < 0=

ex2 < 0=

6

3

31

1

5

5

) (

N END�

55

• • 

• • 

56

McCool, M. D., Wales, C., Moule, K., Incremental and Hierarchical Hilbert Order Edge Equation Polygon Rasterization, Proceedings of the ACM SIGGRAPH/EUROGRAPHICS workshop on Graphics hardware, ACM, pp. 65-72, 2001

57

58

•  •  • 

•  • 

•  • 

• 

59

60

• •  • • •  • 

• 

• • • 

61

• • 

• • 

• • 

•  • 

• • 

• • 

62

63

64

��

�������� ���

�����������

��������� �

!�"��

• • 

• 

•  • 

• • 

• • 

•  (FBO) •  • 

65

• • 

• • 

• • 

• • 

• 

66

Z • • 

• • • 

• •  • 

67

GeForce 256

68

http://www.hc.t.u-tokyo.ac.jp/~kaki/paper/VSJ/VisFrontier/OpenGLarchiAnswers.pdf

69

GeForce 256 • 

• •  Hardware T & L (Transform and Lighting) • 

• GPU (Graphics Processing Unit)•  CPU

72

GeForce 256 • 

• •  • 

• • • • 

73

•  GitHub •  https://github.com/tokoik/ggsample01

•  Web •  Web

•  http://www.wakayama-u.ac.jp/~tokoi/lecture/gg/ • 

•  Linux / Windows / Mac OS X •  OpenGL 3.2 •  OpenGL 3.2 / DirectX 10

• 

• 

OpenGL

76