Slide 1

Slide 1 text

The Power of WebGL @raphamundi HACKING YOUR GPU WITH JAVASCRIPT

Slide 2

Slide 2 text

RAPHAEL AMORIM raphamundi raphamorim raphamorim.com

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Shaders

Slide 5

Slide 5 text

Graphic procedures e.g: surfacing and texturing, lighting and shadowing, texture and geometry generation.

Slide 6

Slide 6 text

The "3D" Effect * A thanks Jaume Sanchez for the awesome resource!

Slide 7

Slide 7 text

[ -1, -1, 0 ], [ 1, -1, 0 ], [ 1, 1, 0 ], [ -1, 1, 0 ]

Slide 8

Slide 8 text

Vertex shader takes this data, and some other values (model-view and projection matrix, and others) and turns the 4 points into 4 projected points

Slide 9

Slide 9 text

We need to specify how to draw it: points, wireframe or solid

Slide 10

Slide 10 text

The solid projected square gets "discretised" base on the output display

Slide 11

Slide 11 text

The system fills the space connecting these dots and calculates what pixels on your display need to be drawn

Slide 12

Slide 12 text

The rest is up to the fragment shader It gets called for each of these small squares, and the correct output color is calculated.

Slide 13

Slide 13 text

GPU Graphics Processing Unit

Slide 14

Slide 14 text

GPU Run! Run! As fast as you can!

Slide 15

Slide 15 text

WebGL Web Graphics Library

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

WebGL Context Define the Geometry and Store it in the Buffer Objects Create and Compile the Shaders ( Vertex && Fragment )

Slide 18

Slide 18 text

Atributes

Slide 19

Slide 19 text

Atributes Uniforms

Slide 20

Slide 20 text

Atributes Uniforms Varyings

Slide 21

Slide 21 text

WebGL Water http://madebyevan.com/webgl-water/

Slide 22

Slide 22 text

WebGL Blossom http://www.bongiovi.tw/experiments/ webgl/blossom/

Slide 23

Slide 23 text

Google Maps Cube http://www.playmapscube.com/

Slide 24

Slide 24 text

WebGL is very hot Damn God! “ ”

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

~= 80ºC!!!

Slide 27

Slide 27 text

~= 80ºC!!! WebGL makes your macbook hot. Yeah, literally.

Slide 28

Slide 28 text

FPS Frame Per Second

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Where are the graphics costs?

Slide 31

Slide 31 text

The first rule of any optimization is to find where the performance problem is.

Slide 32

Slide 32 text

Strategies for optimizing for GPU vs. CPU are quite different.

Slide 33

Slide 33 text

CPU optimization

Slide 34

Slide 34 text

GPU: Optimizing Model Geometry

Slide 35

Slide 35 text

GPU: Texture Compression and Mipmaps

Slide 36

Slide 36 text

DrawCalls

Slide 37

Slide 37 text

WebVR Bringing Virtual Reality to the Web

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Okay, we already tried a lot.

Slide 40

Slide 40 text

till now:

Slide 41

Slide 41 text

WebVR is an API http://mzl.la/1IK6pnf

Slide 42

Slide 42 text

WebVR • Sechelt (http://mozvr.com/projects/sechelt/) • Quake III (http://media.tojicode.com/q3bsp/) • vizor.io (http://vizor.io/fthr/vr_cube/edit) • Primoseeditor (https://www.primroseeditor.com/#fullscreen) • Inspirit (http://inspirit.unboring.net/)

Slide 43

Slide 43 text

MozVR mozvr.com

Slide 44

Slide 44 text

bit.ly/1lDsdLR

Slide 45

Slide 45 text

Thanks! :)

Slide 46

Slide 46 text

References: • Shaders! What are they and what can they do for me? - 
 Jaume Sanchez (https://www.clicktorelease.com/talks/ scotlandjs-2015/) • Dive into 0.016 seconds of WebGL - @yomotsu (https:// speakerdeck.com/yomotsu/dive-into-0-dot-016-seconds-of-webgl) • Getting started with three.js and WebGL - 
 Jaume Sanchez (https://www.clicktorelease.com/talks/ jsconfbp-2015/)

Slide 47

Slide 47 text

References: • The Road To WebVR • Replacing reality with JavaScript - 
 Jaume Sanchez (https://www.clicktorelease.com/talks/ fullstackfest-2015/slides/#0) • WebGL tutorial MDN (https://developer.mozilla.org/en-US/docs/ Web/API/WebGL_API/Tutorial) • The Rise and Fall and Rise of Virtual Reality (http:// www.theverge.com/a/virtual-reality/oral_history)

Slide 48

Slide 48 text

References: • 6 Virtual Reality Devices From the Past (http:// www.cheatsheet.com/technology/a-trip-down-virtual-reality-road-6- systems-of-the-past.html )