leaving flatland: getting started with webgl- sxsw 2012

39
Leaving Flatland: Getting Started with WebGL SXSW 2012 - Luz Caballero - Nicolas Garcia Belmonte

Post on 18-Oct-2014

4.252 views

Category:

Technology


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Leaving Flatland: Getting Started with WebGL- SXSW 2012

Leaving Flatland: Getting Started with WebGL

SXSW 2012 - Luz Caballero - Nicolas Garcia Belmonte

Page 3: Leaving Flatland: Getting Started with WebGL- SXSW 2012

I’m a Web Opener, I evangelize Web Standards.

Luz Caballero - @gerbille

Page 4: Leaving Flatland: Getting Started with WebGL- SXSW 2012

Agenda

• What is WebGL?

• What can WebGL be used for?

• How does WebGL work?

• Getting started with WebGL

Page 6: Leaving Flatland: Getting Started with WebGL- SXSW 2012

OpenGL OpenGL ES WebGL

Page 7: Leaving Flatland: Getting Started with WebGL- SXSW 2012

desktop mobile

Page 8: Leaving Flatland: Getting Started with WebGL- SXSW 2012

<canvas id=‘c’ width=‘100’ height=‘100’></canvas>

document.getElementById(‘c’).getContext(‘webgl’)

Page 9: Leaving Flatland: Getting Started with WebGL- SXSW 2012

What can WebGL be used for?

Page 10: Leaving Flatland: Getting Started with WebGL- SXSW 2012

• Data visualization

• Creative coding

• Art

• 3D design environments

• Music videos

• Plotting math functions

• 3D modeling of objects & space

• Creating textures

• ...fast processing of any data

Page 17: Leaving Flatland: Getting Started with WebGL- SXSW 2012

3D models of objects/space

Page 19: Leaving Flatland: Getting Started with WebGL- SXSW 2012

creating textures

Page 20: Leaving Flatland: Getting Started with WebGL- SXSW 2012

How does WebGL work?

Page 21: Leaving Flatland: Getting Started with WebGL- SXSW 2012

Fragment Shader

Vertex Shader

Triangle Assembly

Rasterization

image source: http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-1:-The-Graphics-Pipeline.html

Page 22: Leaving Flatland: Getting Started with WebGL- SXSW 2012

JavaScript

GPU (Compiled Program)

WebGL JS API

Page 23: Leaving Flatland: Getting Started with WebGL- SXSW 2012

JavaScript

Fragment Shader

WebGL JS API

Vertex ShaderGLSL API

GLSL API

[x1, y1, z1, x2, y2, z2, ...]

attributeuniform

uniform varying

Page 24: Leaving Flatland: Getting Started with WebGL- SXSW 2012

Getting started

Page 25: Leaving Flatland: Getting Started with WebGL- SXSW 2012

image source: http://computer.yourdictionary.com/graphics

The 3D scene

Page 27: Leaving Flatland: Getting Started with WebGL- SXSW 2012

desktop mobile

Page 28: Leaving Flatland: Getting Started with WebGL- SXSW 2012

PhiloGL

Page 29: Leaving Flatland: Getting Started with WebGL- SXSW 2012

HTML Document

Page 30: Leaving Flatland: Getting Started with WebGL- SXSW 2012

HTML DocumentWebGL Canvas

How most people see a WebGL App:

Page 31: Leaving Flatland: Getting Started with WebGL- SXSW 2012

WebGL Canvas

Web Workers

2D Canvas XHR(2)

Video

Audio

Images

Forms

How we see a WebGL App:

Page 33: Leaving Flatland: Getting Started with WebGL- SXSW 2012

PhiloGL

• Idiomatic JavaScript

• Rich Module System

• Flexible and Performance Focused

• Complete documentation

Page 34: Leaving Flatland: Getting Started with WebGL- SXSW 2012

Idiomatic JavaScriptConcise & Expressive

Page 35: Leaving Flatland: Getting Started with WebGL- SXSW 2012

  //Create application  PhiloGL('canvasId', {    program: {      from: 'uris',      vs: 'shader.vs.glsl',      fs: 'shader.fs.glsl'    },    camera: {      position: {        x: 0, y: 0, z: -50      }    },    textures: {      src: ['arroway.jpg', 'earth.jpg']    },    events: {      onDragMove: function(e) {        //do things...      },      onMouseWheel: function(e) {        //do things...      }    },    onError: function() {      alert("There was an error creating the app.");    },    onLoad: function(app) {      /* Do things here */    }  });

Page 36: Leaving Flatland: Getting Started with WebGL- SXSW 2012

• Core

• Math

• WebGL

• Program

• Shaders

• O3D

• Camera

• Scene

• Event

• Fx

• IO

• Workers

• Media

Module System

Page 38: Leaving Flatland: Getting Started with WebGL- SXSW 2012

Resources• An Introduction to WebGL @ dev.Opera

• PhiloGL

• PhiloGL tutorial

• WebGL w/o a library @ dev.Opera

• Porting 3D models to WebGL @ dev.Opera

• News and resources @ the Learning WebGL blog

• WebGL w/o a library @ Learning WebGL

• Three.js

• Three.js tutorial

• WebGL FAQ

• The Khronos WebGL forum

Page 39: Leaving Flatland: Getting Started with WebGL- SXSW 2012

Thanks!

@philogb@gerbille