Real-Time Rendering Graphics Programming p g g Graphics - - PowerPoint PPT Presentation

real time rendering graphics programming p g g graphics
SMART_READER_LITE
LIVE PREVIEW

Real-Time Rendering Graphics Programming p g g Graphics - - PowerPoint PPT Presentation

Real-Time Rendering Graphics Programming p g g Graphics Libraries (APIs) Give access to graphics hardware D Declarative (What, not How) l ti (Wh t t H ) Describe the scene (e.g., scene graphs) SGI Open Inventor, SGI Performer,


slide-1
SLIDE 1

Real-Time Rendering Graphics Programming p g g

slide-2
SLIDE 2

Graphics Libraries (APIs) Give access to graphics hardware… D l ti (Wh t t H ) Declarative (What, not How)

Describe the scene (e.g., scene graphs) SGI Open Inventor, SGI Performer, Renderman OpenSceneGraph Renderman, OpenSceneGraph…

Imperative (How, not What)

Sequence of drawing commands OpenGL, DirectX (Direct3D), Postscript OpenGL, DirectX (Direct3D), Postscript More direct control

Vienna University of Technology 2

slide-3
SLIDE 3

Graphics Libraries (APIs) Using a scene graph API… Application Application Application Application Scenegraph Scenegraph Scenegraph Scenegraph Application Application Application Application Windows/Linux Windows/Linux Windows/Linux Windows/Linux OpenGL OpenGL OpenGL OpenGL Scenegraph Scenegraph Scenegraph Scenegraph Windows/Linux Windows/Linux Windows/Linux Windows/Linux OpenGL OpenGL OpenGL OpenGL Hardware Hardware Hardware Hardware

Vienna University of Technology 3

slide-4
SLIDE 4

Graphics Libraries (APIs) Using an immediate-mode API… Application Application Application Application GLUT GLUT GLUT GLUT Application Application Application Application Windows/Linux Windows/Linux Windows/Linux Windows/Linux OpenGL OpenGL OpenGL OpenGL GLUT GLUT GLUT GLUT Windows/Linux Windows/Linux Windows/Linux Windows/Linux OpenGL OpenGL OpenGL OpenGL Hardware Hardware Hardware Hardware

Vienna University of Technology 4

slide-5
SLIDE 5

Immediate vs. Retained Immediate (OpenGL)

Total control over rendering Total control over rendering

traversal and data structures and formats

Many subroutine calls Driver cannot optimize Driver cannot optimize

Retained (scene graph, display lists)

Driver can optimize execution of display lists API can optimize traversal of scene graph API can optimize traversal of scene graph

for different platforms!

T l i diffi lt t h

Vienna University of Technology 5

Traversal is difficult to change

slide-6
SLIDE 6

The OpenGL Graphics System Web site: www.opengl.org O GL t d k d b SGI OpenGL trademark owned by SGI

More than 70 licensees

OpenGL is controlled by the “ARB”

Architecture Review Board Architecture Review Board Members: Compaq, IBM, Intel, Microsoft, SGI, Evans & Sutherland, HP, Sun, NVidia, ATI, Apple pp Meeting notes on the Web  follow ARB decisions discussions

Vienna University of Technology 6

 follow ARB decisions, discussions, …

slide-7
SLIDE 7

A Short OpenGL Freshup All primitives made up of vertices…

G O S GL POINTS GL_LINES GL_LINES GL_POLYGON GL_POLYGON GL LINE LOOP GL LINE LOOP GL LINE STRIP GL LINE STRIP GL_POINTS GL_POINTS _ _ _ _ _ _ _ _ GL_TRIANGLES GL_TRIANGLES GL QUAD STRIP GL QUAD STRIP GL TRIANGLE FAN GL TRIANGLE FAN GL TRIANGLE STRIP GL TRIANGLE STRIP GL_QUADS GL_QUADS

Vienna University of Technology 7

GL_QUAD_STRIP GL_QUAD_STRIP _ _ _ _ GL_TRIANGLE_STRIP GL_TRIANGLE_STRIP

slide-8
SLIDE 8

A Short OpenGL Freshup Shading: From wire frame to texture mapped From wire frame to texture mapped…

Wire frame (hidden line) flat shading Gouraud Textured (Combination)

Vienna University of Technology 8

Gouraud Textured (Combination)

slide-9
SLIDE 9

Short History of OpenGL

1982 Silicon Graphics (SGI) incorporated 1983 IRIS GL on IRIS 1000 terminal (the predecessor to OpenGL) (the predecessor to OpenGL) 1991 OpenGL ARB created 1992 OpenGL 1.0 (June 30) 1995 OpenGL 1 1 1995 OpenGL 1.1 1996 OpenGL specification made public 1998 OpenGL 1.2 O G 2000 OpenGL goes open source 2001 OpenGL 1.3 2002 OpenGL 1.4 2002 OpenGL 1.4 2003 OpenGL 1.5 2004 OpenGL 2.0 (Shaders) 2008 OpenGL 3 0 (Depreciation model) 2008 OpenGL 3.0 (Depreciation model) 2008 OpenGL 3.0 (Depreciation model) 2009 OpenGL 3.2 (Geometry shaders) 2010 O GL 4 0 (T l ti )

Vienna University of Technology 9

2010 OpenGL 4.0 (Tesselation)

slide-10
SLIDE 10

Modern Graphics Pipeline

Application Command Geometry Rasterization Texture Texture Fragment Display

Vienna University of Technology 10

slide-11
SLIDE 11

OpenGL Programing Model OpenGL is a state machine

All command change state All command change state Only glVertex causes action

Vienna University of Technology 11

slide-12
SLIDE 12

Vienna University of Technology 12

slide-13
SLIDE 13

OpenGL Design Goals

Platform independent (unlike DirectX)

Window-system dependent code separate (GLX Window system dependent code separate (GLX, WGL) Implementations on Windows Linux MacOS Be Implementations on Windows, Linux, MacOS, Be, OS/2, Unix, … Language independent (bindings for C Java Language independent (bindings for C, Java, Fortran, …)

Consistency (unlike DirectX 9) Consistency (unlike DirectX 9)

Tightly written specification Conformance tests and required verification Not too tight: not pixel exact

Vienna University of Technology 13

Invariance across passes (for correct multipass)

slide-14
SLIDE 14

OpenGL Design Goals Complete implementations (unlike DirectX 9)

Missing hardware features emulated in Missing hardware features emulated in software Silent error recovery Silent error recovery

Clean interface (unlike DirectX 9)

State machine Most states are orthogonal (i.e., don’t g ( , influence each other, no side effects!)

Extensibility (unlike DirectX 9) Extensibility (unlike DirectX 9)

Favors innovation N HW f t fi t il bl O GL!

Vienna University of Technology 14

New HW features first available on OpenGL!

slide-15
SLIDE 15

More Goals High quality I t iti bilit (b t t ) Intuitive usability (beauty counts) Good documentation (Programming Guide) ( g g ) Long life…

Vienna University of Technology 15

slide-16
SLIDE 16

OpenGL Problems

Extensibility

Different extensions for different GPUs Different extensions for different GPUs Hell for production code (games)

D i b itt Design by committee

Unified extension interfaces take long time Very slow to adopt non-GPU specific features (e.g.,

  • ffscreen buffers)

Non-existent toolset

Shading debuggers (but: gDebugger) g gg ( g gg ) Performance tools (but: NVPerfKit) Mesh tools (already included in DirectX)

Vienna University of Technology 16

Mesh tools (already included in DirectX)

Mediocre driver support

slide-17
SLIDE 17

OpenGL Extensions SGI maintains central registry C f ll d t d Carefully documented

Takes into account previous extensions New OpenGL version could be implemented by applying all extensions by applying all extensions

A bit difficult to read

Read overview, then “Additions to…”

Very stable process Very stable process

Extensions are refined and improved…

Vienna University of Technology 17

slide-18
SLIDE 18

OpenGL Extension Categories

Proprietary: suffixed with vendor

e g SGIS texture lod NV fragment program e.g., SGIS_texture_lod, NV_fragment_program

EXT suffix

I l t d b t l t 2 d ( ll NV AMD) Implemented by at least 2 vendors (usually NV,AMD) e.g. EXT_blend_func_separate

ARB suffix

Specification controlled by ARB p y ARB_multitexture

1 x: no suffix 1.x: no suffix

Required feature for version 1.x

Vienna University of Technology 18

slide-19
SLIDE 19

Vienna University of Technology 19

slide-20
SLIDE 20

Vienna University of Technology 20

slide-21
SLIDE 21

Vienna University of Technology 21

slide-22
SLIDE 22

Vienna University of Technology 22

slide-23
SLIDE 23

Using Extensions Get glext.h from www.opengl.org Ch k f t i il bilit Check for extension availability Acquire function pointer(s) (only Win32) q p ( ) ( y ) Easier: use glew or glee

Vienna University of Technology 23

slide-24
SLIDE 24

OpenGL 2.0 Main novelty: shading language GLSL V t d f t h d Vertex and fragment shaders

Replace fixed functionality

Shader: high-level language (C-like) O GL d i il d li k f OpenGL driver: compiler and linker for shaders Vertex-, texture coordinates etc.: abstract input values to shader function abstract input values to shader function Arbitrary calculations possible

Vienna University of Technology 24

Requires DX9 (GeforceFX/6) cards

slide-25
SLIDE 25

OpenGL 3.0 Not much new V t A Obj t Vertex Array Objects

Encapsulate VBO state

sRGB framebuffers T t Texture arrays Transform feedback Extensions: geometry shaders, instancing, ... D i ti h i ! Depreciation mechanism!

Vienna University of Technology 25

slide-26
SLIDE 26

OpenGL 3.2 Geometry shaders

Vienna University of Technology 26

slide-27
SLIDE 27

OpenGL 4.0/3.3 Tesselation Ti i Timer queries Double precision floating point p g p Etc. O GL 3 3 f tibilit ith ld OpenGL 3.3: for compatibility with older hardware

Vienna University of Technology 27

slide-28
SLIDE 28

OpenGL ES For embedded systems R d d i t ti t Reduced instruction set Developers love it  p OpenGL 4.1 is backwards compatible with OpenGL ES! OpenGL ES!

Vienna University of Technology 28

slide-29
SLIDE 29

OpenGL Architecture Symmetric geometry and image paths O ti i d d t (“ th l”) Operations independent (“orthogonal”)

Unpack Pixels Pixel Operations Image Rasterization Pack Texture Fragment Image Pack Pixels Memory Operations Point, Line, Polygon Rasterization Unpack Vertexes Vertex Operations Frame Buffer Geometry

Vienna University of Technology 29

Rasterization

slide-30
SLIDE 30

Typical OpenGL Block Diagram

Vienna University of Technology 30

slide-31
SLIDE 31

They match!

Application Command Geometry Rasterization Rasterization Texture Fragment Display

Vienna University of Technology 31