Understanding M3G 2.0 and its Effect on Producing Exceptional 3D Java-Based Graphics. Sean Ellis Consultant Graphics Engineer ARM, Maidenhead

Similar documents
M3G Overview. Tomi Aarnio Nokia Research Center

M O B I L E. 3D Mobile Games G A M E S. In this lesson 3D Mobile Games. Immediate mode Retained mode. Bhojan ANAND. SoC,

OPENGL RENDERING PIPELINE

Module 13C: Using The 3D Graphics APIs OpenGL ES

Graphics Programming. Computer Graphics, VT 2016 Lecture 2, Chapter 2. Fredrik Nysjö Centre for Image analysis Uppsala University

Bringing it all together: The challenge in delivering a complete graphics system architecture. Chris Porthouse

The Application Stage. The Game Loop, Resource Management and Renderer Design

Shaders. Slide credit to Prof. Zwicker

Optimisation. CS7GV3 Real-time Rendering

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Content. Building Geometry Appearance Lights Model Loaders

Shader Programming 1. Examples. Vertex displacement mapping. Daniel Wesslén 1. Post-processing, animated procedural textures

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

Building scalable 3D applications. Ville Miettinen Hybrid Graphics

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

COMP371 COMPUTER GRAPHICS

CS559 Computer Graphics Fall 2015

Mobile Application Programing: Android. OpenGL Operation

Dave Shreiner, ARM March 2009

OpenGL shaders and programming models that provide object persistence

Shadows. Prof. George Wolberg Dept. of Computer Science City College of New York

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015

Sign up for crits! Announcments

From Art to Engine with Model I/O

Optimizing Mobile Games with ARM. Solo Chang Staff Applications Engineer, ARM

Profiling and Debugging Games on Mobile Platforms

WebGL (Web Graphics Library) is the new standard for 3D graphics on the Web, designed for rendering 2D graphics and interactive 3D graphics.

Models and Architectures

Whiz-Bang Graphics and Media Performance for Java Platform, Micro Edition (JavaME)

CPSC 436D Video Game Programming

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation

CHAPTER 1 Graphics Systems and Models 3

Mobile Application Programing: Android. OpenGL Operation

CS452/552; EE465/505. Review & Examples

Rasterization Overview

GLSL 1: Basics. J.Tumblin-Modified SLIDES from:

Mobile graphics API Overview

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples

Hands-On Workshop: 3D Automotive Graphics on Connected Radios Using Rayleigh and OpenGL ES 2.0

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL

Ciril Bohak. - INTRODUCTION TO WEBGL

Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader

Recall: Indexing into Cube Map

Next-Generation Graphics on Larrabee. Tim Foley Intel Corp

Mali Developer Resources. Kevin Ho ARM Taiwan FAE

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

PROFESSIONAL. WebGL Programming DEVELOPING 3D GRAPHICS FOR THE WEB. Andreas Anyuru WILEY. John Wiley & Sons, Ltd.

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Converts geometric primitives into images Is split into several independent stages Those are usually executed concurrently

Lecture 2. Shaders, GLSL and GPGPU

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Bringing AAA graphics to mobile platforms. Niklas Smedberg Senior Engine Programmer, Epic Games

Computer Graphics Coursework 1

Deferred Rendering Due: Wednesday November 15 at 10pm

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

gltf - what the? Concepts An overview of the basics of the GL Transmission Format Page 1 gltf 2.0 Quick Reference Guide Binary data references

Working with Metal Overview

CS452/552; EE465/505. Intro to Lighting

The Transition from RenderMan to the OpenGL Shading Language (GLSL)

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

EDAF80 Introduction to Computer Graphics. Seminar 3. Shaders. Michael Doggett. Slides by Carl Johan Gribel,

Spring 2009 Prof. Hyesoon Kim

More frames per second. Alex Kan and Jean-François Roy GPU Software

Adaptive Point Cloud Rendering

Quick Shader 0.1 Beta

Spring 2011 Prof. Hyesoon Kim

CS 4620 Program 3: Pipeline

12.2 Programmable Graphics Hardware

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

INFOGR Computer Graphics

Teaching a Modern Graphics Pipeline Using a Shader-based Software Renderer

Chapter 7 - Light, Materials, Appearance

CS 354R: Computer Game Technology

Today. Rendering - III. Outline. Texturing: The 10,000m View. Texture Coordinates. Specifying Texture Coordinates in GL

Introduction. What s New in This Edition

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

Programmable Graphics Hardware

Introduction to Shaders.

Programming shaders & GPUs Christian Miller CS Fall 2011

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system

CS4621/5621 Fall Computer Graphics Practicum Intro to OpenGL/GLSL

Geometry Shaders. And how to use them

Supplement to Lecture 22

CMSC427 Fall 2017 OpenGL Notes A: Starting with JOGL and OpenGL Objectives of notes Readings Computer Graphics Programming in OpenGL with Java

Why modern versions of OpenGL should be used Some useful API commands and extensions

Programming with OpenGL Part 3: Shaders. Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

Pipeline Operations. CS 4620 Lecture 14

Content. Building Geometry Appearance Lights Model Loaders

POWERVR MBX & SGX OpenVG Support and Resources

Java TM Mobile 3D Graphics

The Rasterization Pipeline

Mobile Application Programming: Android. OpenGL Operation

Transcription:

Understanding M3G 2.0 and its Effect on Producing Exceptional 3D Java-Based Graphics Sean Ellis Consultant Graphics Engineer ARM, Maidenhead

Introduction M3G 1.x Recap ARM M3G Integration M3G 2.0 Update M3G 2.0 Hints and Tips 2

Audience Who were we addressing with M3G 1.x? Experienced Software Engineers Technical Artists 3D design skill Java design skill The same people need to be able to use M3G 2.0. 3

Basic MIDlet Architecture initialize Load assets, find commonly used objects, set up display, initialize game state Main loop. Don t create/destroy objects if possible Throttle to consistent frame rate Keep paint() as simple as possible Be careful with threads user input scene update request redraw wait Get any user input, network play, etc. Game logic, animate, align if necessary Wait to ensure consistent frame rate paint() Canvas calls Graphics3D to perform rendering Exit request shut down Release assets, tidy up 4

Java with Native Library Typical Relative Performance Interaction from user 3D object control 3D Application using SwV classes FAST 2D Most UI work Network done Classes here - at Classes high (J2ME) (J2ME) performance 2D UI Library (J2ME) Java Virtual Machine Network Library (J2ME) Input Classes (J2ME) Input Library (J2ME) OS Hardware Sound Classes (OEM specific) Scene management Animations 3D transformation Sound Lighting Library Triangle drawing (OEM specific) Texturing Transfer to 2D Other M3G Classes (OEM specific) Other M3G Library (OEM specific) 5

Class Hierarchy Object3D Node Camera Group World Light Mesh SkinnedMesh Transformable Sprite3D MorphingMesh Texture2D VertexBuffer VertexArray IndexBuffer TriangleStripArray Appearance Material Image2D Background Fog PolygonMode AnimationTrack CompositingMode KeyframeSequence AnimationController Graphics3D Loader RayIntersection Transform 6

M3G Integration Top End Interface Description Java Application JSR184/297 API Example API implementations shipped as source C API Java Interface Layer API interface code is auto-generated for KNI, JNI, C C Interface Layer C++ Implementation Supplied as a linkable library Some C++ libraries pre-linked 7

M3G Integration Bottom End Supplied as a linkable library C Interface Layer C++ Implementation Some C++ libraries pre-linked Example implementations shipped as source Abstraction APIs OS Abstraction GL Abstraction GLES Surface Abstraction EGL Surface abstraction needs access to Java VM internals (pixel buffers for images and Graphics objects) OS 8

M3G 2.0 Integration Tip Good news, everyone almost exactly the same as M3G 1.1 Some software-renderer-only integration APIs removed New abstraction interface for DynamicImage2D 9

M3G 2.0 New Features Core block Fixed function (Open GL ES 1.1) M3G 1.x compatible Mali55 or Mali200 Advanced block Programmable hardware Mali200 Can mix modes in API, with some restrictions Can implement both blocks on OpenGL ES 2.0 M3G 2.0 Core M3G 1.1 M3G 2.0 Advanced Must be completely present or absent less fragmentation Javax.microedition.m3g.shader package is major new addition Disclaimer Spec still in draft details subject to change 10

New Image Types Dynamic Image2D Image Cube Base Slow path Renderer Fast path Java Video Control Native Video Source 11

Mesh and its components Mesh VertexBuffer IndexBuffer IndexBuffer IndexBuffer Appearance Appearance Appearance VertexArray VertexArray VertexArray VertexArray VertexArray VertexArray VertexArray Vertex positions Vertex normals Vertex colors Texture coords Point sizes User attributes User attributes Vertex arrays now can contain values of type byte, short, 16.16 fixed point, float, or half-float 12

Mesh and its components Mesh VertexBuffer Index into IndexBuffer IndexBuffer IndexBuffer Appearance Appearance Appearance TriangleStrip Line Array Point Array Array Explicit Explicit or sequential vertex Explicit or sequential vertex indices or sequential Explicit vertex indices or sequential indices vertex indices 13

Appearance and its components Appearance Shader Appearance Base Material Primitive Polygon Point Line Mode Compositing Mode Fog Diffuse, emissive, specular, ambient colors, shininess Perspective correction, winding, culling Screen buffer write mode, thresholds, depth offset Fog density, color Texture2D Texture2D Texture application mode, coordinate transform, wrapping Image2D 14

Appearance and its components Shader Appearance Shader Program Shader Uniforms Vertex Shader Fragment Shader Texture2D TextureCube Image2D ImageCube 15

Vertex Shader First, vertex shader transforms the position of each vertex in an object. Often also calculates other parameters Position Normal Color Texture Coords Transformed Position Lit Color Transformed Texture Coords Input Object Transformed Object 16

Vertex Shader Same vertex shader runs on all vertices in the object. Can assign different shaders to other objects. Results are interpolated across primitives. Input Object Transformed Object 17

Fragment Shader Fragment shader takes interpolated ( varying ) variables, and calculates the actual color at each pixel. Texture Transformed Object Rendered Object 18

Fragment Shader Or it abandons the pixel, rendering nothing, and leaving a hole. Texture Transformed Object Rendered Object 19

Fragment Shader Same fragment shader runs on all pixels in the object. Can assign different shaders to other objects. Transformed Object You get the idea Rendered Object 20

M3G 2 Shader Model uniform mat4 modelviewmatrix; attribute vec4 vertexpos; void main() { gl_position = modelviewmatrix * vertexpos; } uniform mat4 modelviewmatrix; attribute vec4 vertexpos; void main() { gl_position = modelviewmatrix * vertexpos; } Compiled Vertex Shader Complete Shader Program Compiled Frag Shader Vertex Buffer Complete Appearance Appearance Uniform Variables Mesh Disclaimer: Specification subject to change 21

Why keep Appearance? ShaderAppearance can do anything than Appearance can So why keep it? Easy transition More artists know fixed function pipeline than shaders. Perfectly adequate for a lot of content. Familiarity means faster development. Can use all the legacy content out there. Can mix and match both in one scene. Therefore, shader designers can concentrate effort where it s going to be noticed. 22

Shader Example 23

Shader Walkthrough So, what does a shader look like? Isn t that just C? // Astoundingly dull fragment shader uniform vec4 flatcolor; void main() { gl_fragcolor = flatcolor; } 24

Same Geometry, Dull Shader 25

C-like language Syntax familiar to most programmers Simplified: no pointers, no characters New types: vectors, matrices, samplers New qualifiers: attribute, uniform, varying Limited size 95% common between Vertex and Fragment shaders 26

RenderPass Mesh Any Node can have a RenderPass VertexBuffer World IndexBuffer IndexBuffer IndexBuffer Meshes Appearance Appearance Appearance Texture2D Image2D Renders to 27

M3G2 Shader Tips TANSTAAFL Shaders are not free they take time, even on hardware Complex shaders take more time Specialize shaders for common parameter values 28

The #1 Important Shader Optimization Tip DON T DO IT yet Premature optimisation is the root of all evil C.A.R.Hoare Profile! Is it really the shaders at all? How fast does my shader run? What s really holding it up? Then you can really improve things 29

M3G2 Shader Tips Compilation time is fast, but not insignificant Compile once, use many times (This is why compilation happens at construction) Don t create shaders on the fly It s a balancing act More specialized shaders = faster execution More specialized shaders = slower startup 30

M3G2 Shader Tips Tools support often at the low level Requires cooperation from the hardware Mali hardware has debugging/profiling counters Low-level performance analysis tools Framerate Throughput Cache usage Higher level analysis tools under development: Shader debugger Shader profiler 31

Animation Changes Content developers requested changes to animation system. Designed for ease-of-use. Details currently under discussion in expert group. 32

You can contribute Early Draft Review Spec available at: http://jcp.org/aboutjava/communityprocess/edr/jsr297 Or just go to jcp.org and enter 297 in the Go to JSR box. The download link is on the resulting page. We want to hear feedback, especially from content developers We want you to understand it We want you to use it We want you to make good-looking applications exceptional 33

Q&A http://jcp.org/aboutjava/communityprocess/edr/jsr297 34