GLSL

From GPWiki

This page is far from complete, go ahead and write some more!
You can extend this page by editing it.

Contents

Introduction

GLSL (a.k.a. glslang) is the OpenGL Shading Language. It's a C-like hi-level language to create OpenGL fragment (pixel) and vertex shaders. To make it simple, 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 new types and keywords. To get a detailed view of the language, I suggest the reading of the GLSL specification you can find on OpenGL Shading Language website.

Using a shader

A shader is a program, to be run it must be loaded, compiled and linked. Actually each vertex and fragment shader must have one entry point (the main function) each, but you can create and link more shaders.

Vertex Shader

TODO

Fragment Shader

TODO

See also