Demistifying the 3D Web - part 2

13

Click here to load reader

Transcript of Demistifying the 3D Web - part 2

Page 1: Demistifying the 3D Web - part 2

WebGL

The native 3D API

Page 2: Demistifying the 3D Web - part 2

Native API

● javascript API

● brings typed arrays

● immediate mode graphical API

● no plugins needed

Page 3: Demistifying the 3D Web - part 2

OpenGL legacy

● based on OpenGL ES 2.0

● shader based pipeline

● uses GLSL 1.0 for shaders

● shaders are compiled

Page 4: Demistifying the 3D Web - part 2

How to get it

● create a <canvas> element

● retrieve the desired context

o myCanvasDOMElem.getContext(“3d”);

● access WebGL methods through context

Page 5: Demistifying the 3D Web - part 2

And what about shaders?

● passed as strings. Very long strings.

● C like syntax and statically typed

● two flavors: vertex and fragment shader

● native matrix and vector operators

Page 6: Demistifying the 3D Web - part 2

● shader based pipeline

● vertex shader to control vertices properties

● fragment shader to control pixels properties

● allow us to keep control of the pipeline

Why?

Page 7: Demistifying the 3D Web - part 2

Dealing with complexity

● WebGL uses points, lines and triangles

● geometries can have thousands of triangles

● lot of boilerplate even for trivial examples

● string composition in JS? Really?

Page 8: Demistifying the 3D Web - part 2

JS Frameworks for WebGL

● ThreeJS

● OSGJS

● BabylonJS

● ...yet another JS (SceneJS, ...)

Page 9: Demistifying the 3D Web - part 2

ThreeJS

● originally written in ActionScript

● the most famous one

● tons of tutorials and workshops

Page 10: Demistifying the 3D Web - part 2

OSGJS

● porting of OpenSceneGraph (C++)

● texture pipeline very close to Blender

● good support through forums

● production use: Sketchfab

Page 11: Demistifying the 3D Web - part 2

BabylonJS

● Microsoft’s WebGL framework

● based on a Silverlight game engine

● good support and demos

● extended physics support

Page 12: Demistifying the 3D Web - part 2

Let’s sell it tomorrow!

● Not just a modern browser, but a cool one

● not a HTML5 standard. Yet.

● powerful GPU is strongly suggested

Page 13: Demistifying the 3D Web - part 2

Let’s sell it tomorrow!

● Depends on the whole stack

o video adapter

o OS and drivers

o browser version, vendor, build...

o blacklists, security paranoias, luck