42
POCKET WEBGL

Pocket web gl sk

  • Upload
    fitc

  • View
    148

  • Download
    2

Embed Size (px)

DESCRIPTION

Pocket WebGL: What WebGL support on mobile means for HTML5 games with Chris Shankland presented on September 17 2014 at FITC's Web Unleashed Toronto 2014 Conference WebGL is an adaptation of the OpenGL ES specification for usage within the context of HTML5. This allows for unprecedented control over hardware directly from JavaScript and can provide a significant performance boost for essentially any graphics intensive application. HTML5 games on mobile have been very limited in what they can achieve in terms of visual fidelity and performance, unless some kind of native extension was used. These native extensions significantly reduce the flexibility of the applications, both from a distribution point of view and from a cross-platform point of view. These reasons are a large part of the choice to use HTML5 in the first place, and any hinderance of them drastically reduces the value of HTML5 as a mobile platform for games. WebGL provides a standardized mechanism to overcome many of the performance issues that had previously crippled mobile HTML5. In this session, Chris Shankland will be exploring how to get WebGL into your application, even if it’s just a 2D application. He will also explore some of the drawbacks that come with the additional control: mobile HTML5 games that use WebGL can be a double-edged sword. Additionally, he will give some examples of how this is the case and share some best practices. Finally, given that the field of 3D graphics and OpenGL is extensive, Chris will also share a number of resources for further learning and exploration. OBJECTIVE Understand what WebGL means for Mobile TARGET AUDIENCE Game developers with a focus on HTML5 related technologies ASSUMED AUDIENCE KNOWLEDGE Familiarity with JavaScript, HTML5 (what it is, what it isn’t), and a general understanding of what WebGL (or OpenGL) is. Any mobile development experience will be a big bonus, but not required. 5 THINGS LEARNED How to get WebGL running from scratch A sense of the significance of WebGL (performance comparison against 2D canvas) Differences across platforms to be aware of Common pitfalls Performance best practices

Citation preview

Page 1: Pocket web gl sk

POCKET WEBGL

Page 2: Pocket web gl sk

What is WebGL?Khronos

“WebGL is a cross-platform, royalty-free web standard for a low-level 3D graphics API based on OpenGL ES 2.0, exposed through the HTML5 Canvas element as Document Object Model interfaces.”

Page 3: Pocket web gl sk
Page 4: Pocket web gl sk

Why do we want WebGL?

Platform shouldn’t hold back content

True portability with performance

Battery life

Page 5: Pocket web gl sk

HELLO WEBGL

Page 6: Pocket web gl sk

How do I WebGL?

Page 7: Pocket web gl sk

CREATE A SHADER (1/3)

Page 8: Pocket web gl sk

CREATE A SHADER (2/3)

Page 9: Pocket web gl sk

CREATE A SHADER (3/3)

Page 10: Pocket web gl sk

CREATE BUFFERS

Page 11: Pocket web gl sk

CREATE TEXTURES

Page 12: Pocket web gl sk

MATRIX STACK AND TRANSFORM (1/5)

Page 13: Pocket web gl sk

MATRIX STACK AND TRANSFORM (2/5)

Page 14: Pocket web gl sk

MATRIX STACK AND TRANSFORM (3/5)

Page 15: Pocket web gl sk

MATRIX STACK AND TRANSFORM (4/5)

Page 16: Pocket web gl sk

MATRIX STACK AND TRANSFORM (5/5)

Page 17: Pocket web gl sk

DRAWIMAGE AND STROKERECT (1/5)

Page 18: Pocket web gl sk

DRAWIMAGE AND STROKERECT (2/5)

Page 19: Pocket web gl sk

DRAWIMAGE AND STROKERECT (3/5)

Page 20: Pocket web gl sk

DRAWIMAGE AND STROKERECT (4/5)

Page 21: Pocket web gl sk

DRAWIMAGE AND STROKERECT (5/5)

Page 22: Pocket web gl sk

PROFILING

Page 23: Pocket web gl sk

MAKE A DEMO SCENE, MAKE IT SLOW

Page 24: Pocket web gl sk

DEVELOPER TOOLS

Page 25: Pocket web gl sk

2D CANVAS CONTEXT

Page 26: Pocket web gl sk

WEBGL CONTEXT

Page 27: Pocket web gl sk

JS PROFILE

Page 28: Pocket web gl sk

OPTIMIZE

Page 29: Pocket web gl sk

DRAW IMAGE (1/3)

Page 30: Pocket web gl sk

DRAW IMAGE (2/3)

Page 31: Pocket web gl sk

DRAW IMAGE (3/3)

Page 32: Pocket web gl sk

BUFFER RESIZE AND DRAW (1/2)

Page 33: Pocket web gl sk

BUFFER RESIZE AND DRAW (2/2)

Page 34: Pocket web gl sk

SINGLE DRAW ELEMENTS

Page 35: Pocket web gl sk

MOVING TO MOBILE

Page 36: Pocket web gl sk

OVERVIEW

Does it run WKWebView What’s different

Page 37: Pocket web gl sk

Tile-basedDeferred rendering

Page 38: Pocket web gl sk

TBDR

Hardware - PowerVR

What is the bottleneck

Mobile specific concerns

Page 39: Pocket web gl sk

TBDR

Draw calls are buffered and tiled

Hardware hidden surface removal

0 overdraw (only opaque fragments)

Page 40: Pocket web gl sk

Going deeper on mobileNative profiling

Page 41: Pocket web gl sk

Mobile Profiling

Instruments

OpenGL ES Analyzer

Custom build an app

Page 42: Pocket web gl sk

ResourcesResources

- OpenGL Insights (http://openglinsights.com/)- MDN (https://developer.mozilla.org/en-US/)- WebGL Spec (https://www.khronos.org/webgl/)- Your hardware vendor (http://www.imgtec.com/powervr/graphics.asp)- Your platform vendor (https://developer.apple.com/library/ios)- Learning WebGL (http://learningwebgl.com)