SlideShare uma empresa Scribd logo
1 de 41
OpenGL Shading Languages
(GLSL)
SK planet/Mobile Platform Dept.
Jungsoo Nam
namjungsoo@gmail.com
Graphics Programming
• Generates
– 2D Programming
• GDI, Quartz, Canvas
• DirectDraw
– 3D Programming
• Direct3D, OpenGL
• Post Processing
– Image Processing, Computer Vision
• OpenCV
• OpenCL, CUDA, RenderScript
3D Graphics Programming
• Inputs
– Vertex Processing
• Vertices(Positions), Lights, Colors, Texture Coordinates
– Fragment Processing
• Texture Coordinates, Texture Images
• Outputs
– Vertex Processing
• Vertices, Texture Coordinates and Colors
• Polygons
– Fragment Processing
• Pixels, Depth
Shading
• Shading
– Shading refers to depicting depth perception in 3D
models or illustrations by varying levels of darkness.
– In computer graphics, shading refers to the process of
altering the color of an object/surface/polygon in the
3D scene, based on its angle to lights and its distance
from lights to create a photorealistic effect. Shading is
performed during the rendering process by a program
called a shader.
3D Rendering Pipeline
OpenGL ES 2.0 Rendering Pipeline –
Fixed Function Pipeline removed
Rasterization & Raster
Operations(ROP)
Transform and Lighting
surfaceColor = emissive + ambient + diffuse + specular
emissive = Ke
ambient = Ka x globalAmbient
diffuse = Kd x lightColor x max(N · L, 0)
specular = Ks x lightColor x facing x (max(N · H, 0)) shininess
Vertex Processing Pipeline
Fragment Processing Pipeline
GPU Programming
• Writing programmable vertex/fragment
programs(shaders)
GPU Programming History(1/6)
GPU Programming History(2/6)
GPU Programming History(3/6)
GPU Programming History(4/6)
GPU Programming History(5/6)
GPU Programming History(6/6)
Cg vs GLSL
• Advantage of Cg
– Supports both of Direct3D/OpenGL
– Supports Old VGAs(before OpenGL 2.0)
– Supports nVIDIA OpenGL Extensions
– Direct3D compatibility(HLSL and Cg, HLSL Effect and CgFX
– Possible to assembly optimization
• Advantage of GLSL
– OpenGL Standard(for OpenGL only users and new comers)
• No extra runtimes(Cg.dll, CgGL.dll, …)
• Supports OpenGL ES(Android, iOS, WebGL)
OpenGL Versions
OpenGL
Version
Comments
1.0~1.5 Direct3D 8.0~9.0b
Shader Model 1.0~2.0a
Cg
2.0 Direct3D 9.0c
Shader Model 3.0
OpenGL Shading Language
3.0 Direct3D 10
Shader Model 4.0
Deprecated features include:
• All fixed-function vertex and fragment
processing.
• Direct-mode rendering, using glBegin and
glEnd.
• Display lists.
• Indexed-color rendering targets.
• OpenGL Shading Language versions 1.10 and
1.20.
3.3 Geforce 8
4.0 Direct3D 11
Shader Model 5.0
4.1 OpenGL ES 2.0
4.2 OpenGL ES 3.0
DirectX
Version
Description
8.0 Shader Model 1.0 & 1.1, Geforce 3
8.0a Shader Model 1.3
8.1 Shader Model 1.4, ATI Radeon 8500
9.0 Shader Model 2.0, Geforce FX(5)
HLSL
9.0a Shader Model 2.0a
9.0b Shader Model 2.0b
9.0c Shader Model 3.0, Geforce 6
10.0* Shader Model 4.0, Geforce 8, Geometry Shader
10.1* Shader Model 4.1, Geforce 200
11.0* Shader Model 5.0, Geforce 400, Compute Shader
11.1*+ Shader Model 5.0, Geforce 600
*Not available for Windows XP OS
†Only available for Windows 8 OS
OpenGL Extensions
• OpenGL Extensions
– OpenGL Extensions are usually made available to access new features of 3D graphics hardware. Hardware vendors
define new functions and/or tokens that enhance the existing features of OpenGL.
• Extensions created by a single vendor are called "vendor-specific" and extensions created by several vendors are called
"multivendor" extensions.
• If a vendor-specific or multivendor extension proves to be a good enhancement, the OpenGL Architecture Review Board (ARB)
may promote it to an "ARB approved" extension.
• If the extension is very useful, the ARB may decide to integrate the extension as a "core feature" to OpenGL. This happened for
example with the OpenGL Shading Language which is now a core feature of OpenGL 2.0 and higher.
– Detecting extensions
• const GLubyte* sExtensions = glGetString(GL_EXTENSIONS);
– Naming conventions
• GL(PLATFORM)_VENDOR_extension_name
• VENDOR
– ARB Architecture Review Board approved extension
– EXT Multivendor Extension
– APPLE Extension from Apple Computer, Inc.
– ATI Extension from ATI Technologies, Inc. (AMD)
– HP Extension from Hewlett Packard.
– NV Extension from NVIDIA Corporation
– SGIS Extension from Silicon Graphics, Inc.
• PLATFORM: WGL, GLX, EGL
– GLSL required extensions
• ARB vertex shader
• ARB fragment shader
• ARB shader objects
• ARB geometry shader 4
• ARB tessellation shader
GLSL Versions
• Until version 3.30, the GLSL version number and the corresponding OpenGL version number
were different. Here's a table:
• Direct3D Shader Model 4.0 is equivalent to GLSL version 3.30. Earlier GLSL versions for
OpenGL 3.x provide subsets of this functionality, based on the available functionality in the
OpenGL version, though 1.50 is almost feature-identical to SM4
• Direct3D Shader Model 5.0 is equivalent to GLSL version 4.30.
• http://www.opengl.org/wiki/Detecting_the_Shader_Model
OpenGL Version GLSL Version
2.0 1.10
2.1 1.20
3.0 1.30
3.1 1.40
3.2 1.50
Shader Model(SM) Numbers
• ARB Assembly Language
• These are done through testing the presence of extensions. You should test
them in this order:
• GL_NV_gpu_program4: SM 4.0 or better.
• GL_NV_vertex_program3: SM 3.0 or better.
• GL_ARB_fragment_program: SM 2.0 or better.
• ATI does not support higher than SM 2.0 functionality in assembly shaders.
• http://msdn.microsoft.com/en-
us/library/windows/desktop/bb509626(v=vs.85).aspx
(Although gs_4_0, gs_4_1, ps_4_0, ps_4_1, vs_4_0, and vs_4_1 were introduced in shader model 4.0, shader
model 5 adds support to these shader profiles for structured buffers and byte address buffers.)
Shader Model Shader Profiles
Shader Model 1 vs_1_1
Shader Model 2 ps_2_0, ps_2_x, vs_2_0, vs_2_x, ps_4_0_level_9_0, ps_4_0_level_9_1, ps_4_0_level_9_3,
vs_4_0_level_9_0, vs_4_0_level_9_1, vs_4_0_level_9_3, lib_4_0_level_9_1, lib_4_0_level_9_3
Shader Model 3 ps_3_0, vs_3_0
Shader Model 4 cs_4_0, gs_4_0, ps_4_0, vs_4_0, cs_4_1, gs_4_1, ps_4_1, vs_4_1, lib_4_0, lib_4_1
Shader Model 5 cs_5_0, ds_5_0, gs_5_0, hs_5_0, ps_5_0, vs_5_0, lib_5_0
Shader Model 3 Example
OpenGL ES Versions
Version Description
OpenGL ES 1.0
Android
Standard
• Quad and polygon rendering primitives,
• Texgen, line and polygon stipple,
• Polygon mode and antialiased polygon rendering are not supported, although rendering using multisample is still possible (rather
than alpha border fragments),
• ARB_Image pixel class operation are not supported, nor are bitmaps or 3D textures,
• Several of the more technical drawing modes are eliminated, including frontbuffer and accumulation buffer. Bitmap operations,
specifically copying pixels (individually) is not allowed, nor are evaluators, nor (user) selection operations,
• Display lists and feedback are removed, as are push and pop operations for state attributes,
• Some material parameters were removed, including back-face parameters and user defined clip planes.
OpenGL ES 1.1
Android 1.6
• Better multitexture support (including combiners and dot product texture operations)
• Automatic mipmap generation
• Vertex buffer objects
• State queries
• User clip planes
• Greater control over point rendering
OpenGL ES 2.0
Android
2.0(NDK), 2.2
• Eliminates most of the fixed-function rendering pipeline in favor of a programmable one in a move similar to transition from OpenGL
3.0 to 3.1.
• Almost all rendering features of the transform and lighting stage, such as the specification of materials and light parameters formerly
specified by the fixed-function API, are replaced by shaders written by the graphics programmer.
• As a result, OpenGL ES 2.0 is not backward compatible with OpenGL ES 1.1.
OpenGL ES 3.0
Android 4.3
Samsung
S4(Snapdragon
)/Nexus5,
7(2013)/LG G2
OpenGL ES 3.0 is backwards compatible with OpenGL ES 2.0, enabling applications to incrementally add new visual features to
applications. OpenGL 4.3 provides full compatibility with OpenGL ES 3.0.
• Multiple enhancements to the rendering pipeline to enable acceleration of advanced visual effects including: occlusion queries,
transform feedback, instanced rendering and support for four or more rendering targets
• High quality ETC2 / EAC texture compression as a standard feature, eliminating the need for a different set of textures for each
platform
• A new version of the GLSL ES shading language[8] with full support for integer and 32-bit floating point operations
• Greatly enhanced texturing functionality including guaranteed support for floating point textures, 3D textures, depth textures, vertex
textures, NPOT textures, R/RG textures, immutable textures, 2D array textures, swizzles, LOD and mip level clamps, seamless cube
maps and sampler objects
• An extensive set of required, explicitly sized texture and render-buffer formats, reducing implementation variability and making it
much easier to write portable applications
WebGL
• WebGL
– WebGL is based on OpenGL ES 2.0 and provides
an API for 3D graphics.
– Like OpenGL ES 2.0, WebGL does not have the
fixed-function APIs introduced in OpenGL 1.0 and
deprecated in OpenGL 3.0.
• Strictly speaking, WebGL is a dialect of OpenGL ES 2.0
– http://learningwebgl.com/lessons/
GLSL – Simple Example
ftransform() is used for fixed function pipeline.
GLSL - Build-in Variables(1/2)
GLSL - Build-in Variables(1/2)
GLSL keywords – attribute, uniform,
varying
• (Vertex) Attribute
– Vertex attributes are used to communicate from outside to the vertex shader.
• Unlike uniform variables, values are provided per vertex (and not globally for all vertices).
• There are built-in vertex attributes like the normal or the position, or you can specify
your own vertex attribute like a tangent or another custom value.
• Attributes can't be defined in the fragment shader.
• Uniform
– Uniform variables are used to communicate with your vertex or fragment
shader from "outside". In your shader you use the uniform qualifier to declare
the variable
• Uniform variables are read-only and have the same value among all processed vertices.
You can only change them within your C++ program.
• Varying
– Varying variables provide an interface between Vertex and Fragment Shader.
• Vertex Shaders compute values per vertex and fragment shaders compute values per
fragment.
• If you define a varying variable in a vertex shader, its value will be interpolated
(perspective-correct) over the primitive being rendered and you can access the
interpolated value in the fragment shader.
GLSL APIs
• GLSL flow APIs
– Loading Shader
• glCreateShaderObject
• glShaderSource
– Compiling Shader
• glCompileShader
– Linking
• glCreateProgramObject
• glAttachObject
• glLinkProgram
– Using Shaders
• glUseProgramObject
• GLSL communication APIs
– Attribute
• glGetAttribLocation
• glEnableVertexAttribArray
• glVertexAttribPointer
– Uniform
• glGetUniformLocation
• glUniform
Vertex Shader Example – Directional
Lighting
void main()
{
vec3 normal, lightDir, viewVector, halfVector;
vec4 diffuse, ambient, globalAmbient, specular = vec4(0.0);
float NdotL,NdotHV;
/* first transform the normal into eye space and normalize the result */
normal = normalize(gl_NormalMatrix * gl_Normal);
/* now normalize the light's direction. Note that according to the
OpenGL specification, the light is stored in eye space. Also since
we're talking about a directional light, the position field is actually
direction */
lightDir = normalize(vec3(gl_LightSource[0].position));
/* compute the cos of the angle between the normal and lights direction.
The light is directional so the direction is constant for every vertex.
Since these two are normalized the cosine is the dot product. We also
need to clamp the result to the [0,1] range. */
NdotL = max(dot(normal, lightDir), 0.0);
/* Compute the diffuse, ambient and globalAmbient terms */
diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient;
/* compute the specular term if NdotL is larger than zero */
if (NdotL > 0.0) {
NdotHV = max(dot(normal, normalize(gl_LightSource[0].halfVector.xyz)),0.0);
specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(NdotHV,gl_FrontMaterial.shininess);
}
gl_FrontColor = globalAmbient + NdotL * diffuse + ambient + specular;
gl_Position = ftransform();
}
Fragment Shader Example – Per Pixel
Directional Lighting
http://www.lighthouse3d.com/tutorials/glsl-tutorial/directional-light-per-pixel/
Fragment Shader Example – YUV to
RGB Conversion
http://helloworld.naver.com/helloworld/1207
Fragment Shader Example – Image
Filter(Box Blur)
attribute vec2 vPosition;
attribute vec2 vTexCoord;
uniform float texelWidthOffset;
uniform float texelHeightOffset;
uniform highp float blurSize;
varying vec2 centerTextureCoordinate;
varying vec2 oneStepLeftTextureCoordinate;
varying vec2 twoStepsLeftTextureCoordinate;
varying vec2 oneStepRightTextureCoordinate;
varying vec2 twoStepsRightTextureCoordinate;
void main()
{
gl_Position = vPosition;
vec2 firstOffset = vec2(1.5 * texelWidthOffset, 1.5 * texelHeightOffset) * blurSize;
vec2 secondOffset = vec2(3.5 * texelWidthOffset, 3.5 * texelHeightOffset) * blurSize;
centerTextureCoordinate = vTexCoord;
oneStepLeftTextureCoordinate = vTexCoord - firstOffset;
twoStepsLeftTextureCoordinate = vTexCoord - secondOffset;
oneStepRightTextureCoordinate = vTexCoord + firstOffset;
twoStepsRightTextureCoordinate = vTexCoord + secondOffset;
}
precision mediump float;
uniform sampler2D sTexture;
varying vec2 centerTextureCoordinate;
varying vec2 oneStepLeftTextureCoordinate;
varying vec2 twoStepsLeftTextureCoordinate;
varying vec2 oneStepRightTextureCoordinate;
varying vec2 twoStepsRightTextureCoordinate;
void main()
{
lowp vec4 fragmentColor = texture2D(sTexture, centerTextureCoordinate) * 0.2;
fragmentColor += texture2D(sTexture, oneStepLeftTextureCoordinate) * 0.2;
fragmentColor += texture2D(sTexture, oneStepRightTextureCoordinate) * 0.2;
fragmentColor += texture2D(sTexture, twoStepsLeftTextureCoordinate) * 0.2;
fragmentColor += texture2D(sTexture, twoStepsRightTextureCoordinate) * 0.2;
gl_FragColor = fragmentColor;
}
OpenGL 4.3 generation
OpenGL 4.3
Direct3D 11
Fragment Shader vs Compute Shader
Geometry Shader
//GEOMETRY SHADER
#version 120
#extension GL_ARB_geometry_shader4 : enable
///////////////////////
void main()
{
//increment variable
int i;
vec4 vertex;
/////////////////////////////////////////////////////////////
//This example has two parts
// step a) draw the primitive pushed down the pipeline
// there are gl_VerticesIn # of vertices
// put the vertex value into gl_Position
// use EmitVertex => 'create' a new vertex
// use EndPrimitive to signal that you are done creating a primitive!
// step b) create a new piece of geometry
// I just do the same loop, but I negate the vertex.z
// result => the primitive is now mirrored.
//Pass-thru!
for(i = 0; i < gl_VerticesIn; i++)
{
gl_Position = gl_PositionIn[i];
EmitVertex();
}
EndPrimitive();
//New piece of geometry!
for(i = 0; i < gl_VerticesIn; i++)
{
vertex = gl_PositionIn[i];
vertex.z = -vertex.z;
gl_Position = vertex;
EmitVertex();
}
EndPrimitive();
}
Compute Shader
Thank you
• Q & A

Mais conteúdo relacionado

Mais procurados

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Drools and jBPM 6 Overview
Drools and jBPM 6 OverviewDrools and jBPM 6 Overview
Drools and jBPM 6 OverviewMark Proctor
 
[FOSS4G Korea 2016] Workshop - Advanced GeoServer
[FOSS4G Korea 2016] Workshop - Advanced GeoServer[FOSS4G Korea 2016] Workshop - Advanced GeoServer
[FOSS4G Korea 2016] Workshop - Advanced GeoServerMinPa Lee
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonAMD Developer Central
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android Arvind Devaraj
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewYu-Hsin Hung
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Edureka!
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overheadCass Everitt
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineNarann29
 
CityGML extension for BIM and IFC
CityGML extension for BIM and IFCCityGML extension for BIM and IFC
CityGML extension for BIM and IFCLéon Berlo
 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGLSuhan Lee
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)Johan Andersson
 
Android Chromium Rendering Pipeline
Android Chromium Rendering PipelineAndroid Chromium Rendering Pipeline
Android Chromium Rendering PipelineHyungwook Lee
 

Mais procurados (20)

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Express JS
Express JSExpress JS
Express JS
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
Drools and jBPM 6 Overview
Drools and jBPM 6 OverviewDrools and jBPM 6 Overview
Drools and jBPM 6 Overview
 
[FOSS4G Korea 2016] Workshop - Advanced GeoServer
[FOSS4G Korea 2016] Workshop - Advanced GeoServer[FOSS4G Korea 2016] Workshop - Advanced GeoServer
[FOSS4G Korea 2016] Workshop - Advanced GeoServer
 
OpenGL 4.6 Reference Guide
OpenGL 4.6 Reference GuideOpenGL 4.6 Reference Guide
OpenGL 4.6 Reference Guide
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
Vulkan 1.1 Reference Guide
Vulkan 1.1 Reference GuideVulkan 1.1 Reference Guide
Vulkan 1.1 Reference Guide
 
Angular
AngularAngular
Angular
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture Overview
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering Pipeline
 
CityGML extension for BIM and IFC
CityGML extension for BIM and IFCCityGML extension for BIM and IFC
CityGML extension for BIM and IFC
 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGL
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
Terrain Rendering in Frostbite using Procedural Shader Splatting (Siggraph 2007)
 
Android Chromium Rendering Pipeline
Android Chromium Rendering PipelineAndroid Chromium Rendering Pipeline
Android Chromium Rendering Pipeline
 

Destaque

13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGLJungsoo Nam
 
ICON 2011 Introduction to OpenGL ES
ICON 2011 Introduction to OpenGL ESICON 2011 Introduction to OpenGL ES
ICON 2011 Introduction to OpenGL ESSeongWan Kim
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and MoreMark Kilgard
 
GFX Part 4 - Introduction to Texturing in OpenGL ES
GFX Part 4 - Introduction to Texturing in OpenGL ESGFX Part 4 - Introduction to Texturing in OpenGL ES
GFX Part 4 - Introduction to Texturing in OpenGL ESPrabindh Sundareson
 
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기MinGeun Park
 
01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)
01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)
01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)VentureSquare
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityMark Kilgard
 
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현MinGeun Park
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShareSlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShareSlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShareSlideShare
 

Destaque (13)

13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
 
ICON 2011 Introduction to OpenGL ES
ICON 2011 Introduction to OpenGL ESICON 2011 Introduction to OpenGL ES
ICON 2011 Introduction to OpenGL ES
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
GFX Part 4 - Introduction to Texturing in OpenGL ES
GFX Part 4 - Introduction to Texturing in OpenGL ESGFX Part 4 - Introduction to Texturing in OpenGL ES
GFX Part 4 - Introduction to Texturing in OpenGL ES
 
Open Shading Language (OSL)
Open Shading Language (OSL)Open Shading Language (OSL)
Open Shading Language (OSL)
 
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
 
01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)
01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)
01 23회 오픈업 발표자료 명승은 대표(벤처스퀘어)
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
 
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 

Semelhante a OpenGL Shading Language

Hpg2011 papers kazakov
Hpg2011 papers kazakovHpg2011 papers kazakov
Hpg2011 papers kazakovmistercteam
 
GTC 2009 OpenGL Barthold
GTC 2009 OpenGL BartholdGTC 2009 OpenGL Barthold
GTC 2009 OpenGL BartholdMark Kilgard
 
NVIDIA Graphics, Cg, and Transparency
NVIDIA Graphics, Cg, and TransparencyNVIDIA Graphics, Cg, and Transparency
NVIDIA Graphics, Cg, and TransparencyMark Kilgard
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesEpic Games China
 
OpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUOpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUJiansong Chen
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Prabindh Sundareson
 
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsGFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsPrabindh Sundareson
 
Hardware Shaders
Hardware ShadersHardware Shaders
Hardware Shadersgueste52f1b
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Droidcon Berlin
 
Open GL ES Android
Open GL ES AndroidOpen GL ES Android
Open GL ES AndroidMindos Cheng
 
OpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsOpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsPrabindh Sundareson
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGLGary Yeh
 
openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).pptHIMANKMISHRA2
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.pptHIMANKMISHRA2
 

Semelhante a OpenGL Shading Language (20)

OpenGL 4 for 2010
OpenGL 4 for 2010OpenGL 4 for 2010
OpenGL 4 for 2010
 
What is OpenGL ?
What is OpenGL ?What is OpenGL ?
What is OpenGL ?
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
Hpg2011 papers kazakov
Hpg2011 papers kazakovHpg2011 papers kazakov
Hpg2011 papers kazakov
 
GTC 2009 OpenGL Barthold
GTC 2009 OpenGL BartholdGTC 2009 OpenGL Barthold
GTC 2009 OpenGL Barthold
 
NVIDIA Graphics, Cg, and Transparency
NVIDIA Graphics, Cg, and TransparencyNVIDIA Graphics, Cg, and Transparency
NVIDIA Graphics, Cg, and Transparency
 
OpenGL basics
OpenGL basicsOpenGL basics
OpenGL basics
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
 
OpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUOpenGL ES and Mobile GPU
OpenGL ES and Mobile GPU
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
 
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsGFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
 
Hardware Shaders
Hardware ShadersHardware Shaders
Hardware Shaders
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014
 
Open GL ES Android
Open GL ES AndroidOpen GL ES Android
Open GL ES Android
 
OpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsOpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI Platforms
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
CAD STANDARDS
CAD STANDARDSCAD STANDARDS
CAD STANDARDS
 
openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).ppt
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.ppt
 
Graphics Libraries
Graphics LibrariesGraphics Libraries
Graphics Libraries
 

Mais de Jungsoo Nam

AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by stepJungsoo Nam
 
Android Grabber Module Proposal
Android Grabber Module ProposalAndroid Grabber Module Proposal
Android Grabber Module ProposalJungsoo Nam
 
Unity3D Audio Grabber design
Unity3D Audio Grabber designUnity3D Audio Grabber design
Unity3D Audio Grabber designJungsoo Nam
 
Android OpenGL ES Game ImageGrabber Final Report
Android OpenGL ES Game ImageGrabber Final ReportAndroid OpenGL ES Game ImageGrabber Final Report
Android OpenGL ES Game ImageGrabber Final ReportJungsoo Nam
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScriptJungsoo Nam
 

Mais de Jungsoo Nam (6)

NVIDIA CUDA
NVIDIA CUDANVIDIA CUDA
NVIDIA CUDA
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by step
 
Android Grabber Module Proposal
Android Grabber Module ProposalAndroid Grabber Module Proposal
Android Grabber Module Proposal
 
Unity3D Audio Grabber design
Unity3D Audio Grabber designUnity3D Audio Grabber design
Unity3D Audio Grabber design
 
Android OpenGL ES Game ImageGrabber Final Report
Android OpenGL ES Game ImageGrabber Final ReportAndroid OpenGL ES Game ImageGrabber Final Report
Android OpenGL ES Game ImageGrabber Final Report
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScript
 

Último

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Último (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

OpenGL Shading Language

  • 1. OpenGL Shading Languages (GLSL) SK planet/Mobile Platform Dept. Jungsoo Nam namjungsoo@gmail.com
  • 2. Graphics Programming • Generates – 2D Programming • GDI, Quartz, Canvas • DirectDraw – 3D Programming • Direct3D, OpenGL • Post Processing – Image Processing, Computer Vision • OpenCV • OpenCL, CUDA, RenderScript
  • 3. 3D Graphics Programming • Inputs – Vertex Processing • Vertices(Positions), Lights, Colors, Texture Coordinates – Fragment Processing • Texture Coordinates, Texture Images • Outputs – Vertex Processing • Vertices, Texture Coordinates and Colors • Polygons – Fragment Processing • Pixels, Depth
  • 4. Shading • Shading – Shading refers to depicting depth perception in 3D models or illustrations by varying levels of darkness. – In computer graphics, shading refers to the process of altering the color of an object/surface/polygon in the 3D scene, based on its angle to lights and its distance from lights to create a photorealistic effect. Shading is performed during the rendering process by a program called a shader.
  • 6. OpenGL ES 2.0 Rendering Pipeline – Fixed Function Pipeline removed
  • 8. Transform and Lighting surfaceColor = emissive + ambient + diffuse + specular emissive = Ke ambient = Ka x globalAmbient diffuse = Kd x lightColor x max(N · L, 0) specular = Ks x lightColor x facing x (max(N · H, 0)) shininess
  • 11. GPU Programming • Writing programmable vertex/fragment programs(shaders)
  • 18. Cg vs GLSL • Advantage of Cg – Supports both of Direct3D/OpenGL – Supports Old VGAs(before OpenGL 2.0) – Supports nVIDIA OpenGL Extensions – Direct3D compatibility(HLSL and Cg, HLSL Effect and CgFX – Possible to assembly optimization • Advantage of GLSL – OpenGL Standard(for OpenGL only users and new comers) • No extra runtimes(Cg.dll, CgGL.dll, …) • Supports OpenGL ES(Android, iOS, WebGL)
  • 19. OpenGL Versions OpenGL Version Comments 1.0~1.5 Direct3D 8.0~9.0b Shader Model 1.0~2.0a Cg 2.0 Direct3D 9.0c Shader Model 3.0 OpenGL Shading Language 3.0 Direct3D 10 Shader Model 4.0 Deprecated features include: • All fixed-function vertex and fragment processing. • Direct-mode rendering, using glBegin and glEnd. • Display lists. • Indexed-color rendering targets. • OpenGL Shading Language versions 1.10 and 1.20. 3.3 Geforce 8 4.0 Direct3D 11 Shader Model 5.0 4.1 OpenGL ES 2.0 4.2 OpenGL ES 3.0 DirectX Version Description 8.0 Shader Model 1.0 & 1.1, Geforce 3 8.0a Shader Model 1.3 8.1 Shader Model 1.4, ATI Radeon 8500 9.0 Shader Model 2.0, Geforce FX(5) HLSL 9.0a Shader Model 2.0a 9.0b Shader Model 2.0b 9.0c Shader Model 3.0, Geforce 6 10.0* Shader Model 4.0, Geforce 8, Geometry Shader 10.1* Shader Model 4.1, Geforce 200 11.0* Shader Model 5.0, Geforce 400, Compute Shader 11.1*+ Shader Model 5.0, Geforce 600 *Not available for Windows XP OS †Only available for Windows 8 OS
  • 20. OpenGL Extensions • OpenGL Extensions – OpenGL Extensions are usually made available to access new features of 3D graphics hardware. Hardware vendors define new functions and/or tokens that enhance the existing features of OpenGL. • Extensions created by a single vendor are called "vendor-specific" and extensions created by several vendors are called "multivendor" extensions. • If a vendor-specific or multivendor extension proves to be a good enhancement, the OpenGL Architecture Review Board (ARB) may promote it to an "ARB approved" extension. • If the extension is very useful, the ARB may decide to integrate the extension as a "core feature" to OpenGL. This happened for example with the OpenGL Shading Language which is now a core feature of OpenGL 2.0 and higher. – Detecting extensions • const GLubyte* sExtensions = glGetString(GL_EXTENSIONS); – Naming conventions • GL(PLATFORM)_VENDOR_extension_name • VENDOR – ARB Architecture Review Board approved extension – EXT Multivendor Extension – APPLE Extension from Apple Computer, Inc. – ATI Extension from ATI Technologies, Inc. (AMD) – HP Extension from Hewlett Packard. – NV Extension from NVIDIA Corporation – SGIS Extension from Silicon Graphics, Inc. • PLATFORM: WGL, GLX, EGL – GLSL required extensions • ARB vertex shader • ARB fragment shader • ARB shader objects • ARB geometry shader 4 • ARB tessellation shader
  • 21. GLSL Versions • Until version 3.30, the GLSL version number and the corresponding OpenGL version number were different. Here's a table: • Direct3D Shader Model 4.0 is equivalent to GLSL version 3.30. Earlier GLSL versions for OpenGL 3.x provide subsets of this functionality, based on the available functionality in the OpenGL version, though 1.50 is almost feature-identical to SM4 • Direct3D Shader Model 5.0 is equivalent to GLSL version 4.30. • http://www.opengl.org/wiki/Detecting_the_Shader_Model OpenGL Version GLSL Version 2.0 1.10 2.1 1.20 3.0 1.30 3.1 1.40 3.2 1.50
  • 22. Shader Model(SM) Numbers • ARB Assembly Language • These are done through testing the presence of extensions. You should test them in this order: • GL_NV_gpu_program4: SM 4.0 or better. • GL_NV_vertex_program3: SM 3.0 or better. • GL_ARB_fragment_program: SM 2.0 or better. • ATI does not support higher than SM 2.0 functionality in assembly shaders. • http://msdn.microsoft.com/en- us/library/windows/desktop/bb509626(v=vs.85).aspx (Although gs_4_0, gs_4_1, ps_4_0, ps_4_1, vs_4_0, and vs_4_1 were introduced in shader model 4.0, shader model 5 adds support to these shader profiles for structured buffers and byte address buffers.) Shader Model Shader Profiles Shader Model 1 vs_1_1 Shader Model 2 ps_2_0, ps_2_x, vs_2_0, vs_2_x, ps_4_0_level_9_0, ps_4_0_level_9_1, ps_4_0_level_9_3, vs_4_0_level_9_0, vs_4_0_level_9_1, vs_4_0_level_9_3, lib_4_0_level_9_1, lib_4_0_level_9_3 Shader Model 3 ps_3_0, vs_3_0 Shader Model 4 cs_4_0, gs_4_0, ps_4_0, vs_4_0, cs_4_1, gs_4_1, ps_4_1, vs_4_1, lib_4_0, lib_4_1 Shader Model 5 cs_5_0, ds_5_0, gs_5_0, hs_5_0, ps_5_0, vs_5_0, lib_5_0
  • 23. Shader Model 3 Example
  • 24. OpenGL ES Versions Version Description OpenGL ES 1.0 Android Standard • Quad and polygon rendering primitives, • Texgen, line and polygon stipple, • Polygon mode and antialiased polygon rendering are not supported, although rendering using multisample is still possible (rather than alpha border fragments), • ARB_Image pixel class operation are not supported, nor are bitmaps or 3D textures, • Several of the more technical drawing modes are eliminated, including frontbuffer and accumulation buffer. Bitmap operations, specifically copying pixels (individually) is not allowed, nor are evaluators, nor (user) selection operations, • Display lists and feedback are removed, as are push and pop operations for state attributes, • Some material parameters were removed, including back-face parameters and user defined clip planes. OpenGL ES 1.1 Android 1.6 • Better multitexture support (including combiners and dot product texture operations) • Automatic mipmap generation • Vertex buffer objects • State queries • User clip planes • Greater control over point rendering OpenGL ES 2.0 Android 2.0(NDK), 2.2 • Eliminates most of the fixed-function rendering pipeline in favor of a programmable one in a move similar to transition from OpenGL 3.0 to 3.1. • Almost all rendering features of the transform and lighting stage, such as the specification of materials and light parameters formerly specified by the fixed-function API, are replaced by shaders written by the graphics programmer. • As a result, OpenGL ES 2.0 is not backward compatible with OpenGL ES 1.1. OpenGL ES 3.0 Android 4.3 Samsung S4(Snapdragon )/Nexus5, 7(2013)/LG G2 OpenGL ES 3.0 is backwards compatible with OpenGL ES 2.0, enabling applications to incrementally add new visual features to applications. OpenGL 4.3 provides full compatibility with OpenGL ES 3.0. • Multiple enhancements to the rendering pipeline to enable acceleration of advanced visual effects including: occlusion queries, transform feedback, instanced rendering and support for four or more rendering targets • High quality ETC2 / EAC texture compression as a standard feature, eliminating the need for a different set of textures for each platform • A new version of the GLSL ES shading language[8] with full support for integer and 32-bit floating point operations • Greatly enhanced texturing functionality including guaranteed support for floating point textures, 3D textures, depth textures, vertex textures, NPOT textures, R/RG textures, immutable textures, 2D array textures, swizzles, LOD and mip level clamps, seamless cube maps and sampler objects • An extensive set of required, explicitly sized texture and render-buffer formats, reducing implementation variability and making it much easier to write portable applications
  • 25. WebGL • WebGL – WebGL is based on OpenGL ES 2.0 and provides an API for 3D graphics. – Like OpenGL ES 2.0, WebGL does not have the fixed-function APIs introduced in OpenGL 1.0 and deprecated in OpenGL 3.0. • Strictly speaking, WebGL is a dialect of OpenGL ES 2.0 – http://learningwebgl.com/lessons/
  • 26. GLSL – Simple Example ftransform() is used for fixed function pipeline.
  • 27. GLSL - Build-in Variables(1/2)
  • 28. GLSL - Build-in Variables(1/2)
  • 29. GLSL keywords – attribute, uniform, varying • (Vertex) Attribute – Vertex attributes are used to communicate from outside to the vertex shader. • Unlike uniform variables, values are provided per vertex (and not globally for all vertices). • There are built-in vertex attributes like the normal or the position, or you can specify your own vertex attribute like a tangent or another custom value. • Attributes can't be defined in the fragment shader. • Uniform – Uniform variables are used to communicate with your vertex or fragment shader from "outside". In your shader you use the uniform qualifier to declare the variable • Uniform variables are read-only and have the same value among all processed vertices. You can only change them within your C++ program. • Varying – Varying variables provide an interface between Vertex and Fragment Shader. • Vertex Shaders compute values per vertex and fragment shaders compute values per fragment. • If you define a varying variable in a vertex shader, its value will be interpolated (perspective-correct) over the primitive being rendered and you can access the interpolated value in the fragment shader.
  • 30. GLSL APIs • GLSL flow APIs – Loading Shader • glCreateShaderObject • glShaderSource – Compiling Shader • glCompileShader – Linking • glCreateProgramObject • glAttachObject • glLinkProgram – Using Shaders • glUseProgramObject • GLSL communication APIs – Attribute • glGetAttribLocation • glEnableVertexAttribArray • glVertexAttribPointer – Uniform • glGetUniformLocation • glUniform
  • 31. Vertex Shader Example – Directional Lighting void main() { vec3 normal, lightDir, viewVector, halfVector; vec4 diffuse, ambient, globalAmbient, specular = vec4(0.0); float NdotL,NdotHV; /* first transform the normal into eye space and normalize the result */ normal = normalize(gl_NormalMatrix * gl_Normal); /* now normalize the light's direction. Note that according to the OpenGL specification, the light is stored in eye space. Also since we're talking about a directional light, the position field is actually direction */ lightDir = normalize(vec3(gl_LightSource[0].position)); /* compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. */ NdotL = max(dot(normal, lightDir), 0.0); /* Compute the diffuse, ambient and globalAmbient terms */ diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse; ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient; globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient; /* compute the specular term if NdotL is larger than zero */ if (NdotL > 0.0) { NdotHV = max(dot(normal, normalize(gl_LightSource[0].halfVector.xyz)),0.0); specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(NdotHV,gl_FrontMaterial.shininess); } gl_FrontColor = globalAmbient + NdotL * diffuse + ambient + specular; gl_Position = ftransform(); }
  • 32. Fragment Shader Example – Per Pixel Directional Lighting http://www.lighthouse3d.com/tutorials/glsl-tutorial/directional-light-per-pixel/
  • 33. Fragment Shader Example – YUV to RGB Conversion http://helloworld.naver.com/helloworld/1207
  • 34. Fragment Shader Example – Image Filter(Box Blur) attribute vec2 vPosition; attribute vec2 vTexCoord; uniform float texelWidthOffset; uniform float texelHeightOffset; uniform highp float blurSize; varying vec2 centerTextureCoordinate; varying vec2 oneStepLeftTextureCoordinate; varying vec2 twoStepsLeftTextureCoordinate; varying vec2 oneStepRightTextureCoordinate; varying vec2 twoStepsRightTextureCoordinate; void main() { gl_Position = vPosition; vec2 firstOffset = vec2(1.5 * texelWidthOffset, 1.5 * texelHeightOffset) * blurSize; vec2 secondOffset = vec2(3.5 * texelWidthOffset, 3.5 * texelHeightOffset) * blurSize; centerTextureCoordinate = vTexCoord; oneStepLeftTextureCoordinate = vTexCoord - firstOffset; twoStepsLeftTextureCoordinate = vTexCoord - secondOffset; oneStepRightTextureCoordinate = vTexCoord + firstOffset; twoStepsRightTextureCoordinate = vTexCoord + secondOffset; } precision mediump float; uniform sampler2D sTexture; varying vec2 centerTextureCoordinate; varying vec2 oneStepLeftTextureCoordinate; varying vec2 twoStepsLeftTextureCoordinate; varying vec2 oneStepRightTextureCoordinate; varying vec2 twoStepsRightTextureCoordinate; void main() { lowp vec4 fragmentColor = texture2D(sTexture, centerTextureCoordinate) * 0.2; fragmentColor += texture2D(sTexture, oneStepLeftTextureCoordinate) * 0.2; fragmentColor += texture2D(sTexture, oneStepRightTextureCoordinate) * 0.2; fragmentColor += texture2D(sTexture, twoStepsLeftTextureCoordinate) * 0.2; fragmentColor += texture2D(sTexture, twoStepsRightTextureCoordinate) * 0.2; gl_FragColor = fragmentColor; }
  • 38. Fragment Shader vs Compute Shader
  • 39. Geometry Shader //GEOMETRY SHADER #version 120 #extension GL_ARB_geometry_shader4 : enable /////////////////////// void main() { //increment variable int i; vec4 vertex; ///////////////////////////////////////////////////////////// //This example has two parts // step a) draw the primitive pushed down the pipeline // there are gl_VerticesIn # of vertices // put the vertex value into gl_Position // use EmitVertex => 'create' a new vertex // use EndPrimitive to signal that you are done creating a primitive! // step b) create a new piece of geometry // I just do the same loop, but I negate the vertex.z // result => the primitive is now mirrored. //Pass-thru! for(i = 0; i < gl_VerticesIn; i++) { gl_Position = gl_PositionIn[i]; EmitVertex(); } EndPrimitive(); //New piece of geometry! for(i = 0; i < gl_VerticesIn; i++) { vertex = gl_PositionIn[i]; vertex.z = -vertex.z; gl_Position = vertex; EmitVertex(); } EndPrimitive(); }