به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92.

Slides:



Advertisements
Similar presentations
HTML Basics Customizing your site using the basics of HTML.
Advertisements

Visa-Valtteri visy Pimiä or how fumbling my way through pixel-based effects made learning WebGL a lot easier.
Iframes & Images Using HTML.
XHTML Basics.
An introduction to WebGL Viktor Kovács. Content A little 3D modeling. What is WebGL? Introducing Three.js. Visualizing GDL objects.
The Web Warrior Guide to Web Design Technologies
HTML 5. What is HTML5? HTML5 will be the new standard for HTML, XHTML, and the HTML DOM. The previous version of HTML came in The web has changed.
 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.
Intro to HTML Workshop. Welcome This slideshow presentation is designed to introduce you to the basics of HTML. It is the first of three HTML workshops.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
This course is designed to give you a basic introduction to the ins and outs of using tablet and smartphone technology. By and large, you will learn the.
Introduction to scripting
 Using Microsoft Expression Web you can: › Create Web pages and Web sites › Set what you site will look like as you design it › Add text, images, multimedia.
And Mobile Web Browsers
Michael Robertson Yuta Takayama. WebGL is OpenGL on a web browser. OpenGL is a low-level 3D graphics API Basically, WebGL is a 3D graphics API that generates.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
HTML 5 New Standardization of HTML. I NTRODUCTION HTML5 is The New HTML Standard, New Elements New Attributes Full CSS3 Support Video and Audio 2D/3D.
WebGL Patrick Cozzi University of Pennsylvania CIS Spring 2012.
Suleyman YILDIRIM.  Overview  Browser support  Scalability  Performance  Demos  Added value to the project.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
Mobile App Support Jacob Poirier Geri Hengesbach Andrea Menke Erin Rossell.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
CS 418: Interactive Computer Graphics Introduction to WebGL: HelloTriangle.html Eric Shaffer.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
PACS - 09/19/15 1 favicon A ‘Favorite icon’ is a file containing one or more small icons associated with a particular website or web page. Web browsers.
WebGL: in-browser 3D graphics Nick Whitelegg Maritme and Technology Faculty Southampton Solent University.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Programming with Visual Web Developer Chapter 9.
CS 450: COMPUTER GRAPHICS PORTRAIT OF AN OPENGL PROGRAM SPRING 2015 DR. MICHAEL J. REALE.
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
CS 480/680 Intro Dr. Frederick C Harris, Jr. Fall 2014.
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
1 Graphics CSCI 343, Fall 2015 Lecture 2 Introduction to HTML, JavaScript and WebGL.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
JavaScript Defined JavaScript Basics Definitions JavaScript is an object-oriented programming language designed for the world wide web. JavaScript code.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
Lesson 9. * Testing Your browser * Using different browser tools * Using conditional comments with * Dealing with future compatibility problems.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
WebGL Presentation by: Viet Nguyen.  Final Project Outline  Introduction  History  Support  Implementation  Advantages  Disadvantages  Conclusion.
1 A Simple Applet. 2 Applets and applications An applet is a Java program that runs on a web page Applets can be run within any modern browser To run.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
Beginning JavaScript 4 th Edition. Chapter 1 Introduction to JavaScript and the Web.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
GPU Computing for GIS James Mower Department of Geography and Planning University at Albany.
© 2012 DigitalDay | MOBILE WEB DESIGN PRINCIPLES Best Practices Workshop 1.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Lesson 1 – Getting Started with App Inventor
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 1.
Our Graphics Environment Landscape Rendering. Hardware  CPU  Modern CPUs are multicore processors  User programs can run at the same time as other.
The HTML5 logo was introduced by W3C in 2010
HTML5 Basics.
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
WebGL The HTML5/JavaScript 3D Computer Graphics API
The Basics: HTML5, Drawing, and Source Code Organization
گرافیک رایانه ای.
Introduction to OpenGL
Introduction to Computer Graphics with WebGL
The Canvas.
Introduction to Computer Graphics with WebGL
Browser Engine How it works…..
JavaScript.
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Introduction to Computer Graphics with WebGL
Introduction to OpenGL
Presentation transcript:

به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92

What is WebGL? WebGL (Web Graphics Library) WebGL is an implementation of OpenGL ES 2.0 for the web. WebGL is a JavaScript API for rendering interactive 3D graphics and 2D graphics within any compatible web browser without the use of plug-ins. WebGL programs consist of control code written in JavaScript and shader code that is executed on a computer's Graphics Processing Unit (GPU).

WebGL is designed and maintained by the non-profit Khronos Group. You program it in Javascript (which is not Java). WebGL makes it possible to display amazing realtime 3D graphics in your browser but what many people don't know is that WebGL is actually a 2D API, not a 3D API. WebGL only cares about 2 things. Clipspace coordinates in 2D and colors.

Your job as a programmer using WebGL is to provide WebGL with those 2 things. You provide 2 "shaders" to do this. A Vertex shader which provides the clipspace coordinates and a fragment shader that provides the color. Clipspace coordinates always go from -1 to +1 no matter what size your canvas is.

Does it run on my favorite browser? Browsers that support WebGL : Desktop Chrome Desktop Firefox Desktop Safari (on OSX, need to flip a flag ) Desktop Opera

Browsers that do not support WebGL : Internet Explorer Desktop Safari on Windows Mobile Safari (iOS, iPhone, iPad etc.) Opera for iOS Builtin Android browser

Does it run on my favorite platform? If a platform works or not depends a bit on driver versions, OS versions and other factors. This is known as a Whitelist/Blacklist. here are however platforms where WebGL will not run no matter what: Windows on ARM (surface etc.) Windows Phones Windows 8 Modern UI iOS (iPhone, iPad etc.) This is because Microsoft and Apple have not implemented WebGL and they dissallow other browsers for these platforms.

Examples:

Here's the 2 shaders:

This will draw a green rectangle the entire size of the canvas. Here it is:

For 2D stuff you would probably rather work in pixels than clipspace so let's change the shader so we can supply rectangles in pixels and have it convert to clipspace for us. Here's the new vertex shader:

Now we can change our data from clipspace to pixels:

And here it is:

You might notice the rectangle is near the bottom of that area. WebGL considers the bottom left corner to be 0,0. To get it to be the more traditional top left corner used for 2d graphics APIs we just flip the y coordinate.

Let's make the code that defines a rectangle into a function so we can call it for different sized rectangles. While we're at it we'll make the color settable. First we make the fragment shader take a color uniform input:

And here's the new code that draws 50 rectangles in random places and random colors:

And here's the rectangles:

What do type="x-shader/x-vertex" and type="x- shader/x-fragment" mean? tags default to having JavaScript in them. You can put no type or you can put type="javascript" or type="text/javascript" and the browser will interpret the contents as JavaScript. If you put anything else the browser ignores the contents of the script tag. We can use this feature to store shaders in script tags. Even better, we can make up our own type and in our javascript look for that to decide whether to compile the shader as a vertex shader or a fragment shader. In this case the function “createShaderFromScriptElement” looks for a script with specified id and then looks at the type to decide what type of shader to create.

WebGL Image Processing To draw images in WebGL we need to use textures. Similarly to the way WebGL expects clipspace coordinates when rendering instead of pixels, WebGL expects texture coordinates when reading a texture. Texture coordinates go from 0.0 to 1.0 no matter the dimensions of the texture. Since we are only drawing a single rectangle (well, 2 triangles) we need to tell WebGL which place in the texture each point in the rectangle corresponds to. We'll pass this information from the vertex shader to the fragment shader using a special kind of variable called a 'varying'. It's called a varying because it varies. WebGL will interpolate the values we provide in the vertex shader as it draws each pixel using the fragment shader.

Using the vertex shader from the end of previous section we need to add an attribute to pass in texture coordinates and then pass those on to the fragment shader.

Then we supply a fragment shader to look up colors from the texture.

Finally we need to load an image, create a texture and copy the image into the texture. Because we are in a browser images load asynchronously so we have to re- arrange our code a little to wait for the texture to load. Once it loads we'll draw it.

And here's the image rendered in WebGL.

How about just swapping red and blue?