intro to webgl and babylonjs

34
Intro to WebGL Dave Voyles Sr. Tech Evangelist | Microsoft @DaveVoyles

Upload: dave-voyles

Post on 08-Sep-2014

1.040 views

Category:

Technology


2 download

DESCRIPTION

A high level overview of WebGL programming and the open source BabylonJS framework

TRANSCRIPT

Page 1: Intro to WebGL and BabylonJS

Intro to WebGL

Dave VoylesSr. Tech Evangelist | Microsoft@DaveVoyles

Page 2: Intro to WebGL and BabylonJS

About MePreviously a Sr. Engineer on the Xbox team at Comcast

Have been dabbling in the games industry for 4 years

Construction worker turned software engineer!

I’m a recent transplant from Long Island, NY.

Page 3: Intro to WebGL and BabylonJS

• OpenGL ES™ in a browser

• JavaScript API bindings

• Introduced in early 2011

• supported in nearly all modern browsers

What is WebGL?

Page 4: Intro to WebGL and BabylonJS

• Utilizes a JavaScript drawing API• Draw to a canvas element using a webGL context

• Low-level drawing – buffers, primitives, textures and shaders • Shaders are done in GLSL, similar to C

• Visuals are accelerated by graphics hardware (GPU)

• Can draw 2D or 3D

How does it work?

Page 5: Intro to WebGL and BabylonJS
Page 6: Intro to WebGL and BabylonJS

Uses for WebGLData Visualization

Page 7: Intro to WebGL and BabylonJS

Uses for WebGL

Source: Score Rush – Xona Games, Turbulenz

Gaming

Page 8: Intro to WebGL and BabylonJS

What else uses webGL?

Source: http://code.tutsplus.com/articles/webgl-essentials-part-i--net-25856, Don Olmstead, Sony, 2014

Sony PS4 UI“When you login to your PS4 you are running WebGL code. The PlayStation Store, the Music and Video Applications, as well as a good chunk of UX are all rendered within the browser”

Page 9: Intro to WebGL and BabylonJS

1. create <canvas> element2. obtain drawing context3. initialize the viewport4. create buffers5. create matrices6. create shaders7. initialize shaders8. draw primitives

Steps

Page 10: Intro to WebGL and BabylonJS

Shaders

Source: http://code.tutsplus.com/articles/webgl-essentials-part-i--net-25856, Gabriel Manricks, 2012

Fancy way of saying "position calculator" & "color chooser"

Page 11: Intro to WebGL and BabylonJS

Shaders (cont’d)

Source: http://msdn.microsoft.com/en-us/library/ie/dn385809(v=vs.85).aspx , Microsoft, 2014

Data coming in from your JavaScript code is passed by two types of qualifier variables: uniforms and attributes.

Uniform variables are global variables. They can be used by either the vertex or fragment shader, and define values that stay the same during the run of the program. An example is a value to use to scale vertex points.

uniform vec4 myVector = {0.5, 0.2, 0.7, 1.0};

Page 12: Intro to WebGL and BabylonJS

Shaders (cont’d)

Source: http://msdn.microsoft.com/en-us/library/ie/dn385809(v=vs.85).aspx , Microsoft, 2014

Attributes are variables that relate to a specific vertex point. Attributes can only be used in the vertex shader, and could be used to set a specific color for each vertex point.

There's a third qualifier variable, the varying variable, that's declared only in the GLSL shader code. A varying variable is set in the vertex shader and consumed in the fragment shader.

in vec3 position;

Page 13: Intro to WebGL and BabylonJS

That sounds like a ton of work. Let’s use a library, instead.

Page 14: Intro to WebGL and BabylonJS

Popular WebGL LibrariesBabylonJSAn open source webGL gaming framework, written by several Microsoft employees

ThreeJSA lightweight cross-browser JS library/API used to create and display animated 3D graphics

TurbulenzOpen source HTML5 game engine for developing games under the MIT license.

Page 16: Intro to WebGL and BabylonJS

I wrote a WebGL app – now what?For Windows Phone or Windows 8:

Just write a Win8 or Win Phone 8 app!

For iOS and Android, you have a bit more work:

CocoonJS

Page 17: Intro to WebGL and BabylonJS

Ludei (CocoonJS)

Page 18: Intro to WebGL and BabylonJS

BabylonJS

Page 19: Intro to WebGL and BabylonJS

Why build a WebGL Engine?

Page 20: Intro to WebGL and BabylonJS
Page 21: Intro to WebGL and BabylonJS
Page 22: Intro to WebGL and BabylonJS
Page 23: Intro to WebGL and BabylonJS
Page 24: Intro to WebGL and BabylonJS
Page 25: Intro to WebGL and BabylonJS
Page 26: Intro to WebGL and BabylonJS
Page 27: Intro to WebGL and BabylonJS
Page 28: Intro to WebGL and BabylonJS
Page 29: Intro to WebGL and BabylonJS
Page 30: Intro to WebGL and BabylonJS
Page 31: Intro to WebGL and BabylonJS
Page 32: Intro to WebGL and BabylonJS
Page 33: Intro to WebGL and BabylonJS
Page 34: Intro to WebGL and BabylonJS

@DaveVoyles