Rasterization-based pipeline

Similar documents
WebGL (Web Graphics Library) is the new standard for 3D graphics on the Web, designed for rendering 2D graphics and interactive 3D graphics.

Comp4422. Computer Graphics. Lab 02: WebGL API Prof. George Baciu. PQ838 x7272.

BCA611 Video Oyunları için 3B Grafik

Introduction to OpenGL/GLSL and WebGL GLSL

Ciril Bohak. - INTRODUCTION TO WEBGL

WebGL A quick introduction. J. Madeira V. 0.2 September 2017

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

WebGL. Announcements. WebGL for Graphics Developers. WebGL for Web Developers. Homework 5 due Monday, 04/16. Final on Tuesday, 05/01

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

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

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

OpenGL shaders and programming models that provide object persistence

Programming with OpenGL Complete Programs Objectives Build a complete first program

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

CS452/552; EE465/505. Image Formation

CS452/552; EE465/505. Overview of Computer Graphics

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

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

Programming with WebGL Part 1: Background. CS 432 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Objectives. Programming with WebGL Part 1: Background. Retained vs. Immediate Mode Graphics. Early History of APIs. PHIGS and X.

COMP371 COMPUTER GRAPHICS

Mining the Rendering Power in Web Browsers. Jianxia Xue Jan. 28, 2014

OPENGL RENDERING PIPELINE

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

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

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Dave Shreiner, ARM March 2009

Rendering Objects. Need to transform all geometry then

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

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

Introduction to Computer Graphics with WebGL

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

Models and Architectures

Pipeline Operations. CS 4620 Lecture 14

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

I Can t Believe It s Not

Water Simulation on WebGL and Three.js

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

WebGL Seminar: O3D. Alexander Lokhman Tampere University of Technology

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

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

Graphics Hardware. Instructor Stephen J. Guy

Introduction to Computer Graphics with WebGL

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

CS452/552; EE465/505. Shadow Mapping in WebGL

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

Introduction to Computer Graphics with WebGL

We assume that you are familiar with the following:

CPSC 436D Video Game Programming

WebGL. WebGL. Bring 3D to the Masses. WebGL. The web has text, images, and video. We want to support. Put it in on a webpage

CS 464 Review. Review of Computer Graphics for Final Exam

Computer Science 175. Introduction to Computer Graphics lib175 time: m/w 2:30-4:00 pm place:md g125 section times: tba

Lecture 2. Shaders, GLSL and GPGPU

CSE4030 Introduction to Computer Graphics

Computer Graphics Lecture 2

I expect to interact in class with the students, so I expect students to be engaged. (no laptops, smartphones,...) (fig)

CS770/870 Fall 2015 Advanced GLSL

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

Module 13C: Using The 3D Graphics APIs OpenGL ES

Computer Graphics (CS 4731) OpenGL/GLUT(Part 1)

Lecture 13: OpenGL Shading Language (GLSL)

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

CS452/552; EE465/505. Review & Examples

Introduction to Shaders.

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Lecture 11 Shaders and WebGL. October 8, 2015

Line Drawing. Foundations of Computer Graphics Torsten Möller

Shaders. Slide credit to Prof. Zwicker

CS475/CS675 - Computer Graphics. OpenGL Drawing

COPYRIGHTED MATERIAL. 1Introducing WebGL THE BASICS OF WEBGL

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

Understanding Shaders and WebGL. Chris Dalton & Olli Etuaho

The Rasterization Pipeline

Shaders (some slides taken from David M. course)

Introduction to OpenGL ES 3.0

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

Qiufeng Zhu Advanced User Interface Spring 2017

The Graphics Pipeline

CMT315 - Computer Graphics & Visual Computing

2.11 Particle Systems

Get your port on! porting to Native Client as of Pepper 18. Colt "MainRoach" McAnlis

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

SpiderGL. A JavaScript 3D Graphics for Next-Generation WWW. Visual Computing Lab ISTI CNR. Marco Di Benedetto

Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer Graphics

REALISTIC RENDERING IN WEBGL

Introductory Seminar

Drawing Fast The Graphics Pipeline

last time put back pipeline figure today will be very codey OpenGL API library of routines to control graphics calls to compile and load shaders

Free Downloads OpenGL ES 3.0 Programming Guide

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

Massively Parallel Non- Convex Optimization on the GPU Through the Graphics Pipeline

Spring 2009 Prof. Hyesoon Kim

CS427 Multicore Architecture and Parallel Computing

OpenGL BOF Siggraph 2011

Lecture 1. Computer Graphics and Systems. Tuesday, January 15, 13

White Paper. Solid Wireframe. February 2007 WP _v01

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

CISC 3620 Lecture 7 Lighting and shading. Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping

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

Transcription:

Rasterization-based pipeline Interactive Graphics: Color and Images 10/2/2014 Pagina 1

Rasterization-based rendering Input: set of vertices and its associated attributes Algorithm goes through several phases: 1. Per-vertex transformations and attributes setup 2. Primitive processing 3. Rasterization 4. Per-fragment computation Interactive Graphics: Color and Images 10/2/2014 Pagina 2

Advantages of ray tracing Conceptually simple algorithm Takes into account GLOBAL effects More realistic rendering of lighting effects Interactive Graphics: Color and Images 10/2/2014 Pagina 3

Advantages of rasterization More easily parallelizable More controllable complexity Better-suited for graphics cards Better treatment of anti-aliasing (more later on) Interactive Graphics: Color and Images 10/2/2014 Pagina 4

First Steps Interactive Graphics Course Prof. Marco Schaerf Dept. of Computer, Systems and Management Science (DIAG) Sapienza University of Rome marco.schaerf@uniroma1.it Pagina 5

Outline Goal: Create an HTML page with WebGL JavaScript code in it To accomplish it we need to (briefly) introduce: OpenGL and WebGL API WebGL rasterization-based pipeline Programming the rendering pipeline WebGL Supporting Libraries (in particular, SpiderGL) envymycar framework and Class NVMC Pagina 6

Application Programming Interface In order to write 3D graphic programs we will use a predefined and standardized 3D API WebGL WebGL is based on OpenGL, an open standard widely used for real-time (interactive) graphics and now mantained by the Khronos group. Almost all of the graphic cards support and accelerate the OpenGL API (and indirectly also WebGL) WebGL runs in a browser using JavaScript, it does not require ad-hoc programming tools. Most browsers support WebGL, including Firefox, Chrome, Safari and Opera Pagina 7

WebGL pipeline: Image Pagina 8

WebGL pipeline Vertex Puller (VP) Vertex Shader (VS) Written in GLSL (OpenGL Shading Language) Primitive Assembler (PA) Rasterizer (RS) Fragment Shader (FS) Written in GLSL (OpenGL Shading Language) Output Combiner (OC) FrameBuffer Operations (FO) Pagina 9

First Rendering We need to: 1. Define the HTML page containing our program 2. Initialize WebGL 3. Define what to draw 4. Define how to draw 5. Perform the actual drawing Pagina 10

HTML Page <html> <head> <script type="text/javascript"> </script> </head> <body> <canvas id = "OUTPUT-CANVAS" width = "500px" height = "500px" style = "border: 1px solid black" ></canvas> </body> </html> Pagina 11

Skeleton Code <script type="text/javascript"> // global variables function setupwebgl() {} function setupwhattodraw() {} function setuphowtodraw() {} function draw() {} function hellodraw() { setupwebgl(); setupwhattodraw(); setuphowtodraw(); draw(); } window.onload = hellodraw; </script> Pagina 12

Initialize WebGL 1/2 WebGL is a state machine where the outcome of every operation depends on the internal state of the machine. In OpenGL the state (called the rendering context) is implicit, while in WebGL is stored in a JavaScript object WebGLRenderingContext, which is tied to an HTMLCanvasElement used as an output var gl = null; function setupwebgl() { var canvas = document.getelementbyid("output-canvas"); gl = canvas.getcontext("experimental-webgl"); } Pagina 13

Initialize WebGL 2/2 Associate the canvas variable to the HTML canvas defined in the html source of the page Canvases contain a 4-channels RGBA framebuffer and a depth buffer. The framebuffer Alpha channel is used as a transparency value The method getcontext returns the WebGL context, webgl is the string denoting it in most browsers (in some cases you need to use experimental-webgl Note that the name used for all (and only) the WebGL variables will start with gl Pagina 14

Define what to draw 1/4 WebGL is designed to take advantage of graphic cards Most data structures MUST be mirrored with corresponding ones provided by the API As an example, we define a 2D triangle by using real coordinatse from -1 to 1 Pagina 15

Define what to draw 2/4 Pagina 16

Define what to draw 3/4 More efficient form allows for less redundacy, but is less intuitive and structured var positions = [ 0.0, 0.0, // 1st vertex 1.0, 0.0, // 2nd vertex 0.0, 1.0 // 3rd vertex ]; Pagina 17

Define what to draw 4/4 var typedpositions = new Float32Array(positions); Or alternatively we could have filled the native array directly var typedpositions = new Float32Array(6); // 6 floats typedpositions[0] = 0.0; typedpositions[1] = 0.0; typedpositions[2] = 1.0; typedpositions[3] = 0.0; typedpositions[4] = 0.0; typedpositions[5] = 1.0; We mirror this data and encapsulate it in WebGL object var positionsbuffer = gl.createbuffer(); gl.bindbuffer(gl.array_buffer, positionsbuffer); gl.bufferdata(gl.array_buffer, typedpositions, gl.static_draw); STATIC_DRAW specifies that we expect this object to be accessed many times but rarely changed Pagina 18