From GPWiki
Jump to: navigation, search
40px-sprout.png   This article is a stub. You can help out by expanding it.

Introduced as an ARB extension to the OpenGL Specification as of version OpenGL 1.4 and promoted to a 'Core' function in OpenGL 2.0, GLSL is a high level language used to define vertex, fragment, and with the new DX10 class of hardware geometry shaders.


GLSL (a.k.a. glslang) is the OpenGL Shading Language. It's a C-like high level language to create OpenGL fragment (pixel) and vertex shaders. A shader is a program that is loaded on the GPU and called for every vertex or pixel: this gives programmers the possibility to implement techniques and visual effects and execute them faster. In modern games lots of shaders are used: lights, water, skinning, reflections and much more.

To really understand shaders, you should have a knowledge about the rendering pipeline; this helps to understand where and when the shaders act in the rendering process. In general, you must know that vertex are collected, processed by vertex shaders, primitives are built, then are applied colors, textures and are also called fragment shaders; finally it comes to the rasterization and the frame is put on the buffer.

Language Syntax

The GLSL has a C-Like syntax. It introduces several new data types, and has support for branching and looping constructs like if/else, for, do-while, etc. It has support for user defined functions, but comes with many built in functions that focus mostly on graphics programming.

Using a shader

A shader is a program, to be run it must be loaded, compiled and linked. Each vertex and fragment shader must have one entry point (the main function) each, but one can create and link more shader source files into a single shader program, much like the C compilation model.

See also