SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Moving Frostbite to Physically Based Rendering
Moving Frostbite to Physically Based RenderingMoving Frostbite to Physically Based Rendering
Moving Frostbite to Physically Based RenderingElectronic Arts / DICE
 
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
 
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla MahGS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla MahAMD Developer Central
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and MoreMark Kilgard
 
Rendering Technologies from Crysis 3 (GDC 2013)
Rendering Technologies from Crysis 3 (GDC 2013)Rendering Technologies from Crysis 3 (GDC 2013)
Rendering Technologies from Crysis 3 (GDC 2013)Tiago Sousa
 
Raster animation
Raster animationRaster animation
Raster animationabhijit754
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility bufferWolfgang Engel
 
Future Directions for Compute-for-Graphics
Future Directions for Compute-for-GraphicsFuture Directions for Compute-for-Graphics
Future Directions for Compute-for-GraphicsElectronic Arts / DICE
 
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)Philip Hammer
 
Skia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics EssentialsSkia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics EssentialsKyungmin Lee
 
Parallel Futures of a Game Engine
Parallel Futures of a Game EngineParallel Futures of a Game Engine
Parallel Futures of a Game EngineJohan Andersson
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for GamesUmbra
 
Rational Rhapsody Workflow Integration with Visual Studio
Rational Rhapsody Workflow Integration with Visual Studio Rational Rhapsody Workflow Integration with Visual Studio
Rational Rhapsody Workflow Integration with Visual Studio Frank Braun
 

What's hot (20)

DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3
 
Moving Frostbite to Physically Based Rendering
Moving Frostbite to Physically Based RenderingMoving Frostbite to Physically Based Rendering
Moving Frostbite to Physically Based Rendering
 
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
 
Hair in Tomb Raider
Hair in Tomb RaiderHair in Tomb Raider
Hair in Tomb Raider
 
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla MahGS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
Rendering Technologies from Crysis 3 (GDC 2013)
Rendering Technologies from Crysis 3 (GDC 2013)Rendering Technologies from Crysis 3 (GDC 2013)
Rendering Technologies from Crysis 3 (GDC 2013)
 
Raster animation
Raster animationRaster animation
Raster animation
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility buffer
 
Hardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for AndroidHardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for Android
 
Future Directions for Compute-for-Graphics
Future Directions for Compute-for-GraphicsFuture Directions for Compute-for-Graphics
Future Directions for Compute-for-Graphics
 
Shiny PC Graphics in Battlefield 3
Shiny PC Graphics in Battlefield 3Shiny PC Graphics in Battlefield 3
Shiny PC Graphics in Battlefield 3
 
Global illumination
Global illuminationGlobal illumination
Global illumination
 
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
 
Frostbite on Mobile
Frostbite on MobileFrostbite on Mobile
Frostbite on Mobile
 
Skia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics EssentialsSkia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics Essentials
 
fractals
fractalsfractals
fractals
 
Parallel Futures of a Game Engine
Parallel Futures of a Game EngineParallel Futures of a Game Engine
Parallel Futures of a Game Engine
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for Games
 
Rational Rhapsody Workflow Integration with Visual Studio
Rational Rhapsody Workflow Integration with Visual Studio Rational Rhapsody Workflow Integration with Visual Studio
Rational Rhapsody Workflow Integration with Visual Studio
 

Viewers also liked

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
 
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
 

Viewers also liked (12)

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
 
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
 

Similar to 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
 

Similar to 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
 

More from 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
 
OpenGL ES EGL Spec&APIs
OpenGL ES EGL Spec&APIsOpenGL ES EGL Spec&APIs
OpenGL ES EGL Spec&APIsJungsoo Nam
 

More from Jungsoo Nam (7)

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
 
OpenGL ES EGL Spec&APIs
OpenGL ES EGL Spec&APIsOpenGL ES EGL Spec&APIs
OpenGL ES EGL Spec&APIs
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

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(); }