WebGL - use JavaScript for 3D visualization By Christo Tsvetanov.

Slides:



Advertisements
Similar presentations
GlTF and rest3d Patrick Cozzi University of Pennsylvania CIS Fall 2013.
Advertisements

Ben Constable Developer, Internet Explorer Frank Olivier Program Manager, Internet
Graphics Pipeline.
CSPC 352: Computer Graphics Introduction to WebGL.
An introduction to WebGL Viktor Kovács. Content A little 3D modeling. What is WebGL? Introducing Three.js. Visualizing GDL objects.
WebGL Seminar TUT Technical Overview Arto Salminen, Matti Anttonen
3D Graphics Rendering and Terrain Modeling
Basics. OpenGL. “Hello world” George Georgiev Telerik Corporation
 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.
WebGL: a New Platform for 3D Games Advanced Games Programming by Jarek Francik 2011.
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.
WebGL: Hands On Zhenyao Mo Software Engineer, Google, Inc. Chrome GPU Team.
CS 480/680 Computer Graphics Course Overview Dr. Frederick C Harris, Jr. Fall 2012.
COMP SCI 352 Computer Graphics and Animation. Computer Graphics2 My name is … My name is … How to find me How to find me Course Policies Course Policies.
What is ? Open Graphics Library A cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is used to interact with a Graphics.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
A Really (too) Short Introduction to OpenGL Peter Rautek.
CS 418: Interactive Computer Graphics Introduction to WebGL: HelloTriangle.html Eric Shaffer.
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Shading. What is Shading? Assigning of a color to a pixel in the final image. So, everything in shading is about how to select and combine colors to get.
WebGL: in-browser 3D graphics Nick Whitelegg Maritme and Technology Faculty Southampton Solent University.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Introduction to Computer Graphics 靜宜大學 資訊工程系 蔡奇偉 副教授
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Introduction to Computer Graphics Ed Angel Professor Emeritus of Computer.
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
OpenGL-ES 3.0 And Beyond Boston Photo credit :Johnson Cameraface OpenGL Basics.
WebGL Presentation by: Viet Nguyen.  Final Project Outline  Introduction  History  Support  Implementation  Advantages  Disadvantages  Conclusion.
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
3D Objects in WebGL Loading 3D model files. Announcement Midterm exam on 12/2 –No Internet connection. –Example code and exam questions will be on USB.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
Advanced Texture Mapping Bump Mapping & Environment Mapping (Reflection)
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
WebGL The HTML5/JavaScript 3D Computer Graphics API
Programmable Pipelines
Tips for Environment Mapping
3D Graphics Rendering PPT By Ricardo Veguilla.
Introduction to WebGL 3D with HTML5 and Babylon.js
Understanding Theory and application of 3D
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Chapter VI OpenGL ES and Shader
ICG 2018 Fall Homework1 Guidance
Programming with OpenGL Part 3: Shaders
Mickaël Sereno Shaders Mickaël Sereno 25/04/2019 Mickaël Sereno -
Computer Graphics Introduction to Shaders
Advanced Texture Mapping
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
OpenGL-Rendering Pipeline
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Engine and functionalities
Presentation transcript:

WebGL - use JavaScript for 3D visualization By Christo Tsvetanov

Who am I?  An Infragistics friend  A long term enthusiast of 3D  Fascinates of mobile perspectives

 A Khronos group standard  JavaScript meets the GPU  Fast programmable drawing  OpenGL ES 2.0 for HTML5 Canvas Web Graphics Library

Desktop Browsers  Google Chrome – WebGL has been enabled on all platforms that have a capable graphics card  Mozilla Firefox  Safari – disabled by default  Opera  Internet Explorer - using third-party plugins such as using third-party plugins such as IEWebGL

Mobile Browsers  Nokia N900  BlackBerry PlayBook  Google Chrome for Android  Firefox for mobile for Android  The Sony Ericsson Xperia range of Android  Opera Mobile 12 final for Android  Tizen 1.0

3D Theory  3D Objects  Meshes, Vertices, Faces and Normals  Colors and Textures  Phong reflection model  UV Mapping  Transformations  Matrices  Shader-based drawing

Meshes  A polygon mesh is a collection of vertices, edges and faces that defines the shape of a polyhedral object in 3D computer graphics and solid modeling

Vertex (vertices)

Face

Normal vector

Faces visibility

Phong reflection model  Ambient  Ambient color is the color of an object where it is in shadow. This color is what the object reflects when illuminated by ambient light rather than direct light.  Diffuse  Diffuse color is the most instinctive meaning of the color of an object. It is that essential color that the object reveals under pure white light. It is perceived as the color of the object itself rather than a reflection of the light.

Phong reflection model  Emissive  This is the self-illumination color an object has.  Specular  Specular color is the color of the light of a specular reflection (specular reflection is the type of reflection that is characteristic of light reflected from a shiny surface)

Phong reflection model

UV mapping

World (Model – View) Matrix

 worldMatrix = rotateMatrix * translateMatrix * scaleMatrix  rotateMatrix = rotateX * rotateY *rotateZ  WebGL (glMatrix)  var mvMatrix = mat4.create();  mat4.translate(mvMatrix, [-1.5, 0.0, -7.0]);  mat4.rotate(mvMatrix, degToRad(rTri), [0, 1, 0]);  … rotateX, rotateY, rotateZ, scale

View (Camera) Matrix

Projection Matrix

 WebGL  var pMatrix = mat4.create();  mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix);

Shaders  Shaders are computer programs that runs on the graphics processing unit and are used to do shading - the production of appropriate levels of light and darkness within an image.  Vertex shader  Run once for each vertex given to the graphics processor  Pixel (fragment) shader  Compute color and other attributes of each pixel

Pipeline Buffers Attributes Uniform variables Varying variables Modified varying variables

Vertex shader attribute vec3 aVertexPosition; attribute vec4 aVertexColor; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; varying vec4 vColor; void main(void) { gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); vColor = aVertexColor; }

Fragment shader precision mediump float; varying vec4 vColor; void main(void) { gl_FragColor = vColor; }

WebGL demo  ndex.html ndex.html

Three.js  Three.js is a lightweight cross- browser JavaScript library/API used to create and display animated 3D computer graphics on a Web browser. Three.js scripts may be used in conjunction with the HTML5canvas element, SVG or WebGL.

Features  Renderers: Canvas, SVG and WebGL.  Effects: Anaglyph, cross-eyed and parallax barrier.  Scenes: add and remove objects at run-time; fog  Cameras: perspective and orthographic; controllers: trackball, FPS, path and more  Animation: armatures, forward kinematics, inverse kinematics, morph and keyframe

Features  Lights: ambient, direction, point and spot lights; shadows: cast and receive  Materials: Lambert, Phong, smooth shading, textures and more  Shaders: access to full OpenGL Shading Language (GLSL) capabilities: lens flare, depth pass and extensive post-processing library  Objects: meshes, particles, sprites, lines, ribbons, bones and more - all with Level of detail

Features  Geometry: plane, cube, sphere, torus, 3D text and more; modifiers: lathe, extrude and tube  Data loaders: binary, image, JSON and scene  Utilities: full set of time and 3D math functions including frustum, matrix, Quaternian, UVs and more  Export and import: utilities to create Three.js- compatible JSON files from within: Blender, openCTM, FBX, Max, and OBJ

Features  Support: API documentation is under construction, public forum and wiki in full operation  Examples: Over 150 files of coding examples plus fonts, models, textures, sounds and other support files  Debugging: Stats.js, WebGL Inspector, Three.js Inspector

Variables and functions var renderer; var scene; var camera; var cubeMesh; initializeScene(); animateScene();

Create a render if (Detector.webgl) { renderer = new THREE.WebGLRenderer({ antialias : true }); } else { renderer = new THREE.CanvasRenderer(); }

Set the renderer renderer.setSize(canvasWidth, canvasHeight); document.getElementById("WebGLCanvas").ap pendChild(renderer.domElement);

Create the scene and camera scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera(45, canvasWidth / canvasHeight, 1, 100); camera.position.set(0, 0, 10); camera.lookAt(scene.position); scene.add(camera);

Create mesh – texture, geometry, material var cubeGeometry = new THREE.CubeGeometry(2.0, 2.0, 2.0); var sponsorsTexture = new THREE.ImageUtils.loadTexture("Sponsors.png"); var cubeMaterial = new THREE.MeshBasicMaterial({ map : sponsorsTexture, side : THREE.DoubleSide });

Create mesh and add to scene cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial); cubeMesh.position.set(0.0, 0.0, 4.0); scene.add(cubeMesh);

Animate function animateScene() { xRotation += xSpeed; yRotation += ySpeed; cubeMesh.rotation.set(xRotation, yRotation, zRotation); cubeMesh.position.z = zTranslation; requestAnimationFrame(animateScene); renderer.render(scene, camera); }

Links - WebGL  Tutorial:   Matrix library – glMatrix 

Links – three.js  Source 

Expect very soon: SharePoint Saturday!  Saturday, June 8, 2013  Same familiar format – 1 day filled with sessions focused on SharePoint technologies  Best SharePoint professionals in the region  Registrations will be open next week (15 th )! 

Thanks to our Sponsors: Diamond Sponsor: Platinum Sponsors: Gold Sponsors: Swag Sponsors: Media Partners: