Graphics Pipeline & APIs

Similar documents
Graphics Pipeline & APIs

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

OpenGL. Toolkits.

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Computer graphics MN1

Precept 2 Aleksey Boyko February 18, 2011

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Lecture 4 of 41. Lab 1a: OpenGL Basics

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL

Rendering Pipeline/ OpenGL

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Programming using OpenGL: A first Introduction

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

Computer graphics MN1

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Lectures OpenGL Introduction

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

CS450/550. Pipeline Architecture. Adapted From: Angel and Shreiner: Interactive Computer Graphics6E Addison-Wesley 2012

Computer Graphics Programming

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Graphics and Computation Introduction to OpenGL

E.Order of Operations

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

Luiz Fernando Martha André Pereira

CSC 8470 Computer Graphics. What is Computer Graphics?

Introduction to Shaders.

Models and Architectures

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Introduction to OpenGL

COMP 371/4 Computer Graphics Week 1

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Introduction to Computer Graphics with WebGL

CS 4204 Computer Graphics

Computer Graphics, Chapt 08

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Graphics Processing Unit Architecture (GPU Arch)

Introduction to Computer Graphics with OpenGL/GLUT

Computer Graphics. Bing-Yu Chen National Taiwan University

RECITATION - 1. Ceng477 Fall

An Interactive Introduction to OpenGL Programming

Lecture 2. Shaders, GLSL and GPGPU

Computer Graphics. OpenGL

OpenGL refresher. Advanced Computer Graphics 2012

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Graphics Programming

Lectures Transparency Case Study

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

Cheating: In case of cheating, all parts involved (source(s) and receiver(s)) get zero.

Rasterization Overview

Computer Graphics. Bing-Yu Chen National Taiwan University

CS130 : Computer Graphics. Tamar Shinar Computer Science & Engineering UC Riverside

CSE4030 Introduction to Computer Graphics

Basic Graphics Programming

Programming with OpenGL Part 1: Background

Programming of Graphics

Basic Graphics Programming

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Graphics Hardware. Instructor Stephen J. Guy

Exercise 1 Introduction to OpenGL

Introduction to OpenGL

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

CHAPTER 1 Graphics Systems and Models 3

Programming with OpenGL Part 1: Background

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

CS 591B Lecture 9: The OpenGL Rendering Pipeline

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Computer Graphics. Chapter 10 Three-Dimensional Viewing

20 Years of OpenGL. Kurt Akeley. Copyright Khronos Group, Page 1

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

CS4620/5620: Lecture 14 Pipeline

Computer graphic -- Programming with OpenGL I

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

Introduction to OpenGL

3D Graphics and OpenGl. First Steps

Models and Architectures. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

cs123 Lab 3 OpenGL Part One 1 Introduction 2 OpenGL Basics 2.2 The Rendering Pipeline 2.1 The CPU and the GPU 2.3 Basic Syntax of OpenGL commands

Transformation Pipeline

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Rendering. Part 1 An introduction to OpenGL

CS 428: Fall Introduction to. OpenGL primer. Andrew Nealen, Rutgers, /13/2010 1

Visualizing Molecular Dynamics

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Introduction to OpenGL

Grafica Computazionale: Lezione 30. Grafica Computazionale. Hiding complexity... ;) Introduction to OpenGL. lezione30 Introduction to OpenGL

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

Computer Graphics 1 Computer Graphics 1

Transcription:

Graphics Pipeline & APIs CPU Vertex Processing Rasterization Fragment Processing glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front, GL_EMISSION, mat_zero); glmaterialfv(gl_front, GL_DIFFUSE, mat_solid); glcalllist (spherelist); glpopmatrix (); Display

One person prepares Xmas cards: Pipelines fold write pack fold write pack Three persons prepare Xmas cars: fold fold fold fold write write write pack pack Ideal: n stages speedup n Bottleneck: slowest stage Graphics: Bottleneck determines frames/s 2 1. Graphics APIs

attributed geometry - Database Traversal Model Transform Pre-Sorting Viewing Transform 3D Clipping Lighting, Shading, Texturing Hidden-Lines and Surfaces Perspective Projection Scan Conversion image -pixels 3 1. Graphics APIs

Vertices Pixels Application Geometry Storage Geometry Processor Rasterizer Fragment Processor Frame buffer Texture Storage + Filtering CPU GPU 4

Application Generate database Usually only once Load from disk Build acceleration structures (hierarchies, ) Database traversal Input event handlers Modify data structures Simulation Primitive generation (e.g. triangles) other functions.. 5

Geometry Storage Command buffering Command interpretation Unpack and perform format conversion Maintain graphics state 6

Geometry Processor Evaluation of polynomials for curved surfaces Transformation and projection Vertex Modelview Matrix Projection Matrix Perspective Divison Viewport Transform Modelview Projection Modelview 7

Geometry Processor (2) Evaluation of polynomials for curved surfaces Transformation and projection Clipping, culling, and primitive assembly 8

Geometry Processor (3) Evaluation of polynomials for curved surfaces Transformation and projection Clipping, culling, and primitive assembly Lighting Texture coordinate generation transform object-space triangles screen-space lit triangles 9

Rasterization Setup (per-triangle) Sampling (triangle = {fragments}) Interpolation (interpolate colors and coordinates) screen-space lit triangles fragments 10

Separate rule for each primitive Non-ambiguous! Polygons: Pixel center contained in polygon On-edge pixels only one is rasterized Rasterization (2) 11

Texture Texture transformation and projection Texture address calculation Texture filtering fragments texture fragments 12

Texture combiners texture fragments fragments Texture (2) textured fragments 13

Fragment - Processing Texture combiners and fog Owner, scissor, depth, alpha, stencil tests Blending or compositing Dithering and logical operations textured fragments Framebuffer pixels 14

Fragment Processing Diagram fragment and associated data pixel ownership test scissor test alpha test (RGBA only) depth test stencil test depth buffer stencil buffer blending (RGBA only) dithering logic op frame buffer frame buffer frame buffer 15

Display Frame buffer pixel format RGBA vs. indexed color Bits: 16-bit, 32-bit, 128-bit floating point Double buffer vs. single buffer Quad-buffer stereo Overlays (extra bit planes) Auxiliary buffers: alpha, stencil 16

Contemporary Graphics Pipeline CPU CPU Geometry Storage Geometry Vertex Processing Rasterization Rasterization Texture Fragment Fragment Processing Display Display 17

Contemporary Graphics Pipeline (2) Vertex Processing = per-vertex Transform & Lighting (T&L) Historically: hardwired complex operations (floating point) Today: programmable Brand new: flow control, soon: texture lookup 400 million vertices per second Fragment Processing = per-fragment Blending and texture combination Historically: fixed point and limited operations Today: programmable 4 billion fragments ( Gigapixel ) per second New: floating point, complex operations 18

Graphics Application Programming Interfaces (APIs) glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front, GL_EMISSION, mat_zero); glmaterialfv(gl_front, GL_DIFFUSE, mat_solid); glcalllist (spherelist); glpopmatrix ();

Graphics Libraries (API s) Give access to graphics hardware Declarative (what, not how) Describe the scene Scene Graph API (retained mode) e.g. SGI Open Inventor, SGI Performer, Renderman Imperative (how, not what) Sequence of drawing commands Immediate mode API e.g. OpenGL, DirectX (D3D), Postscript More direct control 20 Graphics APIs

OpenGL (Open Graphics Library) Initially defined by Silicon Graphics Inc. http://www.opengl.org/ http://www.sgi.com/software/opengl/ OpenGL Architectural Review Board (ARB) 3DLabs, Apple, ATI, Compaq, Evans&Sutherland, hp, IBM, Intel, Microsoft, nvidia, sgi, SUN Available on many platforms Windows NT/v4, Windows XP/2000/98/95 various UNIX (IRIX, Solaris, etc.) Linux (Debian, RedHat, SuSE, Caldera) Mac OS 8/9/X 21 OpenGL

Scales from PC to image engines Intuitive, procedural interface Versions 1.4 widespread 2.0 available since August 2004 Language bindings C, Java, Ada, Fortran, Perl, Python OpenGL (2) 22 OpenGL

A 2D OpenGL Example #include <GL\gl.h> #include <GL\glu.h> main() { OpenAWindow(); glclearcolor(0.0, 0.0, 0.0, 0.0); glclear(gl_color_buffer_bit); glortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glbegin(gl_polygon); glcolor3f(1.0, 0.0, 0.0); glvertex2f( 0.9, -0.9); glcolor3f(0.0, 1.0, 0.0); glvertex2f( 0.0, 0.9); glcolor3f(0.0, 0.0, 1.0); glvertex2f(-0.9, -0.9); glend(); glflush(); SomeMainLoop(); } 23 OpenGL

gl.lib: main library glu.lib: utilities supports NURBS, complex polygons, quadric shapes, etc. glut.lib: toolkit simplifies & abstracts window handling Integration windowed application program draw GLU events GLUT OpenGL events windowing system 24 OpenGL

Basics OpenGL is a state machine State encapsulates control for lighting, shading, texturing, etc. Current state affects transforms, color, lighting, shading, etc. Vertices and pixels are fundamental primitives Display lists to optimize performance glnewlist(<id>, GL_COMPILE); Caching of graphics commands 25 OpenGL

Image Unpack pixels Display lists Geometry Unpack vertices [ fragment = pixel ] Pixel operations Texture memory Vertex operations Data Flow Image rasterization Fragment operations to framebuffer Geometric rasterization 26 OpenGL

Geometric Primitives glbegin(x); X: GL_POINTS, GL_LINES, GL_POLYGON, GL_TRIANGLES, GL_QUADS, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, glend(); 27 OpenGL

Materials & colors Texture mapping Texture animation MipMaps Advanced shading and lighting Fog Antialiasing Framebuffer Ops Rendering Features 28 OpenGL

A 3D OpenGL Example glclearcolor(0.0, 0.0, 0.0, 0.0); GLfloat gray[] = {0.5, 0.5, 0.5, 1.0}; GLfloat white[] = {1.0, 1.0, 1.0, 1.0}; GLfloat ldir[] = {1.0, 1.0, 1.0, 0.0}; glenable(gl_lighting); glenable(gl_light0); gllightfv(gl_light0, GL_AMBIENT, gray); gllightfv(gl_light0, GL_DIFFUSE, white); gllightfv(gl_light0, GL_POSITION, ldir); glenable(gl_color_material); glenable(gl_depth_test); Lighting Transforms glmatrixmode(gl_projection); glloadidentity(); gluperspective(40, 1.0, 0.1, 10); // fovy, aspect, near, far glmatrixmode(gl_modelview); glloadidentity(); glulookat(0.0,0.0,2.0, 0.0,0.0,0.0, 0.0,1.0,0.0); // eye, center, up glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glcolor3f(0.5, 0.3, 0.3); glmatrixmode(gl_modelview); glpushmatrix(); glrotatef(30, 1.0, 1.0, 1.0); glutsolidteapot(0.5); glpopmatrix(); Geometry 29 OpenGL

OpenGL Extensions Enables access to hardware-specific features Specified by 3D video card manufacturers & OpenGL vendors Extensions defined in glext.h Extensions have manufacturer s postfix, e.g. ARB = official extensions by OpenGL Architectural Review Board EXT = agreed upon by multiple OpenGL vendors SGI = Silicon Graphics NV = nvidia Corporation Examples: glenable(gl_vertex_program_nv) glloadprogramnv() 30 OpenGL