Ciril Bohak. - INTRODUCTION TO WEBGL

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.

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

Rendering Objects. Need to transform all geometry then

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

Rasterization Overview

Models and Architectures

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

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

The Graphics Pipeline

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

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

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

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

Introduction to Computer Graphics with WebGL

Graphics Hardware. Instructor Stephen J. Guy

Rasterization-based pipeline

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

CHAPTER 1 Graphics Systems and Models 3

CS 4620 Program 3: Pipeline

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

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

Spring 2009 Prof. Hyesoon Kim

Lecture 2. Shaders, GLSL and GPGPU

Spring 2011 Prof. Hyesoon Kim

Shaders. Slide credit to Prof. Zwicker

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

CS770/870 Fall 2015 Advanced 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

GPU Memory Model. Adapted from:

E.Order of Operations

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

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

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

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

CS4620/5620: Lecture 14 Pipeline

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

Dave Shreiner, ARM March 2009

2.11 Particle Systems

1.2.3 The Graphics Hardware Pipeline

Graphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal

Pipeline Operations. CS 4620 Lecture 14

BCA611 Video Oyunları için 3B Grafik

Scanline Rendering 2 1/42

Lecture 13: OpenGL Shading Language (GLSL)

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

COMP371 COMPUTER GRAPHICS

Computer Graphics Seminar

CS4621/5621 Fall Computer Graphics Practicum Intro to OpenGL/GLSL

Graphics Pipeline 2D Geometric Transformations

CS451Real-time Rendering Pipeline

OPENGL RENDERING PIPELINE

Introduction to Shaders.

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

OpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

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

The Rendering Pipeline (1)

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

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

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

Copyright Khronos Group, Page Graphic Remedy. All Rights Reserved

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL

Introduction to 2D Graphics

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

We assume that you are familiar with the following:

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

Visual HTML5. Human Information Interaction for Knowledge Extraction, Interaction, Utilization, Decision making HI-I-KEIUD

CS475/CS675 - Computer Graphics. OpenGL Drawing

CS452/552; EE465/505. Clipping & Scan Conversion

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

CSE4030 Introduction to Computer Graphics

The Graphics Pipeline

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

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

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

OpenGL on Android. Lecture 7. Android and Low-level Optimizations Summer School. 27 July 2015

The Graphics Pipeline

TSBK03 Screen-Space Ambient Occlusion

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

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

Chapter Answers. Appendix A. Chapter 1. This appendix provides answers to all of the book s chapter review questions.

Real-Time Reyes: Programmable Pipelines and Research Challenges. Anjul Patney University of California, Davis

Computer Graphics - Treasure Hunter

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

The Graphics Pipeline and OpenGL I: Transformations!

Graphics Hardware. Graphics Processing Unit (GPU) is a Subsidiary hardware. With massively multi-threaded many-core. Dedicated to 2D and 3D graphics

CS 354R: Computer Game Technology

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

CS 130 Final. Fall 2015

Beginning Direct3D Game Programming: 1. The History of Direct3D Graphics

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

Computer graphics 2: Graduate seminar in computational aesthetics

The Graphics Pipeline and OpenGL I: Transformations!

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

Case 1:17-cv SLR Document 1-3 Filed 01/23/17 Page 1 of 33 PageID #: 60 EXHIBIT C

Introduction to OpenGL. CS 4620 Balazs Kovacs, 2014 Daniel Schroeder, 2013 Pramook Khungurn, 2012

Adaptive Point Cloud Rendering

Free Downloads OpenGL ES 3.0 Programming Guide

Getting fancy with texture mapping (Part 2) CS559 Spring Apr 2017

Transcription:

2016 Ciril Bohak ciril.bohak@fri.uni-lj.si - INTRODUCTION TO WEBGL

What is WebGL? WebGL (Web Graphics Library) is an implementation of OpenGL interface for cmmunication with graphical hardware, intended for use in web browsers. Independant of hardware: same code runns on all the graphical hardware independant of the manufacturer. Independant of the platform: same code for interactive graphics runns on many patforms: Linux, Mac, Windows,» 200 instructions instructions are intended for drawing interactive 3D graphics. 2

What WebGL is not? It does not have support for: UI implementation and interaction; use interaction (keyboard, mouse, ); it uses JavaScript libraries for this. It does not have instructions for: description of 3D objects; it only supports a small set of graphics primitives: dots, lines, polygons 3

WebGL General structure of simple program: initialization of OpenGL context: OpenGL context is part of HTML5 canvas, we obtain the context from the canvas. initialization of OpenGL parameters view definition, initialization of shaders, main program loop (when we use single thread): 1. clear the screen 2. draw 3D scene 3. process I/O devices 4. refresh the context See 00-introduction and 01-polygons 4

WebGL and web browsers Support in most modern browsers: Chrome, Firefox, IE, Safari, Opera, Edge support is implemented in different manner on different systems: Through OpenGL, Direct3D, Direct X, Support on mobile devices: mobile browsers support WebGL: Android Browser, Chrome, Firefox, ios, WebOS, IE, WebGL is winner in battle with Java Applets and Flash Player for 3D rendering on web. 5

OpenGL pipeline Vertex shader Vertex data uniforms array of verices array of indices (textures, variables) [1, 2, 3], [3, 2, 4], [4, 2, 7], [7, 2, 5],... vertex shader Basic vertex positions assembling triangles Rasterization rasterization Display pixels Fragment shader fragment shader Pixel color, depth,... Framebuffer operations (depth test, blending, ) Texturing and blending WebGL Framebuffer framebuffer 6

Polygons Each polygon has two sites: back and front side; OpenGL can draw each side differently; order of veritces defines which side is front side and which side is back side; when we look at the front side, the order of vertices is counter clockwise: right hand rule righthanded coordinate system; we can also change the orientation of polygons. clockwise counter clockwise 7

Transformations Basis for meaningful drawing represent basic transformations: translation; scaling; rotation; projection. Execution of transformation is performed in vertex shader. Developer must take care for appropriate transformations and their chaining, as well as storring (e.g. transformation stack). 8

Transformations Transformation chaining: matrix multiplication: right most matrix represent first transformation. Typical structure of three transformation: TRS translation * rotation * scale ( * point ) 9

Transformations Point v ocs of object O is in the origin of world coordinate system. It represents local coordinate system (c.s.); we can move the point in desired place in the world by model transformation, typicaly TRS: v wcs = (T R S) v ocs ; cammera is at location p and has its own coordinate system; transformation of v wcs into view coordiante system is performed by view transformation: v vcs = (T R ) v wcs. 10

Transformation Projection transformation transforms point v vcs into projected coordinates. We also define how to cut the projection plane and normalization of the coordinates in range of (-1, -1) and (1, 1) : v pcs = Pv vcs. Transformation into viewport transforms normalized coordinates into viewport of the application window: Z-Buffer (z coordinate of vertice) is used to define which points will be drawn; v ndcs = Nv pcs. 11

Transformations (TRS) z y y O OCS x y x z z O WCS (TR) z y O VCS (P) x (N) O NDCS x Računalniška grafika in tehnologija iger - WebGL 12

How are things in WebGL? Geometry we define geometry with float arrays in JavaScript and transfer them onto GPU with use of VBOs (vertex buffered objects), we can read the geometry from the files; in case when geometry is changing we change it in JavaScript and refresh VBO structures on GPU. Transformations matrix stack is implemented in JavaScript; transformation matrices are sent into shaders via input variables (uniforms); every time, when view changes we have to refresh appropriate uniforms. 13

Vertex shader With vertex shader we can implement the functionality of graphics pipeline for processing vertices: vertex transformation; color transformation; lighting (light definition); generation of texture coordiantes for mappint textures 14

Fragment shader With fragment shaderjem we can implement the functionality of graphics pipeline for fragment processing: fragments can be smaller than pixesl or can contain multiple pixels; calculation color and texturing for individual fragment; multi texturing; special effects (fog, blur, ); normal calculation for individual fragment; With multiple pass we can achieve additional special effects (blending, motion blur, ) Values can be transferred between shaders through the variables which are interpolated for individual fragment. 15

Other shaders (not in WebGL) Tessellation shader shader, intended for procedural subdivision of individual surfaces for achieving higher detail of the models; it consists of two faces: Tessellation Control to what degree should tessellation be calculated; Tessellation Evaluation calculates actual positions of vertices according to the calculated pattern. Geometry shader shader, which allows procedural generation of geometry on the GPU; it is executed after the vertex shader in the pipeline and after tessellation shader if it exists; inputs are individual primitives, output are 0 or more instances of input primitives. 16