Converts geometric primitives into images Is split into several independent stages Those are usually executed concurrently

Similar documents
WebGL: Hands On. DevCon5 NYC Kenneth Russell Software Engineer, Google, Inc. Chair, WebGL Working Group

CPSC 436D Video Game Programming

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

Models and Architectures

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015

The Graphics Pipeline

The Graphics Pipeline

Introduction to OpenGL/GLSL and WebGL GLSL

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Rasterization Overview

Introduction to Computer Graphics with WebGL

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

COMP371 COMPUTER GRAPHICS

Practical Texturing (WebGL) CS559 Fall 2016 Lecture 20 November 7th 2016

Lecture 2. Shaders, GLSL and GPGPU

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

OPENGL RENDERING PIPELINE

Introduction to Shaders.

WebGL. Creating Interactive Content with WebGL. Media #WWDC14. Session 509 Dean Jackson and Brady Eidson WebKit Engineers

Copyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012

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

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation

Rendering Objects. Need to transform all geometry then

Mobile Application Programing: Android. OpenGL Operation

CSE 167: Introduction to Computer Graphics Lecture #7: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Graphics Programming. Computer Graphics, VT 2016 Lecture 2, Chapter 2. Fredrik Nysjö Centre for Image analysis Uppsala University

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system

Supplement to Lecture 22

Shadows. Prof. George Wolberg Dept. of Computer Science City College of New York

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

CS 380 Introduction to Computer Graphics. LAB (1) : OpenGL Tutorial Reference : Foundations of 3D Computer Graphics, Steven J.

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017

CS452/552; EE465/505. Image Formation

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

Spring 2009 Prof. Hyesoon Kim

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

Programming shaders & GPUs Christian Miller CS Fall 2011

Mobile Application Programing: Android. OpenGL Operation

Spring 2011 Prof. Hyesoon Kim

OpenGL shaders and programming models that provide object persistence

SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming

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

Geometry Shaders. And how to use them

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

The Graphics Pipeline

CS452/552; EE465/505. Image Processing Frame Buffer Objects

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

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

Shaders. Slide credit to Prof. Zwicker

Programming with OpenGL Part 3: Shaders. Ed Angel Professor of Emeritus of Computer Science University of New Mexico

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

Ciril Bohak. - INTRODUCTION TO WEBGL

CS 432 Interactive Computer Graphics

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL

Game Graphics & Real-time Rendering

CS451Real-time Rendering Pipeline

The Transition from RenderMan to the OpenGL Shading Language (GLSL)

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

- Rasterization. Geometry. Scan Conversion. Rasterization

Introduction to Computer Graphics. Hardware Acceleration Review

OpenGL pipeline Evolution and OpenGL Shading Language (GLSL) Part 2/3 Vertex and Fragment Shaders

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples

Dave Shreiner, ARM March 2009

Web-Based Visualization

Lecture 11 Shaders and WebGL. October 8, 2015

Today. Rendering - III. Outline. Texturing: The 10,000m View. Texture Coordinates. Specifying Texture Coordinates in GL

Shaders (some slides taken from David M. course)

The Application Stage. The Game Loop, Resource Management and Renderer Design

Graphics Pipeline & APIs

Understanding M3G 2.0 and its Effect on Producing Exceptional 3D Java-Based Graphics. Sean Ellis Consultant Graphics Engineer ARM, Maidenhead

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

Sign up for crits! Announcments

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

2D graphics with WebGL

E.Order of Operations

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

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

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

CS475/CS675 - Computer Graphics. OpenGL Drawing

Graphics Hardware. Instructor Stephen J. Guy

Shader Programming 1. Examples. Vertex displacement mapping. Daniel Wesslén 1. Post-processing, animated procedural textures

Drawing Fast The Graphics Pipeline

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 4: Three Dimensions

OpenGL Programmable Shaders

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

Mobile Application Programming: Android. OpenGL Operation

The Rasterization Pipeline

PROFESSIONAL. WebGL Programming DEVELOPING 3D GRAPHICS FOR THE WEB. Andreas Anyuru WILEY. John Wiley & Sons, Ltd.

Hardware- Software Co-design at Arm GPUs

CS4620/5620: Lecture 14 Pipeline

CS 130 Exam I. Fall 2015

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

1.2.3 The Graphics Hardware Pipeline

Advanced Lighting Techniques Due: Monday November 2 at 10pm

Graphics Pipeline & APIs

We assume that you are familiar with the following:

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

Transcription:

Rendering Pipeline

Rendering Pipeline Converts geometric primitives into images Is split into several independent stages Those are usually executed concurrently Pipeline 18.10.2013 Steiner- Wallner- Podaras 2

The real pipeline 18.10.2013 Steiner- Wallner- Podaras 3

OpenGL Pipeline Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transformation Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 4

Let s draw a triangle Step One: Transform vertices Call vertex shader for each vertex Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 5

Let s draw a triangle Step Two: Primitive Assembly Collect vertices to build a primitive Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 6

Let s draw a triangle Step Three: Polygon Clipping Remove all parts outside of the screen Interpolate new points Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 7

Let s draw a triangle Step Four: Homogenization Apply perspective division Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 8

Let s draw a triangle Step Five: Viewport Transform Convert screen coordinates to pixel positions Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 9

Let s draw a triangle Step Five: Viewport Transform Convert screen coordinates to pixel positions Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 10

Let s draw a triangle Step Six: Rasterization Find pixels inside primitive Call fragment shader for each pixel Set pixel color to fragment shader result Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 11

Let s draw a triangle Step Seven: Z-Test Compare depth before storing pixel color Vertex Processing Primitive Assembly Polygon Clipping Homogenization Viewport Transform. Rasterization Fragment Processing Depth Test 18.10.2013 Steiner- Wallner- Podaras 12

Depth Buffering Draw result depend on order of render calls Blue - > Red - > Green Green - > Red - > Blue 18.10.2013 Steiner- Wallner- Podaras 13

Depth Buffering Draw result depend on order of render calls Blue - > Red - > Green Green - > Red - > Blue BeKer: Order polygons by their depth 18.10.2013 Steiner- Wallner- Podaras 14

Depth Buffer AddiPonal Screen- Buffer that stores depth values Write pixel only when new depth is smaller than stored depth Need to enable and clear depth buffer too gl.enable(gl.depth_test); gl.clear(gl.color_buffer_bit gl.depth_buffer_bit); 18.10.2013 Steiner- Wallner- Podaras 15

Shader Small C- like programs executed on the graphics- hardware Replace fixed funcpon (OpenGL < 3.0) pipeline with shaders Shader- Types Vertex Shader Fragment Shader Geometry Shader, TessellaPon Shader, Compute Shader Used e.g. for transformapons and lighpng 18.10.2013 Steiner- Wallner- Podaras 16

Shader Vertex Processing Vertex Shader Primitive Assembly Polygon Clipping Homogenization varyings Viewport Transformation Rasterization Fragment Processing Fragment Shader Depth Test 18.10.2013 Steiner- Wallner- Podaras 17

Shader Vertex Processing Primitive Assembly Vertex Shader Geometry Shader Polygon Clipping Homogenization Viewport Transformation Rasterization Fragment Processing Fragment Shader Depth Test 18.10.2013 Steiner- Wallner- Podaras 18

Shader Vertex Shader Called once for each vertex Fragment Shader Called once for each pixel inside a surface 18.10.2013 Steiner- Wallner- Podaras 19

AKributes/Varyings Draw Call Vertex Shader attribute vec3 position attribute vec2 uv varying vec2 fragmentuv gl_position Fragment Shader gl_fragcolor Draw Buffer 18.10.2013 Steiner- Wallner- Podaras 20

AKributes/Varyings Pass data from one shader/pipeline stage to the next A>ribute: from Draw Call to Vertex Shader Varying: from Vertex Shader to Fragment Shader from Fragment Shader to Draw Buffer Global variables with varying/attribute qualifier Correct interpoladon between stages 18.10.2013 Steiner- Wallner- Podaras 21

Parameter interpolapon // vertex shader varying vec2 fragmentuv; //... InterpolaDon // fragment shader varying vec2 fragmentuv; //... 18.10.2013 Steiner- Wallner- Podaras 22

Our first shader Vertex Shader Takes akributes from draw call Should set gl_position attribute vec4 position; void main() { gl_position = position; } 18.10.2013 Steiner- Wallner- Podaras 23

Our first shader Fragment Shader Takes interpolated varyings Should write to gl_fragcolor precision mediump float; void main() { gl_fragcolor = vec4(0.6, 0.85, 0.95, 1.0); } 18.10.2013 Steiner- Wallner- Podaras 24

Shader execupon model Shader- Source- Code OpenGL- API ApplicaDon OpenGL- Driver Compiler Shader- Object compiled code Linker Program- Object Graphics- Hardware executable code 18.10.2013 Steiner- Wallner- Podaras 25

Lets start with some code Send HTTP GET Request to load shader file request.open('get', path); request.onreadystatechange = function() { if (request.readystate === this.done) { if (request.status === 200) { callback(request.responsetext); } else { //Error Handling } } }; request.send(); 18.10.2013 Steiner- Wallner- Podaras 26

Shader Loading Generate shader object var shader = gl.createshader(type); Type can be gl.vertex_shader or gl.fragment_shader Upload code to shader object gl.shadersource(shader, src); 18.10.2013 Steiner- Wallner- Podaras 27

Shader Compiling Compile shader gl.compileshader(shader); And test for errors if (!gl.getshaderparameter(shader, gl.compile_status)) { //Handle errors } 18.10.2013 Steiner- Wallner- Podaras 28

Shader Program CombinaPon of Vertex and Fragment Shader Object program = gl.createprogram(); AKach Shader Objects gl.attachshader(program, vertexshader); gl.attachshader(program, fragmentshader); 18.10.2013 Steiner- Wallner- Podaras 29

Shader Linking Link shader program aher akaching shaders gl.linkprogram(program); And check for errors if (!gl.getprogramparameter(program, gl.link_status)) { var infolog = gl.getprograminfolog(program); } 18.10.2013 Steiner- Wallner- Podaras 30

Webserver HTTP Request can only be handled by Server Accessing Textures etc. not possible on local machine due to security reasons. Python provides you with an simple HTTP Server $ python - m SimpleHTTPServer [PORT] 18.10.2013 Steiner- Wallner- Podaras 31

Webserver Access Server http://127.0.0.1:8000 A>enDon: Webserver could cache files! 18.10.2013 Steiner- Wallner- Podaras 32

Big DEMO Time! 18.10.2013 Steiner- Wallner- Podaras 33

Big DEMO Time! Don t try this at home 18.10.2013 34