The OpenGL Shading Language

Size: px
Start display at page:

Download "The OpenGL Shading Language"

Transcription

1 The OpenGL Shading Language

2 GLSL In the previous lecture we looked at the process of loading shaders into the programmable hardware (GPU) The actual language syntax of GLSL and the principles behind it will be covered in this lecture First we will look at the different processors in the GPU

3 Geometric Data Passed as generic vertex attributes Vertex Shading Tessellation Shading Geometry Shading Rasterizer Fragment Shading Pixel Data Textures or Texture buffer objects Tessellation Shading Tessellation control Shader new in OpenGL 4.3 Compute Shading Primitive Generator Tessellation Evaluation Shader

4 Vertex Processor The vertex processor is a programmable unit that operates on incoming vertices and their associated data. Compilation units written in the OpenGL Shading Language to run on this processor are called vertex shaders. The vertex processor operates on one vertex at a time. It does not replace graphics operations that require knowledge of several vertices at a time.

5 Vertex processor (Rost 2009)

6 Geometry Processor The geometry processor is a programmable unit that operates on data for incoming vertices for a primitive assembled after vertex processing and outputs a sequence of vertices forming output primitives. A single invocation of the geometry shader executable on the geometry processor will operate on a declared input primitive with a fixed number of vertices. This single invocation can emit a variable number of vertices that are assembled into primitives of a declared output primitive type and passed to subsequent pipeline stages.

7 Fragment Processor The fragment processor is a programmable unit that operates on fragment values and their associated data A fragment shader cannot change a fragment's (x, y) position. Access to neighbouring fragments is not allowed. The values computed by the fragment shader are ultimately used to update framebuffer memory or texture memory, depending on the current OpenGL state and the OpenGL command that caused the fragments to be generated.

8 The Fragment (2) Processor (Rost 2009)

9 Vertex Processor Input Vertex shader is executed once each time a vertex position is specified gldrawarrays or other vertex array calls Per-vertex input values are called attributes 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 lights, material properties, arbitrary values Constant across at least one primitive, typically constant for many primitives Passed through new OpenGL API calls (gluniform...)

10 Vertex Processor Output Vertex shader uses input values to compute output values Vertex shader must compute gl_position Mandatory, needed by the rasterizer Usually this will be transformed by our own MVP matrix Vertex shader may compute: gl_clipvertex (if user clipping is to be performed) gl_pointsize (if point parameters are to be used)

11 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

12 Fragment Processor Input At it s simplest level the output of the Vertex Processor is the input to the fragment (if we ignore geo and tess shaders) 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

13 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

14 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

15 Fragment Processor 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 The fragment processor in glsl 150 and above use generic output attributes, by default the first attribute is the fragment colour, however we can bind different attributes using glbindfragdatalocation(program, 0, "fragcolor");

16 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

17 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

18 pre-processor The GLSL compiler has a pre-processor just like a normal C compiler. It has the following keywords #define #undef #if #ifdef #ifndef #else #elif #endif #error #pragma #extension #version #line

19 #version #version is used to determine what version of GLSL is the minimum required to compile the shader. The language version a shader is written to is specified by #version number (optional) profile If the optional profile argument is provided, it must be the name of an OpenGL profile. Currently, there are three choices: core compatibility es

20 #pragma Used to enable compiler options / features Common ones used are #pragma optionnv(fastmath on) #pragma optionnv(fastprecision on) #pragma optionnv(ifcvt none) #pragma optionnv(inline all) #pragma optionnv(strict on) #pragma optionnv(unroll all)

21 Type Qualifiers There are many different type qualifiers in GLSL for a thorough examination of them see Typical use for these qualifiers are to tell glsl what direction the data is coming from (in / out) How it changes as the shader is executed How and if interpolation should be used. Some versions of GLSL (ES for example) will need these specified by default.

22 Vertex shader attribute index Vertex shader inputs can specify the attribute index that the particular input uses. This is done with this syntax: layout(location = attribute index) in vec3 position; This means that we don t need to use glbindattriblocation If you try to combine the two and they conflict, the layout qualifier always wins.

23 Vertex shader attribute index Attributes that take up multiple attribute slots will be given a sequential block of that number of attributes in order starting with the given attribute. For example: layout(location = 2) in vec3 values[4]; This will allocate the attribute indices 2, 3, 4, and 5.

24 Scalars The basic non-tuple data types in GLSL are uint: an unsigned 32-bit integer float: a floating point number bool: conditional type, values may be either true or false int: a signed, two's complement, 32-bit integer double: a double-precision floating-point number

25 Vectors Each of the scalar types, including booleans, have 2, 3, and 4-component vector equivalents. The n digit below can be 2, 3, or 4: bvecn : a vector of booleans ivecn : a vector of signed integers uvecn : a vector of unsigned integers vecn : a vector of single-precision floating-point numbers dvecn : a vector of double-precision floating-point numbers

26 Swizzling Vector component access can be achieved in a number of ways You can use x, y, z, or w, referring to the first, second, third, and fourth components, respectively. vec4 somevec; somevec.x + somevec.y; vec2 somevec; vec4 othervec = somevec.xyxx; vec3 thirdvec = othervec.zyy; vec4 somevec; somevec.wzyx = vec4(1.0, 2.0, 3.0, 4.0); somevec.zx = vec2(3.0, 5.0);

27 Swizzling You cannot use the same swizzle component twice. So somevec.xx = vec2(4.0, 4.0); is not allowed. Additionally, there are 3 sets of swizzle masks. You can use xyzw, rgba (for colors), or stpq (for texture coordinates). These three sets have no actual difference they're just syntactic sugar. (but try and use the correct one in context) You cannot combine names from different sets in a single swizzle operation. So ".xrs" is not a valid swizzle mask.

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

29 Matrices All matrix types are floating-point, either single-precision or double-precision. Matrix types are as follows, where n and m can be the numbers 2, 3, or 4: matnxm : A matrix with n columns and m rows. OpenGL uses column-major matrices, which is standard for mathematics users. Example: mat3x4. matn : A matrix with n columns and n rows. Shorthand for matnxn

30 Matrices Swizzling does not work with matrices. Instead [] array access is used mat3 m1; m1[1] = vec3(1.0, 2.0, 0.0); m1[2][0] = 16.0; mat3 m1; m1[1].yzx = vec3(3.0, 1.0, 2.0);

31 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

32 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 (. )

33 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));

34 1 float ramp[10]; 2 vec4 colors[4]; 3 bool results[3]; Arrays structures can be aggregated into arrays Only 1D arrays are supported (GLSL 4.3 has multidimensional arrays but not all gpu s support this) Size of array can be expressed as an integral constant expression within square brackets ([ ]) Arrays can be declared without a size, and then redeclared later with the same type and a size Using an index that goes beyond an array s bounds results in undefined behaviour

35 Arrays The length of an array variable can be computed with the.length() function. uniform float myvalues[12];... myvalues.length(); //Returns 12

36 Type Qualifiers const variable is a constant and can only be written during its declaration in per-vertex data values provided to the vertex shader out per-vertex data values passed from vertex to fragment shader uniform (relatively) constant data provided by the application or by OpenGL for use in the 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

37 Function Examples Declaration Definition 1 vec3 computecolor (in vec3 c1, in vec3 c2); 2 float radians (float degrees); 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 }

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

39 Vertex Shader Built-in Attributes The following are available from a vertex shader for accessing standard OpenGL vertex attributes, however they are deprecated in the latest standard. 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;

40 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 (Never seen this implemented!)

41 Accessing Built In Pipeline GLSL has the ability to access the built in Light and Material Properties however these are now deprecated and we will discuss other ways of accessing this in a later lecture Two main structures for this are gl_frontmaterial gl_lightsource[gl_maxlights]

42 Geometry Shaders The geometry processor is a programmable unit that operates on data for incoming vertices for a primitive assembled after vertex processing and outputs a sequence of vertices forming output primitives. A single invocation of the geometry shader executable on the geometry processor will operate on a declared input primitive with a fixed number of vertices. This single invocation can emit a variable number of vertices that are assembled into primitives of a declared output primitive type and passed to subsequent pipeline stages.

43 Geometry shaders Unlike Vertex and Fragment shaders, Geo shaders have access to the whole primitive (triangle, line or point) at once The geo shader can change the amount of data in the OpenGL pipeline This is in contrast with the vertex shader which works in a one in / one out form or the fragment shader which can only discard a fragment if it doesn t want to process it.

44 Basic pass through #version 150 layout (triangles) in; layout (triangle_strip) out; layout (max_vertices=3) out; void main(void) { for(int i=0; i<gl_in.length(); ++i) { gl_position=gl_in[i].glposition; EmitVertex(); } EndPrimitive(); }

45 pass through This shader just sends the input to the output and doesn t generate any new geometry The first elements of the shader are know as layout qualifiers These inform the shader what the input will be, the output format of the geometry and the max number of vertices that may be generated This have the following type

46 in layout qualifiers Shader Input points lines triangles lines_adjacency triangles_adjacency Draw Modes GL_POINTS GL_LINES, GL_LINE_LOOP,GL_LINE_STRIP GL_TRIANGLES,GL_TRIANGLE_FAN,GL_TRIANGLE _STRIP GL_LINES_ADJACENCY GL_TRIANGLES_ADJACENCY

47 output qualifiers The geometry shader can only output the following primitive types points line_strip triangle_strip The max_vertices value is used to indicate the max size that may be output, this should be kept to a minimum as OpenGL may allocate buffer space for this and will reduce performance

48 Geometry Shaders Geo shaders uses a the following structures to receive and emit vertices in gl_pervertex { vec4 gl_position; float gl_pointsize; float gl_clipdistance[]; } gl_in[]; in int gl_primitiveidin; out gl_pervertex { vec4 gl_position; float gl_pointsize; float gl_clipdistance[]; };

49 Size of input array Input primitive Size of array points 1 lines 2 triangles 3 lines_adjacency 4 triangles_adjacency 6

50 EmitVertex() EmitVertex tells the geometry shader that all the information for the current vertex has been filled in Any other variables set at this stage will be passed to the fragment shader (for example colour) Other attributes active at this stage will also be passed onto the fragment shader EmitVertex() can be called as many times as you like as long as it doesn t reach the max_vertices value

51 EmitPrimitive() EmitPrimitive() indicates that we have finished emitting vertices. It is important that enough vertices have been created for the primitive type specified in the layout qualifier

52 Visualising Normals The following geometry shader is used to draw both face and vertex normals The shader is split into 3 parts and loaded using ngl::shaderlib

53 Vertex Shader #version 150 precision highp float; the vertex passed in in vec3 invert; the normal passed in in vec3 innormal; the in uv in vec2 inuv; uniform mat4 MVP; uniform float normalsize; uniform vec4 vertnormalcolour; uniform vec4 facenormalcolour; out vec4 normal; uniform bool drawfacenormals; uniform bool drawvertexnormals; void main(void) { gl_position = MVP*vec4(inVert,1); normal=mvp*vec4(innormal,0); }

54 Fragment Shader #version 150 our output fragment colour out vec4 fragcolour; in vec4 pernormalcolour; void main () { fragcolour = pernormalcolour; }

55 #version 150 layout(triangles) in; layout(line_strip, max_vertices = 8) out; in vec4 normal[]; uniform float normalsize; uniform vec4 vertnormalcolour; uniform vec4 facenormalcolour; uniform bool drawfacenormals; uniform bool drawvertexnormals; out vec4 pernormalcolour; void main() { if (drawvertexnormals == true) { pernormalcolour=vertnormalcolour; for(int i = 0; i<gl_in.length(); ++i) { gl_position = gl_in[i].gl_position; EmitVertex(); gl_position = gl_in[i].gl_position + normal[i] * abs(normalsize); EmitVertex(); EndPrimitive(); } } if (drawfacenormals == true) { pernormalcolour=facenormalcolour; vec4 cent = (gl_in[0].gl_position + gl_in[1].gl_position + gl_in[2].gl_position) / 3.0; vec3 face_normal = normalize(cross(gl_in[2].gl_position.xyz - gl_in[0].gl_position.xyz, gl_in[1].gl_position.xyz - gl_in[0].gl_position.xyz)); } } gl_position = cent; EmitVertex(); gl_position = (cent + vec4(face_normal * abs(normalsize), 0.0)); EmitVertex(); EndPrimitive();

56 loading shader Adding a geometry shader is the same as any other ngl::shader we just set the type to ngl::geometry as shown shader->attachshader("normalgeo",ngl::geometry); shader->loadshadersource("normalgeo","shaders/normalgeo.gs"); shader->compileshader("normalgeo"); shader->attachshadertoprogram("normalshader","normalgeo");

57 references pdf Tutorial:_OpenGL_3.1_The_First_Triangle_(C%2B %2B/Win) 3DLabs OpenGL Shading Language Master Class Lecture Notes 2004

58 References Rost, R, Licea-Kane B (2009). OpenGL Shading Language. 3rd. ed. New York: Addison Wesley. OpenGL Architecture Review Board, OpenGL Reference Manual, Fourth Edition: The Official Reference to OpenGL, Version 1.4, Editor: Dave Shreiner, Addison- Wesley, Reading, Massachusetts, Segal, Mark, and Kurt Akeley, The OpenGL Graphics System: A Specification (Version 3.1), Editor (v1.1): Chris Frazier, (v ): Jon Leech, (v2.0): Jon Leech and Pat Brown, March spec.html

Tuesday, 23 March OpenGL Shading Language

Tuesday, 23 March OpenGL Shading Language 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

More information

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

GLSL. OpenGL Shading Language. OpenGL 1.5 Logical Diagram. OpenGL 2.0 Logical Diagram 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

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

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

12.2 Programmable Graphics Hardware

12.2 Programmable Graphics Hardware Fall 2018 CSCI 420: Computer Graphics 12.2 Programmable Graphics Hardware Kyle Morgenroth http://cs420.hao-li.com 1 Introduction Recent major advance in real time graphics is the programmable pipeline:

More information

Programmable Graphics Hardware

Programmable Graphics Hardware CSCI 480 Computer Graphics Lecture 14 Programmable Graphics Hardware [Ch. 9] March 2, 2011 Jernej Barbic University of Southern California OpenGL Extensions Shading Languages Vertex Program Fragment Program

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

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

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

Programming with OpenGL Part 3: Shaders. Ed Angel Professor of Emeritus of Computer Science University of New Mexico Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 Objectives Simple Shaders - Vertex shader - Fragment shaders Programming shaders with

More information

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

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation Lecture 5 Vertex and Fragment Shaders-1 CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives The rendering pipeline and the shaders Data

More information

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

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011 Shader Programs Lecture 30 Subsections 2.8.2, 2.8.3 Robb T. Koether Hampden-Sydney College Wed, Nov 16, 2011 Robb T. Koether (Hampden-Sydney College) Shader Programs Wed, Nov 16, 2011 1 / 43 Outline 1

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

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

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

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

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

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

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

Programming shaders & GPUs Christian Miller CS Fall 2011

Programming shaders & GPUs Christian Miller CS Fall 2011 Programming shaders & GPUs Christian Miller CS 354 - Fall 2011 Fixed-function vs. programmable Up until 2001, graphics cards implemented the whole pipeline for you Fixed functionality but configurable

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

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

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

Geometry Shaders. And how to use them

Geometry Shaders. And how to use them Geometry Shaders And how to use them OpenGL Pipeline (part of it) Vertex data Vertex shader Vertices Primitives Geometry shader Primitives Fragments Fragment shader Color Depth Stencil Vertex Data Attributes

More information

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

EDAF80 Introduction to Computer Graphics. Seminar 3. Shaders. Michael Doggett. Slides by Carl Johan Gribel, EDAF80 Introduction to Computer Graphics Seminar 3 Shaders Michael Doggett 2017 Slides by Carl Johan Gribel, 2010-13 Today OpenGL Shader Language (GLSL) Shading theory Assignment 3: (you guessed it) writing

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

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

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1 Programmable GPUs Real Time Graphics Virtua Fighter 1995 (SEGA Corporation) NV1 Dead or Alive 3 2001 (Tecmo Corporation) Xbox (NV2A) Nalu 2004 (NVIDIA Corporation) GeForce 6 Human Head 2006 (NVIDIA Corporation)

More information

0.Features of the OpenGL Shading Language

0.Features of the OpenGL Shading Language 0.Features of the OpenGL Shading Language by John Kessenich 3Dlabs Inc. Ltd. 03-May-2005 Copyright 2003-2005 John Kessenich In this white paper, we present the language features of the OpenGL Shading Language.

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

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

0.Features of the OpenGL Shading Language

0.Features of the OpenGL Shading Language 0.Features of the OpenGL Shading Language by John Kessenich 3Dlabs Inc. Ltd. 19-April-2004 Copyright 2003-2004 John Kessenich In this white paper, we present the language features of the OpenGL Shading

More information

Introduction to GLSL. Announcements. Agenda. Course Contents. Patrick Cozzi University of Pennsylvania CIS Fall 2012

Introduction to GLSL. Announcements. Agenda. Course Contents. Patrick Cozzi University of Pennsylvania CIS Fall 2012 Announcements Introduction to GLSL Patrick Cozzi University of Pennsylvania CIS 565 - Fall 2012 Game career advice Grades Project 3 due Monday, 10/05 Project 4 Released Monday, 10/05 Due Wednesday, 10/07

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

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

Graphics Programming. Computer Graphics, VT 2016 Lecture 2, Chapter 2. Fredrik Nysjö Centre for Image analysis Uppsala University Graphics Programming Computer Graphics, VT 2016 Lecture 2, Chapter 2 Fredrik Nysjö Centre for Image analysis Uppsala University Graphics programming Typically deals with How to define a 3D scene with a

More information

COMP371 COMPUTER GRAPHICS

COMP371 COMPUTER GRAPHICS COMP371 COMPUTER GRAPHICS SESSION 12 PROGRAMMABLE SHADERS Announcement Programming Assignment #2 deadline next week: Session #7 Review of project proposals 2 Lecture Overview GPU programming 3 GPU Pipeline

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

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

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

Shading Language Update

Shading Language Update 3 Shading Language Update Bill Licea-Kane Copyright Khronos Group, 2007 - Page 1 About this talk - Caveat BOFor Contributions to arb-glsl workgroup - NOT final, subject to (minor?) changes Not exhaustive

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

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

Programmable Graphics Hardware

Programmable Graphics Hardware Programmable Graphics Hardware Outline 2/ 49 A brief Introduction into Programmable Graphics Hardware Hardware Graphics Pipeline Shading Languages Tools GPGPU Resources Hardware Graphics Pipeline 3/ 49

More information

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

CSE 4431/ M Advanced Topics in 3D Computer Graphics. TA: Margarita Vinnikov CSE 4431/5331.03M Advanced Topics in 3D Computer Graphics TA: Margarita Vinnikov mvinni@cse.yorku.ca The OpenGL 4.x pipeline 2 new Programmable stages Tessellation Control Shader(GL_TESS_CONTROL_SHADER)

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

Introduction to Shaders for Visualization. The Basic Computer Graphics Pipeline

Introduction to Shaders for Visualization. The Basic Computer Graphics Pipeline Introduction to Shaders for Visualization Mike Bailey The Basic Computer Graphics Pipeline Model Transform View Transform Per-vertex Lighting Projection Transform Homogeneous Division Viewport Transform

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

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

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

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

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C GLSL OpenGL Shading Language Language with syntax similar to C Syntax somewhere between C och C++ No classes. Straight ans simple code. Remarkably understandable and obvious! Avoids most of the bad things

More information

CS 432 Interactive Computer Graphics

CS 432 Interactive Computer Graphics CS 432 Interactive Computer Graphics Lecture 2 Part 2 Introduction to Shaders Matt Burlick - Drexel University - CS 432 1 Shaders To understand shaders, let s look at the graphics pipeline again The job

More information

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

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside CS230 : Computer Graphics Lecture 4 Tamar Shinar Computer Science & Engineering UC Riverside Shadows Shadows for each pixel do compute viewing ray if ( ray hits an object with t in [0, inf] ) then compute

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

The Basic Computer Graphics Pipeline, OpenGL-style. Introduction to the OpenGL Shading Language (GLSL)

The Basic Computer Graphics Pipeline, OpenGL-style. Introduction to the OpenGL Shading Language (GLSL) Introduction to the OpenGL Shading Language (GLSL) 1 The Basic Pipeline, OpenGL-style Vertex, Normal, Color ModelViewMatrix, ProjectionMatrix, ModelViewProjectionMatrix 2 MC Model WC View Per-vertex Projection

More information

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation Lecture 17: Shading in OpenGL CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Introduce the OpenGL shading methods - per vertex shading

More information

The Graphics Pipeline

The Graphics Pipeline The Graphics Pipeline Lecture 2 Robb T. Koether Hampden-Sydney College Wed, Aug 23, 2017 Robb T. Koether (Hampden-Sydney College) The Graphics Pipeline Wed, Aug 23, 2017 1 / 19 Outline 1 Vertices 2 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

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

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

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

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

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

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

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL Today s Agenda Basic design of a graphics system Introduction to OpenGL Image Compositing Compositing one image over another is most common choice can think of each image drawn on a transparent plastic

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

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

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

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

We assume that you are familiar with the following:

We assume that you are familiar with the following: We will use WebGL 1.0. WebGL 2.0 is now being supported by most browsers but requires a better GPU so may not run on older computers or on most cell phones and tablets. See http://webglstats.com/. We will

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

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

Why modern versions of OpenGL should be used Some useful API commands and extensions Michał Radziszewski Why modern versions of OpenGL should be used Some useful API commands and extensions Timer Query EXT Direct State Access (DSA) Geometry Programs Position in pipeline Rendering wireframe

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

CS195V Week 3. GLSL Programming

CS195V Week 3. GLSL Programming CS195V Week 3 GLSL Programming Differences in OpenGL and GLSL 4.x A lot of changes made to GLSL 4.x spec (see: http://www. opengl.org/registry/doc/glslangspec.4.00.8.clean.pdf) CS123 used OpenGL 2.x and

More information

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

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017 Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017 Abbott, Connor (cwa2112) Pan, Wendy (wp2213) Qinami, Klint (kq2129) Vaccaro, Jason (jhv2111) [System

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

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

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

Introduction to Computer Graphics. Hardware Acceleration Review

Introduction to Computer Graphics. Hardware Acceleration Review Introduction to Computer Graphics Hardware Acceleration Review OpenGL Project Setup Create a command-line style project in Xcode 4 Select the project file and click Build Phases tab Add OpenGL.framework

More information

How to use tessellation to add geometric detail to your scenes. How to use geometry shaders to process whole primitives and create geometry on the fly

How to use tessellation to add geometric detail to your scenes. How to use geometry shaders to process whole primitives and create geometry on the fly Chapter 8 Primitive Processing WHAT YOU LL LEARN IN THIS CHAPTER How to use tessellation to add geometric detail to your scenes How to use geometry shaders to process whole primitives and create geometry

More information

LSU EE Homework 3 Solution Due: 16 November 2012

LSU EE Homework 3 Solution Due: 16 November 2012 LSU EE 4702 1 Homework 3 Solution Due: 16 November 2012 Follow the Programming Homework Work Flow instructions on the procedures page, substituting hw3 for hw1. Also, update the include directory. Use

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

Grafica Computazionale: Lezione 30. Grafica Computazionale. Hiding complexity... ;) Introduction to OpenGL. lezione30 Introduction to OpenGL

Grafica Computazionale: Lezione 30. Grafica Computazionale. Hiding complexity... ;) Introduction to OpenGL. lezione30 Introduction to OpenGL Grafica Computazionale: Lezione 30 Grafica Computazionale lezione30 Introduction to OpenGL Informatica e Automazione, "Roma Tre" May 20, 2010 OpenGL Shading Language Introduction to OpenGL OpenGL (Open

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

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

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system GRAPHICS PIPELINE 1 OUTLINE Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system 2 IMAGE FORMATION REVISITED Can we mimic the synthetic

More information

1 of 5 9/10/ :11 PM

1 of 5 9/10/ :11 PM Shader programs Summary: This tutorial shows how to write a simple shader in X3D. Shader program definition Keywords: tutorial, X3D, world, rendering Author(s): Yvonne Jung Date: 2007-02-05 First an example

More information

OpenGL Programmable Shaders

OpenGL Programmable Shaders h gpup 1 Topics Rendering Pipeline Shader Types OpenGL Programmable Shaders sh gpup 1 OpenGL Shader Language Basics h gpup 1 EE 4702-X Lecture Transparency. Formatted 9:03, 20 October 2014 from shaders2.

More information

Mobile graphics API Overview

Mobile graphics API Overview Mobile graphics API Overview Michael Doggett Department of Computer Science Lund University 2009 Michael Doggett and Tomas Akenine-Möller 1 Register Please check to see if your name is on the list, if

More information

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

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley OpenGUES 2.0 Programming Guide Aaftab Munshi Dan Ginsburg Dave Shreiner TT r^addison-wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid

More information

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

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11 Pipeline Operations CS 4620 Lecture 11 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to pixels RASTERIZATION

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

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

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL CS770/870 Spring 2017 Open GL Shader Language GLSL Based on material from Angel and Shreiner, Interactive Computer Graphics, 6 th Edition, Addison-Wesley, 2011 Bailey and Cunningham, Graphics Shaders 2

More information

Some advantages come from the limited environment! No classes. Stranight ans simple code. Remarkably. Avoids most of the bad things with C/C++.

Some advantages come from the limited environment! No classes. Stranight ans simple code. Remarkably. Avoids most of the bad things with C/C++. GLSL OpenGL Shading Language Language with syntax similar to C Syntax somewhere between C och C++ No classes. Stranight ans simple code. Remarkably understandable and obvious! Avoids most of the bad things

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

Pipeline Operations. CS 4620 Lecture 14

Pipeline Operations. CS 4620 Lecture 14 Pipeline Operations CS 4620 Lecture 14 2014 Steve Marschner 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives

More information

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

WebGL A quick introduction. J. Madeira V. 0.2 September 2017 WebGL A quick introduction J. Madeira V. 0.2 September 2017 1 Interactive Computer Graphics Graphics library / package is intermediary between application and display hardware Application program maps

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

CS 4620 Program 3: Pipeline

CS 4620 Program 3: Pipeline CS 4620 Program 3: Pipeline out: Wednesday 14 October 2009 due: Friday 30 October 2009 1 Introduction In this assignment, you will implement several types of shading in a simple software graphics pipeline.

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

Appendix A Cg Language Specification

Appendix A Cg Language Specification Appendix A Cg Language Specification Language Overview The Cg language is primarily modeled on ANSI C, but adopts some ideas from modern languages such as C++ and Java, and from earlier shading languages

More information

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1 UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series PG Examination 2013-14 COMPUTER GAMES DEVELOPMENT CMPSME27 Time allowed: 2 hours Answer any THREE questions. (40 marks each) Notes are

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