Mobile Application Programing: Android. OpenGL Operation

Similar documents
Mobile Application Programing: Android. OpenGL Operation

Mobile Application Programming: Android. OpenGL Operation

Introduction to Computer Graphics. Hardware Acceleration Review

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

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

OPENGL RENDERING PIPELINE

Shaders. Slide credit to Prof. Zwicker

WebGL A quick introduction. J. Madeira V. 0.2 September 2017

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

Mobile graphics API Overview

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

CS452/552; EE465/505. Image Processing Frame Buffer Objects

Copyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012

Mobile Application Programming: Android. OpenGL ES 3D

Introduction to Shaders.

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

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

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

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

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

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL

Mobile Application Programming. OpenGL ES 3D

Shading Language Update

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

We assume that you are familiar with the following:

BCA611 Video Oyunları için 3B Grafik

Programming shaders & GPUs Christian Miller CS Fall 2011

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

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

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

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Programmable Graphics Hardware

CSE 4431/ M Advanced Topics in 3D Computer Graphics. TA: Margarita Vinnikov

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

We will use WebGL 1.0. WebGL 2.0 is now being supported by most browsers but requires a better GPU so may not run on older computers or on most cell

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

2D graphics with WebGL

COMP371 COMPUTER GRAPHICS

12.2 Programmable Graphics Hardware

SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming

Dave Shreiner, ARM March 2009

GPU Quality and Application Portability

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

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

CSE 167: Introduction to Computer Graphics Lecture #7: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C

Programming with OpenGL Complete Programs Objectives Build a complete first program

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

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

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

Geometry Shaders. And how to use them

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

Sign up for crits! Announcments

CS 432 Interactive Computer Graphics

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

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

CPSC 436D Video Game Programming

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 4: Three Dimensions

Introduction to Computer Graphics with WebGL

CS559 Computer Graphics Fall 2015

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

CS452/552; EE465/505. Image Formation

Computer Graphics Coursework 1

The Projection Matrix

An Overview GLUT GLSL GLEW

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

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

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

Lecture 09: Shaders (Part 1)

From system point of view, a graphics application handles the user input, changes the internal state, called the virtual world by modeling or

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

Shaders. Introduction. OpenGL Grows via Extensions. OpenGL Extensions. OpenGL 2.0 Added Shaders. Shaders Enable Many New Effects

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 3: Shaders

Rasterization Overview

OpenGL on Android. Lecture 7. Android and Low-level Optimizations Summer School. 27 July 2015

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

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

Introduction to the OpenGL Shading Language

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

CMSC427 OpenGL and JOGL

Models and Architectures. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Supplement to Lecture 22

Introduction to OpenGL ES 3.0

CS452/552; EE465/505. Review & Examples

The OpenGL Shading Language

Introduction to Computer Graphics with WebGL

OUTLINE. Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction

CS 380 Introduction to Computer Graphics. LAB (1) : OpenGL Tutorial Reference : Foundations of 3D Computer Graphics, Steven J.

CSE 167: Introduction to Computer Graphics Lecture #13: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Adding New Features to the CS 5625 Framework. Pramook Khungurn

Lecture 11 Shaders and WebGL. October 8, 2015

The Projection Matrix

Shading Languages. Ari Silvennoinen Apri 12, 2004

OPENGL AND GLSL. Computer Graphics

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Ciril Bohak. - INTRODUCTION TO WEBGL

Transcription:

Mobile Application Programing: Android OpenGL Operation

Activities Apps are composed of activities Activities are self-contained tasks made up of one screen-full of information Activities start one another and are destroyed commonly Apps can use activities belonging to another app

OpenGL ES C-Based Performance-Oriented Graphics Library Wrapper libraries provided for Java, C#, etc. Produces 2D images from 2D or 3D geometric data Mobile version of OpenGL Includes nearly all OpenGL functionality Removes seldom-used or legacy features Used by non-mobile platforms also (eg. Playstation 3)

OpenGL Environment android.opengl.glsurfaceview GLSurfaceView.Renderer GLES20 (C Library Wrapper) Vertex Shader Fragment Shader Program Uniform Variables Attribute Arrays GLSurfaceView Renderer GLES20 GL Calls

Data read from Scene and OBJ files OpenGL ES Primitive Processing Vertex Shader Fragments resulting from rasterization Fragment Shader OpenGL ES Rasterizer Frame Buffer OpenGL ES Fragment Processing

OpenGL Shading Language Defines a C-like language that can be compiled into GPU instructions Floating-point, Integer, and Boolean data types Vectors of these types in 2, 3, 4 sizes Matrices of floats in 2x2, 3x3, 4x4 1D-Arrays and Structures Special Texture types Operators on all these types

OpenGL Shading Language Variable storage qualifiers - uniform, attribute, varying Variable precision qualifiers - lowp, mediump, highp Control Statements - if, else Loops - for, while, do-while Jumps - break, continue, return Function Definition Pre-processor Directives

OpenGL Shading Language Built-in functions for basic mathematics, trigonometry, geometry, and texturing (eg. exp, tan, cross, texture2d) Built-in variables to represent inputs and outputs Vertex Shader gl_position (vec4, out) Fragment Shader gl_fragcoord (vec2, in) gl_fragcolor (vec4, out)

Host-GPU Data Transfer Global values are sent to the graphics processing hardware by changing the values of uniform variables defined in the shaders using glgetunifromlocation and gluniform* calls Geometry data is sent to the graphics hardware by using glbindattriblocation, glenablevertexattribarray, glvertexattribpointer Textures are sent to the graphics processing hardware by calling glbindtexture and glteximage2d Drawing is initiated by calling gldrawarrays

Vertex Shader Receives a vertex from OpenGL after minimal processing Modifies incoming vertex in some way using uniform variables where needed Outputs the vertex May also output additional data for the fragment shader to use

Vertex Shader attribute vec4 position; gl_position = position;

Vertex Shader attribute vec4 position; uniform mat4 modelview; gl_position = modelview * position;

Vertex Shader attribute vec4 position; uniform mat4 modelview; uniform mat4 projection; gl_position = projection * modelview * position;

Vertex Shader attribute vec4 position; attribute vec2 texturecoordinate; uniform mat4 modelview; uniform mat4 projection; varying lowp vec2 texturecoordinatevarying; gl_position = projection * modelview * position; texturecoordinatevarying = texturecoordinate;

Vertex Shader attribute vec4 position; attribute vec3 normal; attribute vec2 texturecoordinate; uniform mat4 modelview; uniform mat4 projection; varying lowp vec3 normalvarying; varying lowp vec2 texturecoordinatevarying; gl_position = projection * modelview * position; normalvarying = vec3(normalize(modelview * vec4(normal, 0.0))); texturecoordinatevarying = texturecoordinate;

Vertex Shader attribute vec4 position; attribute vec3 normal; attribute vec2 texturecoordinate; uniform mat4 modelview; uniform mat4 projection; uniform vec4 lightposition; uniform vec4 lightambient; uniform vec4 lightdiffuse; varying lowp vec3 normalvarying; varying lowp vec2 texturecoordinatevarying; varying lowp vec4 diffusevarying; gl_position = projection * modelview * position; normalvarying = vec3(normalize(modelview * vec4(normal, 0.0))); texturecoordinatevarying = texturecoordinate; vec4 lightvector = normalize(lightposition - gl_position); float lightincidence = dot(lightvector, vec4(normalvarying, 1.0)); diffusevarying = lightdiffuse * vec4(max(lightincidence, 0.0));

Fragment Shader Receives a fragment from OpenGL resulting from rasterizing a primitive Chooses a color for the fragment based on data given by vertex shader and uniform variables Outputs the fragment color

Fragment Shader gl_fragcolor = vec4(1.0, 1.0, 0.0, 1.0);

Fragment Shader uniform vec4 color; gl_fragcolor = color;

Fragment Shader varying vec4 color; gl_fragcolor = color;

Fragment Shader uniform sampler2d textureunit; varying vec2 texturecoordinate; gl_fragcolor = texture2d(textureunit, texturecoordinate);

Fragment Shader uniform vec4 color; uniform vec4 lightpositioneyecoords; varying vec4 positioneyecoords; varying vec3 normaleyecoords; vec3 incident = vec3(normalize(lightpositioneyecoords - positioneyecoords)); vec3 normal = normaleyecoords; float incidence = max(0.0, dot(incident, normal)); gl_fragcolor = color * incidence;

Shaders attribute vec4 position; attribute vec2 texturecoordinate; uniform mat4 modelview; uniform mat4 projection; varying lowp vec2 texturecoordinatevarying; gl_position = projection * modelview * position; texturecoordinatevarying = texturecoordinate; uniform sampler2d textureunit; varying vec2 texturecoordinate; gl_fragcolor = texture2d(textureunit, texturecoordinate);