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

Rendering Pipeline/ OpenGL

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

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

Programming using OpenGL: A first Introduction

Computer graphics MN1

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

Computer Graphics Programming

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

Lectures OpenGL Introduction

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

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

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

Graphics and Computation Introduction to OpenGL

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

E.Order of Operations

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

Introduction to Computer Graphics with WebGL

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

Luiz Fernando Martha André Pereira

CSC 8470 Computer Graphics. What is Computer Graphics?

COMP 371/4 Computer Graphics Week 1

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Introduction to Shaders.

Introduction to OpenGL

CS 4204 Computer Graphics

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

Computer Graphics, Chapt 08

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Models and Architectures

Introduction to Computer Graphics with OpenGL/GLUT

Graphics Processing Unit Architecture (GPU Arch)

Computer Graphics. Bing-Yu Chen National Taiwan University

RECITATION - 1. Ceng477 Fall

An Interactive Introduction to OpenGL Programming

Computer Graphics. OpenGL

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

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

OpenGL refresher. Advanced Computer Graphics 2012

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

Computer Graphics. Bing-Yu Chen National Taiwan University

Lecture 2. Shaders, GLSL and GPGPU

Graphics Programming

Programming with OpenGL Part 1: Background

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

Basic Graphics Programming

CSE4030 Introduction to Computer Graphics

Basic Graphics Programming

Programming of Graphics

Rasterization Overview

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

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

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

Exercise 1 Introduction to OpenGL

CHAPTER 1 Graphics Systems and Models 3

CS4620/5620: Lecture 14 Pipeline

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

Programming with OpenGL Part 1: Background

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

Introduction to OpenGL

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

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

CS 591B Lecture 9: The OpenGL Rendering Pipeline

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

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

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

Introduction to OpenGL

Computer graphic -- Programming with OpenGL I

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

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

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

Rendering. Part 1 An introduction to OpenGL

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

Introduction to OpenGL

Visualizing Molecular Dynamics

Transformation Pipeline

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

3D Graphics and OpenGl. First Steps

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

Computer Graphics 1 Computer Graphics 1

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

World Coordinate System

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

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

Transcription:

3 2 4 Graphics Pipeline & APIs CPU Vertex Processing Rasterization 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 (); attributed geometry - Database Traversal Hidden-Lines and Surfaces Model Transform Perspective Projection Pre-Sorting Scan Conversion Viewing Transform 3D Clipping image -pixels Lighting, Shading, Texturing 1. Graphics APIs 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 1. Graphics APIs Vertices Pixels Application Storage Processor Rasterizer Processor Frame buffer Texture Storage + Filtering CPU GPU

5 7 8 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.. Processor Evaluation of polynomials for curved surfaces Transformation and projection Vertex Modelview Matrix Projection Matrix Perspective Divison Viewport Transform Modelview Projection Modelview Storage Command buffering Command interpretation Unpack and perform format conversion Maintain graphics state 6 Processor (2) Evaluation of polynomials for curved surfaces Transformation and projection Clipping, culling, and primitive assembly

Processor (3) Evaluation of polynomials for curved surfaces Transformation and projection Clipping, culling, and primitive assembly Lighting Texture coordinate generation transform 9 object-space triangles screen-space lit triangles Rasterization (2) Separate rule for each primitive Non-ambiguous! Polygons: Pixel center contained in polygon On-edge pixels only one is rasterized 11 Rasterization Setup (per-triangle) Sampling (triangle = {fragments}) Interpolation (interpolate colors and coordinates) screen-space lit triangles fragments 10 Texture Texture transformation and projection Texture address calculation Texture filtering fragments texture fragments 12

Texture (2) Texture combiners texture fragments textured fragments 13 fragments 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 - Processing Texture combiners and fog Owner, scissor, depth, alpha, stencil tests Blending or compositing Dithering and logical operations textured fragments Framebuffer pixels 14 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 Storage Vertex Processing Rasterization Rasterization Texture Processing 17 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 (); 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 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 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., DirectX (D3D), Postscript More direct control 20 Graphics APIs

(Open Graphics Library) Initially defined by Silicon Graphics Inc. http://www.opengl.org/ http://www.sgi.com/software/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 A 2D 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(); } 21 23 (2) 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 Integration gl.lib: main library glu.lib: utilities supports NURBS, complex polygons, quadric shapes, etc. glut.lib: toolkit simplifies & abstracts window handling windowed application program GLU draw GLUT windowing system events events 22 24

Basics 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 lists to optimize performance glnewlist(<id>, GL_COMPILE); Caching of graphics commands Geometric Primitives glbegin(x); X: GL_POINTS, GL_LINES, GL_POLYGON, GL_TRIANGLES, GL_QUADS, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, glend(); 25 27 Data Flow Image Unpack pixels Pixel operations Image rasterization lists Texture memory operations to framebuffer Unpack vertices Vertex operations Geometric rasterization [ fragment = pixel ] 26 Rendering Features Materials & colors Texture mapping Texture animation MipMaps Advanced shading and lighting Fog Antialiasing Framebuffer Ops 28

A 3D 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 glmatrixmode(gl_projection); Transforms 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(); 29 Extensions Enables access to hardware-specific features Specified by3d video card manufacturers & vendors Extensions defined in glext.h Extensions have manufacturer s postfix, e.g. ARB = official extensions by Architectural Review Board EXT = agreed upon by multiple vendors SGI = Silicon Graphics NV = nvidia Corporation Examples: glenable(gl_vertex_program_nv) glloadprogramnv() 30