GLSL. OpenGL Shading Language. OpenGL 1.5 Logical Diagram. OpenGL 2.0 Logical Diagram

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "GLSL. OpenGL Shading Language. OpenGL 1.5 Logical Diagram. OpenGL 2.0 Logical Diagram"

Transcription

1 OpenGL Shading Language GLSL Is a high level shading language based on the C programming language. It was created by the OpenGL ARB to give developers more direct control of the graphics pipeline without having to use assembly language or hardware-specific languages. Originally introduced as an extension to OpenGL 1.4, the OpenGL ARB formally included GLSL into the OpenGL 2.0 core. OpenGL 2.0 is the first major revision to OpenGL since the creation of OpenGL 1.0 in OpenGL 4.0 has just been announced! OpenGL 1.5 Logical Diagram OpenGL 2.0 Logical Diagram

2 Vertex Processor Capabilities Lighting, material and geometry flexibility Vertex processor can do general processing, including things like: Vertex transformation Normal transformation, normalization and rescaling Lighting Colour material application Clamping of colours Texture co-ordinate generation Texture co-ordinate transformation Vertex Processor Overview Fragment Processor Capabilities Fragment Processor Overview Fragment processor can do general processing, including things like: Operations on interpolated values!pixel zoom Texture access :- Scale and bias Texture application :- Colour table lookup Fog! Convolution Colour sum!colour matrix

3 Vertex Processor Input Vertex shader is executed once each time a vertex position is specified Via glvertex or gldrawarrays or other vertex array calls Per-vertex input values are called attributes E.g., colour, normal, position, arbitrary values Change every vertex Passed through normal OpenGL mechanisms (per-vertex API or vertex arrays) More persistent input values are called uniforms E.g., lights, material properties, arbitrary values Can come from OpenGL state or from the application Constant across at least one primitive, typically constant for many primitives Passed through new OpenGL API calls Vertex Processor Output Vertex shader uses input values to compute output values Vertex shader must compute gl_position Mandatory, needed by the rasterizer Can use built-in function ftransform() to get invariance with fixed functionality Vertex shader may compute: gl_clipvertex (if user clipping is to be performed) gl_pointsize (if point parameters are to be used) Vertex Processor Output Other output values are called varying variables E.g., colour, texture co-ordinates, arbitrary data Will be interpolated in a perspective-correct fashion across the primitives Defined by the vertex shader Can be of type float, vec2, vec3, vec4, mat2, mat3, mat4, or arrays of these Output of vertex processor feeds into OpenGL fixed functionality If a fragment shader is active, output of vertex shader must match input of fragment shader If no fragment shader is active, output of vertex shader must match the needs of fixed functionality fragment processing Vertex Processor Definition The vertex processor executes the vertex shader The vertex processor has knowledge of only the current vertex An implementation may have multiple vertex processors operating in parallel

4 Fragment Processor Input Output of vertex shader is the input to the fragment shader Compatibility is checked when linking occurs Compatibility between the two is based on varying variables that are defined in both shaders and that match in type and name Fragment shader is executed for each fragment produced by rasterization For each fragment, fragment shader has access to the interpolated value for each varying variable Colour, normal, texture coordinates, arbitrary values Fragment Processor Input Fragment shader may access: gl_frontfacing contains facingness of primitive that produced the fragment gl_fragcoord contains computed window relative coordinates x, y, z, 1/w Uniform variables are also available OpenGL state or supplied by the application, same as for vertex shader If no vertex shader is active, fragment shader get the results of OpenGL fixed functionality Fragment Processor Output Output of the fragment processor goes on to the fixed function fragment operations and frame buffer operations using built-in variables gl_fragcolor computed R, G, B, A for the fragment gl_fragdepth computed depth value for the fragment Both values are destined for writing into the frame buffer if back end tests all pass Clamping or format conversion to the target buffer is done automatically outside of the fragment shader Fragment Processor Definition The fragment processor executes the fragment shader The fragment processor has knowledge of only the current fragment An implementation may have multiple fragment processors operating in parallel

5 GLSL Language Syntax GLSL Language syntax is very similar to that of Renderman SL Most of the usual data types are present Other elements are available to fit into the GL pipeline marble.vertex 1 uniform vec3 LightPosition; 2 varying vec3 vpos; 3 varying float LightIntensity; 4 5 const float SpecularContribution = 0.3; 6 const float DiffuseContribution = SpecularContribution; 7 8 void main() 9 { 10 vec3 ecposition = vec3(gl_modelviewmatrix * gl_vertex); 11 vec3 tnorm = normalize(gl_normalmatrix * gl_normal); 12 vec3 lightvec = normalize(lightposition - ecposition); 13 vec3 reflectvec = reflect(-lightvec, tnorm); 14 vec3 viewvec = normalize(-ecposition); 15 float diffuse = max(dot(lightvec, tnorm), 0.0); 16 float spec = 0.0; if (diffuse > 0.0) { 19 spec = dot(reflectvec, viewvec); 20 spec = pow(spec, 16.0); 21 } LightIntensity = DiffuseContribution * diffuse + 24 SpecularContribution * spec; gl_position = ftransform(); 27 vpos = gl_vertex.xyz; gl_frontcolor = vec4(lightintensity, LightIntensity, LightIntensity, 1.0); } marble.fragment 1 uniform vec3 stretch; 2 uniform vec3 color_a, color_b; 3 varying vec3 vpos; 4 varying float LightIntensity; 5 6 void main() { 7 float f; 8 vec3 color; 9 10 f = float(noise3(vpos * stretch)); 11 f = abs(f) + 0.8; 12 f = pow(f, 7.0); 13 f = clamp(f, 0.0, 1.0); 14 color = mix(color_a, color_b, f); 15 color *= LightIntensity; gl_fragcolor = vec4(color, 1); 18 }

6 Source Code When Using GLSL the Shader source code is loaded into the program One for each Fragment and Vertex Shader required. We can load as many as we need. This is then compiled and sent to the graphics card. We then load the appropriate shader at render time to do the drawing. Source Code The source code for a shader consists of an array of strings Each string may contain multiple lines of source code, separated by new-lines A line of source code may be made of multiple strings Compiler diagnostic messages identify the source string and the line within the string that caused the error Source strings are numbered starting from 0 When parsing, current line number is number of new-lines processed plus 1 Loading Shader Code 1 bool ReadShader( 2 const std::string &_fname, 3 char **io_sourcebuffer 4 ) 5 { 6 std::fstream FileIn; 7 FileIn.open(_fname.c_str(),std::ios::in); 8 if (!FileIn.is_open()) 9 { 10 std::cout <<"File : "<<_fname<<" Not found"<<std::endl; 11 return false; 12 } 13 // grab the file lenght 14 FileIn.seekg (0, std::ios::end); 15 int length = FileIn.tellg(); 16 FileIn.seekg (0, std::ios::beg); // allocate memory: 19 *io_sourcebuffer = new char [length]; // read data as a block: 22 FileIn.read (*io_sourcebuffer,length); FileIn.close(); return true; 27 } Checking to see if GLSL available 1 void InitGLSL(void) 2 { 3 4 glewinit(); 5 if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader) 6 printf("ready for GLSL\n"); 7 else { 8 printf("no GLSL support\n"); 9 exit(1); 10 } }

7 1 GLhandleARB InstallShaders( 2 const std::string &_vertexshader, 3 const std::string &_fragmentshader 4 ) 5 { 6 GLhandleARB vertex; 7 GLhandleARB fragment; 8 GLhandleARB shaderprog; 9 GLint vertcompiled; 10 GLint fragcompiled; // status values 11 GLint linked; // Create a vertex shader object and a fragment shader object 14 vertex = glcreateshaderobjectarb(gl_vertex_shader_arb); 15 fragment = glcreateshaderobjectarb(gl_fragment_shader_arb); 16 std::cout <<"Shader ID's VS="<<vertex<<" FS="<<fragment<<std::endl; 17 // Load source code strings into shaders 18 char *shadersource; 19 ReadShader(_fragmentShader,&shadersource); 20 glshadersourcearb(fragment, 1, (const GLcharARB**)&shadersource, NULL); 21 glcompileshaderarb(fragment); 22 PrintOpenGLError(); // Check for OpenGL errors 23 glgetobjectparameterivarb(fragment,gl_object_compile_status_arb, &fragcompiled); 24 PrintInfoLog(fragment); 25 delete [] shadersource; ReadShader(_vertexShader,&shadersource); 28 glshadersourcearb(vertex, 1, (const GLcharARB**)&shadersource, NULL); 29 glcompileshaderarb(vertex); 30 PrintOpenGLError(); // Check for OpenGL errors 31 glgetobjectparameterivarb(vertex,gl_object_compile_status_arb, &vertcompiled); 32 PrintInfoLog(vertex); delete [] shadersource; // compile the shader and print out the results 37 if (!vertcompiled!fragcompiled) 38 { 39 std::cout << "Compilation error"<<" Vert = "<<vertcompiled<<" Frag = "<<fragcompiled<< std::endl; return 0; } 42 // Create a program object and attach the two compiled shaders shaderprog = glcreateprogramobjectarb(); 45 glattachobjectarb(shaderprog, vertex); 46 glattachobjectarb(shaderprog, fragment); 47 // Link the program object and print out the info log 48 gllinkprogramarb(shaderprog); 49 PrintOpenGLError(); // Check for OpenGL errors glgetobjectparameterivarb(shaderprog,gl_object_link_status_arb, &linked); 52 PrintInfoLog(shaderProg); if (!linked) 55 { 56 std::cout << "link error"<<std::endl; 57 return false; 58 } // Install program object as part of current state gluseprogramobjectarb(shaderprog); 63 return shaderprog; 64 } Using the Shaders Once the shader is loaded and made active it replaces the Fixed Function OpenGL Pipeline 1 void LoadShaders( 2 GLhandleARB &_currentshader 3 ) 4 { 5 _currentshader=installshaders("../shaders/marble.vertex","../shaders/marble.fragment"); 6 gluniform3farb(getuniloc(_currentshader, "LightPosition"), 0.0, 1.0, 0.0); 7 gluniform3farb(getuniloc(_currentshader, "color_a"), 1.0, 0.3, 0.1); 8 gluniform3farb(getuniloc(_currentshader, "color_b"), 0.2, 0.3, 0.2); 9 gluniform3farb(getuniloc(_currentshader, "stretch"),2, 2, 2); 10 } 1 case SDLK_1 : gluseprogramobjectarb(currentshader); break; 2 case SDLK_2 : gluseprogramobjectarb(null); break; 3 4 case SDLK_EQUALS : 5 Stretch+=0.5; 6 gluniform3farb(getuniloc(currentshader, "stretch"),stretch,stretch,stretch); 7 break; 8 9 case SDLK_MINUS : 10 Stretch-=0.5; 11 gluniform3farb(getuniloc(currentshader, "stretch"),stretch,stretch,stretch); 12 break; minimal Shaders Using Multiple Shaders 1 // Min Fragment Shader 2 3 void main() 4 { 5 // set to red 6 gl_fragcolor=vec4(1.0,0.0,0.0,1.0); 7 } 8 9 // min vertex shader void main() 12 { 13 // set the position using built in 14 gl_position= ftransform(); 15 } For each shader we need to load, compile and link We then store the Handle to the shader Object. When we wish to use the shader object we use a call to gluseprogramobjectarb

8 Setting Shader Parameters To Set parameters to a shader we use the following code to get access to the shader Object and Parameter Setting Shader Parameters Depending Upon the Parameter to be set we use the following 1 GLint getuniloc(glhandlearb program, const GLcharARB *name) 2 { 3 GLint loc; 4 5 loc = glgetuniformlocationarb(program, name); 6 7 if (loc == -1) 8 printf("no such uniform named \"%s\"\n", name); 9 10 return loc; 11 } 1 p[2] = LoadShaders("../Shaders/brick.vert","../Shaders/brick.frag"); 2 gluseprogramobjectarb(p[2]); 3 4 gluniform3farb(getuniloc(p[2], "BrickColor"), 1.0, 0.3, 0.2); 5 gluniform3farb(getuniloc(p[2], "MortarColor"), 0.85, 0.86, 0.84); 6 gluniform2farb(getuniloc(p[2], "BrickSize"), 0.30, 0.15); 7 gluniform2farb(getuniloc(p[2], "BrickPct"), 0.90, 0.85); 8 gluniform3farb(getuniloc(p[2], "LightPosition"), 0.0, 2.0, 4.0); Brick Fragment Shader 1 // See 3Dlabs-License.txt for license information 2 uniform vec3 BrickColor, MortarColor; 3 uniform vec2 BrickSize; 4 uniform vec2 BrickPct; 5 6 varying vec2 MCposition; 7 varying float LightIntensity; 8 9 void main(void) 10 { 11 vec3 color; 12 vec2 position, usebrick; position = MCposition / BrickSize; if (fract(position.y * 0.5) > 0.5) 17 position.x += 0.5; position = fract(position); usebrick = step(position, BrickPct); color = mix(mortarcolor, BrickColor, usebrick.x * usebrick.y ); 24 color *= LightIntensity; 25 gl_fragcolor = vec4 (color, 1.0); 26 } Brick Vertex Shader 1 // Copyright (c) Dlabs Inc. Ltd. 2 uniform vec3 LightPosition; 3 4 const float SpecularContribution = 0.7; 5 const float DiffuseContribution = SpecularContribution; 6 7 varying float LightIntensity; 8 varying vec2 MCposition; 9 10 void main(void) 11 { 12 vec3 ecposition = vec3 (gl_modelviewmatrix * gl_vertex); 13 vec3 tnorm = normalize(gl_normalmatrix * gl_normal); 14 vec3 lightvec = normalize(lightposition - ecposition); 15 vec3 reflectvec = reflect(-lightvec, tnorm); 16 vec3 viewvec = normalize(-ecposition); 17 float diffuse = max(dot(lightvec, tnorm), 0.0); 18 float spec = 0.0; if (diffuse > 0.0) 21 { 22 spec = max(dot(reflectvec, viewvec), 0.0); 23 spec = pow(spec, 16.0); 24 } LightIntensity = DiffuseContribution * diffuse + 27 SpecularContribution * spec; MCposition = gl_vertex.xy; 30 gl_position = ftransform(); 31 }

9 Shader Basic Structure A shader is a sequence of declarations and function bodies Curly braces are used to group sequences of statements A shader must have a main function Statements end with a semi-colon Basic Types float, vec2, vec3, vec4 1, 2, 3, or 4 floating point values Preferred data types for most processing int, ivec2, ivec3, ivec4 1, 2, 3, or 4 integer values Integer for loops and array index bool, bvec2, bvec3, bvec4 1, 2, 3, or 4 boolean values As in C++, contains true or false mat2, mat3, mat4 Floating point square matrix Used to perform transformation operations Basic Types void Used for functions that do not return a value sampler1d, sampler2d, sampler3d Handles for accessing 1D, 2D, and 3D textures samplercube Handle for accessing a cube map texture sampler1dshadow, sampler2dshadow Handles for accessing 1D or 2D depth textures with an implicit comparison operation All Used in conjunction with texture access functions 1 float ramp[10]; 2 vec4 colors[4]; 3 bool results[3]; Arrays structures can be aggregated into arrays Only 1D arrays are supported Size of array can be expressed as an integral constant expression within square brackets ([ ]) Arrays can be declared without a size, and then re-declared later with the same type and a size Using an index that goes beyond an array s bounds results in undefined behavior

10 structs 1 struct surfacematerial 2 { 3 float ambient; 4 float diffuse; 5 float specular; 6 vec3 basecolor; 7 } surf; 8 9 surfmaterial surf1, surf2; User-defined types can be created using struct with previously defined types Creates a new type called surfacematerial Defines variables of this type called surf, surf1, and surf2 Structures can include arrays Fields are selected using the period (. ) Structure Constructors Constructor for a structure is available once structure is defined Example: 1 struct light 2 { 3 float intensity; 4 vec3 position; 5 }; 6 7 light newlight = light(3.0, vec3(1.0, 2.0, 3.0)); Type Qualifiers const variable is a constant and can only be written during its declaration attribute per-vertex data values provided to the vertex shader uniform (relatively) constant data provided by the application or by OpenGL for use in the shader varying a perspective-correct interpolated value output for vertex shader input for fragment shader in for function parameters copied into a function, but not copied out out for function parameters copied out of a function, but not copied in inout for function parameters copied into and out of a function Vector Components Vector components can be referred to using array syntax or a single letter: [0], [1], [2], [3] r, g, b, a x, y, z, w s, t, p, q This syntax can be used to extract, duplicate, or swizzle components 1 vec4 pos = vec4(1.0, 2.0, 3.0, 4.0); 2 vec4 swiz= pos.wzyx; // swiz = (4.0, 3.0, 2.0, 1.0) 3 vec4 dup = pos.xxyy; // dup = (1.0, 1.0, 2.0, 2.0) 4 5 pos.xw = vec2(5.0, 6.0); // pos = (5.0, 2.0, 3.0, 6.0) 6 pos.wx = vec2(7.0, 8.0); // pos = (8.0, 2.0, 3.0, 7.0) 7 pos.xx = vec2(3.0, 4.0); // illegal - 'x' used twice

11 Matrix Components Matrix components can be accessed using array subscripting syntax A single subscript selects a single column A second subscript selects a component within a column 1 mat4 m; 2 m[1] = vec4(2.0); // sets the second column to all m[0][0] = 1.0; // sets the upper left element to m[2][3] = 2.0; // sets the 4th element of the third 5 // column to 2.0 Declaration Function Examples 1 vec3 computecolor (in vec3 c1, in vec3 c2); 2 float radians (float degrees); Definition 1 float myfunc (in float f1, // f1 is copied in 2 inout float f2) // f2 is copied in and out 3 { 4 float myresult; 5 6 // do computations 7 8 return myresult; 9 } Vertex Shader Built-in Variables The following special variables are available in a vertex shader: 1 vec4 gl_position; // must be written to 2 float gl_pointsize; // may be written to 3 vec4 gl_clipvertex; // may be written to Every execution of a vertex shader must write the homogeneous vertex position into gl_position Can use the built-in function ftransform() to achieve invariance with fixed functionality Vertex shaders may write the size of points to be rasterized (measured in pixels) into the built-in variable gl_pointsize Vertex shaders may write the transformed coordinate to be used in conjunction with user clipping planes into gl_clipvertex Vertex Shader Built-in Attributes The following are available from a vertex shader for accessing standard OpenGL vertex attributes: 1 attribute vec4 gl_color; 2 attribute vec4 gl_secondarycolor; 3 attribute vec3 gl_normal; 4 attribute vec4 gl_vertex; 5 attribute vec4 gl_multitexcoord0; 6 attribute vec4 gl_multitexcoord1; 7 attribute vec4 gl_multitexcoord2; 8 attribute vec4 gl_multitexcoord3; 9 attribute vec4 gl_multitexcoord4; 10 attribute vec4 gl_multitexcoord5; 11 attribute vec4 gl_multitexcoord6; 12 attribute vec4 gl_multitexcoord7; 13 attribute float gl_fogcoord;

12 Built-in Functions Trigonometry/angle radians, degrees, sin, cos, tan, asin, acos, atan Exponential pow, exp2, log2, sqrt, inversesqrt Common abs, sign, floor, ceil, fract, mod, min, max, clamp, mix, step, smoothstep Geometric and matrix length, distance, dot, cross, normalize, ftransform, faceforward, reflect, matrixcompmult Vector relational lessthan, lessthanequal, greaterthan, greaterthanequal, equal, any, all Texture lookup texture1d/2d/3d, texture1d/2d/3dproj, texturecube, texture1d/2dshadow, texture1d/2dshadowproj Fragment shader only dfdx, dfdy, fwidth Noise noise1/2/3/4 Accessing Built In Pipeline GLSL has the ability to access the built in Light and Material Properties Two main structures for this are gl_frontmaterial gl_lightsource[gl_maxlights] The parameters for these (and others) are show in the following slide 1 the vertex normal 2 varying vec3 v_n; 3 4 the number of active lights to evaluate 5 /// this must be set before the shader is used. 6 uniform int numlights; 7 8 void main () 9 { Blinn Shader 10 // set the output colour to black 11 vec4 colour= vec4(0.0); 12 // normalize the vertex normal 13 vec3 N = normalize(v_n); 14 // The Light source vector 15 vec3 L; 16 // the Halfway vector (used for speed) 17 vec3 H; 18 // pre declare the colour contribution values 19 vec4 ambient; 20 vec4 diffuse; 21 vec4 specular; // now loop for active lights for (int i=0; i<numlights; ++i) 26 { 27 // get the Light vector 28 L = normalize(gl_lightsource[i].position.xyz); 29 // get the halfway vector 30 H = normalize(gl_lightsource[i].halfvector.xyz); 31 // ambient just added 32 ambient = gl_frontmaterial.ambient *gl_lightsource[i].ambient; 33 // calculate diffuse based on Lambert's law (L.N) 34 diffuse = gl_frontmaterial.diffuse *gl_lightsource[i].diffuse * max(dot(l, N), 0.0); 35 // calculate specular based on H.NˆShininess 36 specular = gl_frontmaterial.specular *gl_lightsource[i].specular * pow(max(dot(h, N), 0.0), gl_frontmaterial.shininess); combine contribution for the light 37 // 38 colour+=ambient+diffuse+specular; 39 } 40 // finally set the colour clamping between 0 and 1 41 gl_fragcolor = clamp(vec4(colour),0.0,1.0); }

13 References OpenGL Shading Language Addison-Wesley R J Rost 3DLabs OpenGL Shading Language Master Class Lecture Notes Apple GLSL Shader Examples

Vertex & Fragment shaders

Vertex & Fragment shaders Vertex & Fragment shaders The next big step in graphics hardware Adds programmability to the previously fixed rendering pipeline The OpenGL Shading Language (a.k.a. GLSL, glslang) Vertex shaders: programs

More information

Design Focus. GLSL Language Details. Additions from C++ Additions for Graphics

Design Focus. GLSL Language Details. Additions from C++ Additions for Graphics GLSL Language Details Design Focus Based on syntax of ANSI C Some additions to support graphics functionality Some additions from C++ Some differences for a cleaner language design 41 December 9, 2005

More information

GLSL Language Details

GLSL Language Details GLSL Language Details 41 Design Focus Based on syntax of ANSI C Some additions to support graphics functionality Some additions from C++ Some differences for a cleaner language design December 9, 2005

More information

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

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people GLSL Introduction Fu-Chung Huang Thanks for materials from many other people Shader Languages Currently 3 major shader languages Cg (Nvidia) HLSL (Microsoft) Derived from Cg GLSL (OpenGL) Main influences

More information

Introduction to the OpenGL Shading Language

Introduction to the OpenGL Shading Language Introduction to the OpenGL Shading Language Randi Rost Director of Developer Relations, 3Dlabs 08-Dec-2005 1 Why use graphics programmability? Graphics hardware has changed radically Fixed functionality

More information

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

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)! ! The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)! Gordon Wetzstein! Stanford University! EE 267 Virtual Reality! Lecture 4! stanford.edu/class/ee267/! Updates! for 24h lab access:

More information

Supplement to Lecture 22

Supplement to Lecture 22 Supplement to Lecture 22 Programmable GPUs Programmable Pipelines Introduce programmable pipelines - Vertex shaders - Fragment shaders Introduce shading languages - Needed to describe shaders - RenderMan

More information

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

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)! ! The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)! Gordon Wetzstein! Stanford University! EE 267 Virtual Reality! Lecture 4! stanford.edu/class/ee267/! Lecture Overview! Review

More information

Lecture 09: Shaders (Part 1)

Lecture 09: Shaders (Part 1) Lecture 09: Shaders (Part 1) CSE 40166 Computer Graphics Peter Bui University of Notre Dame, IN, USA November 9, 2010 OpenGL Rendering Pipeline OpenGL Rendering Pipeline (Pseudo-Code) 1 f o r gl_vertex

More information

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

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people GLSL Introduction Fu-Chung Huang Thanks for materials from many other people Programmable Shaders //per vertex inputs from main attribute aposition; attribute anormal; //outputs to frag. program varying

More information

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

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples Shader Programming Daniel Wesslén, dwn@hig.se Stefan Seipel, ssl@hig.se Examples 1 Per-pixel lighting Texture convolution filtering 2 Post-processing, animated procedural textures Vertex displacement mapping

More information

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

The Transition from RenderMan to the OpenGL Shading Language (GLSL) 1 The Transition from RenderMan to the OpenGL Shading Language (GLSL) Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International

More information

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

CSE 167: Introduction to Computer Graphics Lecture #7: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016 CSE 167: Introduction to Computer Graphics Lecture #7: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016 Announcements Project 2 due Friday 4/22 at 2pm Midterm #1 on

More information

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

CSE 167: Introduction to Computer Graphics Lecture #13: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015 CSE 167: Introduction to Computer Graphics Lecture #13: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015 Announcements Project 6 due Friday Next Thursday: Midterm #2

More information

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

GLSL 1: Basics. J.Tumblin-Modified SLIDES from: GLSL 1: Basics J.Tumblin-Modified SLIDES from: Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico and

More information

CMPS160 Shader-based OpenGL Programming. All slides originally from Prabath Gunawardane, et al. unless noted otherwise

CMPS160 Shader-based OpenGL Programming. All slides originally from Prabath Gunawardane, et al. unless noted otherwise CMPS160 Shader-based OpenGL Programming All slides originally from Prabath Gunawardane, et al. unless noted otherwise Shader gallery I Above: Demo of Microsoft s XNA game platform Right: Product demos

More information

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

Shaders. Introduction. OpenGL Grows via Extensions. OpenGL Extensions. OpenGL 2.0 Added Shaders. Shaders Enable Many New Effects CSCI 420 Computer Graphics Lecture 4 Shaders Jernej Barbic University of Southern California Shading Languages GLSL Vertex Array Objects Vertex Shader Fragment Shader [Angel Ch. 1, 2, A] Introduction The

More information

GLSL v1.20. Scott MacHaffie Schrödinger, Inc.

GLSL v1.20. Scott MacHaffie Schrödinger, Inc. 1 GLSL v1.20 Scott MacHaffie Schrödinger, Inc. http://www.schrodinger.com Table of Contents Introduction...2 Example 01: Trivial shader...2 Syntax...3 Types of variables...3 Example 02: Materials vertex

More information

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

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics Shader Programming Technical Game Development II Professor Charles Rich Computer Science Department rich@wpi.edu Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS

More information

Introduction to the OpenGL Shading Language (GLSL)

Introduction to the OpenGL Shading Language (GLSL) 1 Introduction to the OpenGL Shading Language (GLSL) This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Mike Bailey mjb@cs.oregonstate.edu

More information

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

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico Programming with OpenGL Shaders I Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico 0 Objectives Shader Basics Simple Shaders Vertex shader Fragment shaders 1 Vertex

More information

Programmable shader. Hanyang University

Programmable shader. Hanyang University Programmable shader Hanyang University Objective API references (will be skipped) Examples Simple shader Phong shading shader INTRODUCTION GLSL(OPENGL SHADING LANGUAGE) Scalar Data types Structure Structures

More information

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

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics Shader Programming Technical Game Development II Professor Charles Rich Computer Science Department rich@wpi.edu Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS

More information

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

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico Programming with OpenGL Shaders I Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico Objectives Shader Programming Basics Simple Shaders Vertex shader Fragment shaders

More information

Objectives. Open GL Shading Language (GLSL)

Objectives. Open GL Shading Language (GLSL) Open GL Shading Language (GLSL) Objectives Shader applications Vertex shaders Fragment shaders Programming shaders Cg GLSL Coupling GLSL to Applications Example applications 1 Vertex Shader Applications

More information

Mobile Application Programing: Android. OpenGL Operation

Mobile Application Programing: Android. OpenGL Operation Mobile Application Programing: Android OpenGL Operation Activities Apps are composed of activities Activities are self-contained tasks made up of one screen-full of information Activities start one another

More information

Advanced Graphics. The Shader knows. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Advanced Graphics. The Shader knows. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd Advanced Graphics The Shader knows Alex Benton, University of Cambridge A.Benton@damtp.cam.ac.uk Supported in part by Google UK, Ltd What is the shader? Local space World space Viewing space Local space

More information

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

Today. Rendering - III. Outline. Texturing: The 10,000m View. Texture Coordinates. Specifying Texture Coordinates in GL Today Rendering - III CS148, Summer 2010 Graphics Pipeline and Programmable Shaders Artist Workflow Siddhartha Chaudhuri 1 2 Outline Texturing: The 10,000m View Intro to textures The fixed-function graphics

More information

Stored Texture Shaders

Stored Texture Shaders Stored Texture Shaders 157 Preparing for Texture Access These steps are the same when using a shader as when using fixed functionality Make a specific texture unit active by calling glactivetexture Create

More information

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

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012 CSE 167: Introduction to Computer Graphics Lecture #8: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012 Announcements Homework project #4 due Friday, November 2 nd Introduction:

More information

2D graphics with WebGL

2D graphics with WebGL 2D graphics with WebGL Some material contained here is adapted from the book s slides. September 7, 2015 (Dr. Mihail) 2D graphics September 7, 2015 1 / 22 Graphics Pipeline (Dr. Mihail) 2D graphics September

More information

GLSL Programming. Nicolas Holzschuch

GLSL Programming. Nicolas Holzschuch GLSL Programming Nicolas Holzschuch GLSL programming C-like language structure: int i, j; i = 2; j = 0; j += i; Functions, loops, branches... Reading your first GSL shader is easy Differences with C New

More information

An Overview GLUT GLSL GLEW

An Overview GLUT GLSL GLEW OpenGL, GLUT, GLEW, GLSL An Overview GLUT GLEW GLSL Objectives Give you an overview of the software that you will be using this semester OpenGL, GLUT, GLEW, GLSL What are they? How do you use them? What

More information

Intro to GPU Programming (OpenGL Shading Language) Cliff Lindsay Ph.D. Student CS WPI

Intro to GPU Programming (OpenGL Shading Language) Cliff Lindsay Ph.D. Student CS WPI Intro to GPU Programming (OpenGL Shading Language) Cliff Lindsay Ph.D. Student CS WPI Talk Summary Topic Coverage Define Shading Languages (loosely) High Level View of GPU Functional Aspects of GPU Example

More information

Today s Agenda. Shaders fundamentals. Programming with shader-based OpenGL

Today s Agenda. Shaders fundamentals. Programming with shader-based OpenGL Today s Agenda Shaders fundamentals Programming with shader-based OpenGL Shaders Like a function call data are passed in, processed, and passed back out -- Shreiner et al, OpenGL Programming Guide GLSL

More information

Mobile Application Programing: Android. OpenGL Operation

Mobile Application Programing: Android. OpenGL Operation Mobile Application Programing: Android OpenGL Operation Activities Apps are composed of activities Activities are self-contained tasks made up of one screen-full of information Activities start one another

More information

Preparing for Texture Access. Stored Texture Shaders. Accessing Texture Maps. Vertex Shader Texture Access

Preparing for Texture Access. Stored Texture Shaders. Accessing Texture Maps. Vertex Shader Texture Access Stored Texture Shaders Preparing for Texture Access These steps are the same when using a shader as when using fixed functionality Make a specific texture unit active by calling glactivetexture Create

More information

Jitter Shaders. Fig 1. The opengl pipeline (simplified).

Jitter Shaders. Fig 1. The opengl pipeline (simplified). Shaders in Jitter Powerful as Jitter is, simple appearing patches often run up against the performance limitations of the computer, especially if we are trying for high resolution. You can't do very many

More information

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

SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming SHADER PROGRAMMING Based on Jian Huang s lecture on Shader Programming What OpenGL 15 years ago could do http://www.neilturner.me.uk/shots/opengl-big.jpg What OpenGL can do now What s Changed? 15 years

More information

Shading Languages. Ari Silvennoinen Apri 12, 2004

Shading Languages. Ari Silvennoinen Apri 12, 2004 Shading Languages Ari Silvennoinen Apri 12, 2004 Introduction The recent trend in graphics hardware has been to replace fixed functionality in vertex and fragment processing with programmability [1], [2],

More information

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016 Computergrafik Matthias Zwicker Universität Bern Herbst 2016 Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading

More information

Mobile Application Programming: Android. OpenGL Operation

Mobile Application Programming: Android. OpenGL Operation Mobile Application Programming: Android OpenGL Operation OpenGL ES C-Based Performance-Oriented Graphics Library Wrapper libraries provided for Java, C#, etc. Produces 2D images from 2D or 3D geometric

More information

Introduction to Shaders.

Introduction to Shaders. Introduction to Shaders Marco Benvegnù hiforce@gmx.it www.benve.org Summer 2005 Overview Rendering pipeline Shaders concepts Shading Languages Shading Tools Effects showcase Setup of a Shader in OpenGL

More information

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

CS4621/5621 Fall Computer Graphics Practicum Intro to OpenGL/GLSL CS4621/5621 Fall 2015 Computer Graphics Practicum Intro to OpenGL/GLSL Professor: Kavita Bala Instructor: Nicolas Savva with slides from Balazs Kovacs, Eston Schweickart, Daniel Schroeder, Jiang Huang

More information

1)Write a shader program that renders a regular pentagon with textured image like the one shown below.

1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Andrew Yenalavitch CSE520 Winter 2015 Quiz 2 Report 1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Use the following provided image for the texture:

More information

COURSE 17: STATE-OF-THE-ART IN SHADING HARDWARE1 CHAPTER 6: THE OPENGL SHADING LANGUAGE 2. Randi J. Rost 3Dlabs, Inc.

COURSE 17: STATE-OF-THE-ART IN SHADING HARDWARE1 CHAPTER 6: THE OPENGL SHADING LANGUAGE 2. Randi J. Rost 3Dlabs, Inc. COURSE 17: STATE-OF-THE-ART IN SHADING HARDWARE1 CHAPTER 6: THE OPENGL SHADING LANGUAGE 2 Randi J. Rost 3Dlabs, Inc. SIGGRAPH 2002 Course Notes 05-August-2002 SIGGRAPH 2002 6-1 State of the Art in Shading

More information

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

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE UGRAD.CS.UBC.C A/~CS314 Mikhail Bessmeltsev 1 WHAT IS RENDERING? Generating image from a 3D scene 2 WHAT IS RENDERING? Generating image

More information

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

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015 WebGL and GLSL Basics CS559 Fall 2015 Lecture 10 October 6, 2015 Last time Hardware Rasterization For each point: Compute barycentric coords Decide if in or out.7,.7, -.4 1.1, 0, -.1.9,.05,.05.33,.33,.33

More information

CS GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1. Markus Hadwiger, KAUST

CS GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1. Markus Hadwiger, KAUST CS 380 - GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1 Markus Hadwiger, KAUST Reading Assignment #4 (until Feb. 23) Read (required): Programming Massively Parallel Processors book, Chapter

More information

Shaders (some slides taken from David M. course)

Shaders (some slides taken from David M. course) Shaders (some slides taken from David M. course) Doron Nussbaum Doron Nussbaum COMP 3501 - Shaders 1 Traditional Rendering Pipeline Traditional pipeline (older graphics cards) restricts developer to texture

More information

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading Objectives Shading in OpenGL Introduce the OpenGL shading methods - per vertex shading vs per fragment shading - Where to carry out Discuss polygonal shading - Flat - Smooth - Gouraud CITS3003 Graphics

More information

Lecture 11 Shaders and WebGL. October 8, 2015

Lecture 11 Shaders and WebGL. October 8, 2015 Lecture 11 Shaders and WebGL October 8, 2015 Review Graphics Pipeline (all the machinery) Program Vertex and Fragment Shaders WebGL to set things up Key Shader Concepts Fragment Processing and Vertex

More information

Waves, Displacement, Reflections. Arun Rao CS 594

Waves, Displacement, Reflections. Arun Rao CS 594 Waves, Displacement, Reflections Arun Rao CS 594 Goals Simple looking waves Waves displace and change orientation of things on top Reflections on surface Partially see through How do we create the Waves?

More information

Shaders. Slide credit to Prof. Zwicker

Shaders. Slide credit to Prof. Zwicker Shaders Slide credit to Prof. Zwicker 2 Today Shader programming 3 Complete model Blinn model with several light sources i diffuse specular ambient How is this implemented on the graphics processor (GPU)?

More information

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October WebGL and GLSL Basics CS559 Fall 2016 Lecture 14 October 24 2016 Review Hardware Rasterization For each point: Compute barycentric coords Decide if in or out.7,.7, -.4 1.1, 0, -.1.9,.05,.05.33,.33,.33

More information

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics CS4621/5621 Fall 2015 Basics of OpenGL/GLSL Textures Basics Professor: Kavita Bala Instructor: Nicolas Savva with slides from Balazs Kovacs, Eston Schweickart, Daniel Schroeder, Jiang Huang and Pramook

More information

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

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 3: Shaders Comp 410/510 Computer Graphics Spring 2018 Programming with OpenGL Part 3: Shaders Objectives Basic shaders - Vertex shader - Fragment shader Programming shaders with GLSL Finish first program void init(void)

More information

OPENGL RENDERING PIPELINE

OPENGL RENDERING PIPELINE CPSC 314 03 SHADERS, OPENGL, & JS UGRAD.CS.UBC.CA/~CS314 Textbook: Appendix A* (helpful, but different version of OpenGL) Alla Sheffer Sep 2016 OPENGL RENDERING PIPELINE 1 OPENGL RENDERING PIPELINE Javascript

More information

OpenGL pipeline Evolution and OpenGL Shading Language (GLSL) Part 2/3 Vertex and Fragment Shaders

OpenGL pipeline Evolution and OpenGL Shading Language (GLSL) Part 2/3 Vertex and Fragment Shaders OpenGL pipeline Evolution and OpenGL Shading Language (GLSL) Part 2/3 Vertex and Fragment Shaders Prateek Shrivastava CS12S008 shrvstv@cse.iitm.ac.in 1 GLSL Data types Scalar types: float, int, bool Vector

More information

MXwendler Fragment Shader Development Reference Version 1.0

MXwendler Fragment Shader Development Reference Version 1.0 MXwendler Fragment Shader Development Reference Version 1.0 This document describes the MXwendler fragmentshader interface. You will learn how to write shaders using the GLSL language standards and the

More information

13 Advanced Rendering and Illumination Methods Advanced Rendering and Illumination Methods

13 Advanced Rendering and Illumination Methods Advanced Rendering and Illumination Methods Chapter 13 Advanced Rendering and Illumination Methods 13-1 Objectives What are shaders? Introduce programmable pipelines Vertex shaders Fragment shaders Introduce shading languages Needed to write shaders

More information

OpenGL shaders and programming models that provide object persistence

OpenGL shaders and programming models that provide object persistence OpenGL shaders and programming models that provide object persistence COSC342 Lecture 22 19 May 2016 OpenGL shaders We discussed forms of local illumination in the ray tracing lectures. We also saw that

More information

Computergraphics Exercise 15/ Shading & Texturing

Computergraphics Exercise 15/ Shading & Texturing Computergraphics Exercise 15/16 3. Shading & Texturing Jakob Wagner for internal use only Shaders Vertex Specification define vertex format & data in model space Vertex Processing transform to clip space

More information

Artistic Rendering with Graphics Shaders

Artistic Rendering with Graphics Shaders Artistic Rendering with Graphics Shaders by A Master Research Paper submitted to the Eastern Michigan University, Department of Computer Science In Partial Fulfillment of the Requirements for the Master

More information

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014 Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014 What is a Shader? Wikipedia: A shader is a computer program used in 3D computer graphics to determine the final surface properties of an object

More information

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL Preview CS770/870 Spring 2017 Open GL Shader Language GLSL Review traditional graphics pipeline CPU/GPU mixed pipeline issues Shaders GLSL graphics pipeline Based on material from Angel and Shreiner, Interactive

More information

LLVM and Clang: Advancing Compiler Technology

LLVM and Clang: Advancing Compiler Technology LLVM and Clang: Advancing Compiler Technology FOSDEM 11 - Feb 5, 2011 What is the LLVM Umbrella Project? Language independent optimizer and code generator Many optimizations, many targets, generates great

More information

Levy: Constraint Texture Mapping, SIGGRAPH, CS 148, Summer 2012 Introduction to Computer Graphics and Imaging Justin Solomon

Levy: Constraint Texture Mapping, SIGGRAPH, CS 148, Summer 2012 Introduction to Computer Graphics and Imaging Justin Solomon Levy: Constraint Texture Mapping, SIGGRAPH, 2001 CS 148, Summer 2012 Introduction to Computer Graphics and Imaging Justin Solomon Instructor: Justin Solomon Email: justin.solomon@stanford.edu Office: Clark

More information

The Rasterization Pipeline

The Rasterization Pipeline Lecture 5: The Rasterization Pipeline Computer Graphics and Imaging UC Berkeley CS184/284A, Spring 2016 What We ve Covered So Far z x y z x y (0, 0) (w, h) Position objects and the camera in the world

More information

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

Converts geometric primitives into images Is split into several independent stages Those are usually executed concurrently Rendering Pipeline Rendering Pipeline Converts geometric primitives into images Is split into several independent stages Those are usually executed concurrently Pipeline 18.10.2013 Steiner- Wallner- Podaras

More information

Objectives. Coupling GLSL to Applications Example applications

Objectives. Coupling GLSL to Applications Example applications GLSL II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico Objectives Coupling GLSL to Applications Example

More information

GPU Programming EE Final Examination

GPU Programming EE Final Examination Name GPU Programming EE 4702-1 Final Examination Monday, 5 December 2016 17:30 19:30 CST Alias Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Exam Total (20 pts) (20 pts) (15 pts) (20 pts) (25 pts)

More information

The Rasterization Pipeline

The Rasterization Pipeline Lecture 5: The Rasterization Pipeline Computer Graphics and Imaging UC Berkeley What We ve Covered So Far z x y z x y (0, 0) (w, h) Position objects and the camera in the world Compute position of objects

More information

SUMMARY. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15. Min H. Kim KAIST School of Computing 18/05/03.

SUMMARY. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15. Min H. Kim KAIST School of Computing 18/05/03. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15 Min H. Kim KAIST School of Computing Materials SUMMARY 2 1 Light blob from PVC plastic Recall: Given any vector w (not necessarily of

More information

OpenGL: What s Coming Down the Graphics Pipeline. Dave Shreiner ARM

OpenGL: What s Coming Down the Graphics Pipeline. Dave Shreiner ARM OpenGL: What s Coming Down the Graphics Pipeline Dave Shreiner ARM shreiner@siggraph.org 1 Syllabus Introduction Rendering Fundamentals Shader Overview Fundamental Techniques Applications [Shreiner] [Shreiner]

More information

Lecture 2. Shaders, GLSL and GPGPU

Lecture 2. Shaders, GLSL and GPGPU Lecture 2 Shaders, GLSL and GPGPU Is it interesting to do GPU computing with graphics APIs today? Lecture overview Why care about shaders for computing? Shaders for graphics GLSL Computing with shaders

More information

GLSL Geometry Shaders

GLSL Geometry Shaders GLSL Geometry Shaders 1 This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License Mike Bailey mjb@cs.oregonstate.edu geometry_shaders.pptx Here s

More information

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

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic. Shading Models There are two main types of rendering that we cover, polygon rendering ray tracing Polygon rendering is used to apply illumination models to polygons, whereas ray tracing applies to arbitrary

More information

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

CS 380 Introduction to Computer Graphics. LAB (1) : OpenGL Tutorial Reference : Foundations of 3D Computer Graphics, Steven J. CS 380 Introduction to Computer Graphics LAB (1) : OpenGL Tutorial 2018. 03. 05 Reference : Foundations of 3D Computer Graphics, Steven J. Gortler Goals Understand OpenGL pipeline Practice basic OpenGL

More information

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

Copyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012 Copyright Khronos Group 2012 Page 1 Teaching GL Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012 Copyright Khronos Group 2012 Page 2 Agenda Overview of OpenGL family of APIs Comparison

More information

1) Here is the various stages of the tetrahedron:

1) Here is the various stages of the tetrahedron: Andrew Yenalavitch Homework 3 CSE 520 - Winter 2015 1) ( 20 points ) Write a shader program that renders a colored tetrahedron, which gradually shrinks to a point and expands back to its original shape.

More information

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

Understanding M3G 2.0 and its Effect on Producing Exceptional 3D Java-Based Graphics. Sean Ellis Consultant Graphics Engineer ARM, Maidenhead Understanding M3G 2.0 and its Effect on Producing Exceptional 3D Java-Based Graphics Sean Ellis Consultant Graphics Engineer ARM, Maidenhead Introduction M3G 1.x Recap ARM M3G Integration M3G 2.0 Update

More information

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker CMSC427 Advanced shading getting global illumination by local methods Credit: slides Prof. Zwicker Topics Shadows Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection

More information

Recall: Indexing into Cube Map

Recall: Indexing into Cube Map Recall: Indexing into Cube Map Compute R = 2(N V)N-V Object at origin Use largest magnitude component of R to determine face of cube Other 2 components give texture coordinates V R Cube Map Layout Example

More information

Graphics Hardware. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 2/26/07 1

Graphics Hardware. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 2/26/07 1 Graphics Hardware Computer Graphics COMP 770 (236) Spring 2007 Instructor: Brandon Lloyd 2/26/07 1 From last time Texture coordinates Uses of texture maps reflectance and other surface parameters lighting

More information

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

OUTLINE. Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction TEXTURE MAPPING 1 OUTLINE Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction 2 BASIC STRAGEGY Three steps to applying a texture 1. specify the texture

More information

Further Graphics. Advanced Shader Techniques. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Further Graphics. Advanced Shader Techniques. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd Further Graphics Advanced Shader Techniques 1 Alex Benton, University of Cambridge alex@bentonian.com Supported in part by Google UK, Ltd Lighting and Shading (a quick refresher) Recall the classic lighting

More information

EECS 487: Interactive Computer Graphics

EECS 487: Interactive Computer Graphics Integrating GLSL with OpenGL EECS 487: Interactive Computer Graphics Lecture 19: Integrating shaders with OpenGL program Vertex-array objects with shaders Miscellaneous shader related stuff Integrating

More information

Sung-Eui Yoon ( 윤성의 )

Sung-Eui Yoon ( 윤성의 ) Introduction to Computer Graphics and OpenGL Graphics Hardware Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/etri_cg/ Class Objectives Understand how GPUs have been evolved Understand

More information

The Graphics Pipeline

The Graphics Pipeline The Graphics Pipeline Lecture 2 Robb T. Koether Hampden-Sydney College Fri, Aug 28, 2015 Robb T. Koether (Hampden-Sydney College) The Graphics Pipeline Fri, Aug 28, 2015 1 / 19 Outline 1 Vertices 2 The

More information

Bump Mapping. Mike Bailey. Oregon State University. What is Bump-Mapping?

Bump Mapping. Mike Bailey. Oregon State University. What is Bump-Mapping? 1 Bump Mapping Mike Bailey mjb@cs.oregonstate.edu bumpmapping.pptx What is Bump-Mapping? 2 Bump-mapping is the process of creating the illusion of 3D depth by using a manipulated surface normal in the

More information

GPU Programming EE Final Examination

GPU Programming EE Final Examination Name Solution GPU Programming EE 4702-1 Final Examination Friday, 11 December 2015 15:00 17:00 CST Alias Methane? Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Exam Total (20 pts) (15 pts)

More information

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

CS452/552; EE465/505. Image Processing Frame Buffer Objects CS452/552; EE465/505 Image Processing Frame Buffer Objects 3-12 15 Outline! Image Processing: Examples! Render to Texture Read: Angel, Chapter 7, 7.10-7.13 Lab3 new due date: Friday, Mar. 13 th Project#1

More information

LSU EE Homework 5 Solution Due: 27 November 2017

LSU EE Homework 5 Solution Due: 27 November 2017 LSU EE 4702 1 Homework 5 Solution Due: 27 November 2017 The solution code is in the repository in file hw05-shdr-sol.cc. Running the makefile will generate an executable for the solution named hw05-sol.

More information

Using Shaders for Lighting

Using Shaders for Lighting Using Shaders for Lighting Mike Bailey mjb@cs.oregonstate.edu Lighting Definitions L N R E N = Normal L = Light vector E = Eye vector R = Light reflection vector ER = Eye reflection vector Color = LightColor

More information

Using Shaders for Lighting

Using Shaders for Lighting 1 Using Shaders for Lighting This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License Mike Bailey mjb@cs.oregonstate.edu lighting.pptx Lighting Definitions

More information

GPU Programming EE Midterm Examination

GPU Programming EE Midterm Examination Name GPU Programming EE 4702- Midterm Examination Wednesday, 2 November 204 9:30 0:20 CST Alias Problem Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Exam Total (8 pts) (2 pts) (24 pts) (2 pts) (4

More information

Lecture 31 Sections 9.1, 9.2, 9.3. Mon, Nov 23, 2009

Lecture 31 Sections 9.1, 9.2, 9.3. Mon, Nov 23, 2009 Lecture 31 Sections 9.1, 9.2, 9.3 Hampden-Sydney College Mon, Nov 23, 2009 Outline 1 2 3 4 5 Outline 1 2 3 4 5 The extension wrangler (glew) will check to see which extensions are supported by the installed

More information

Programmable GPUs Outline

Programmable GPUs Outline papi 1 Outline References Programmable Units Languages Programmable GPUs Outline papi 1 OpenGL Shading Language papi 1 EE 7700-1 Lecture Transparency. Formatted 11:30, 25 March 2009 from set-prog-api.

More information