Simulations on the GPU

CS 482 Lecture, Dr. Lawlor

Modern OpenGL talks to the graphics card using a variety of specialized software objects:
The big limitation with a fragment shader is it can only write to the pixel you're currently rendering.  People deal with this by:

Programmable Shaders are Very Simple in Practice

GLSL is one of the standard languages today for describing the code used to draw pixels to the screen on modern graphics cards.

There are many opportunities to use GLSL in simulations.  First, we can get much higher performance by running our simulation code in a pixel shader, which allows all the pixels to execute in parallel.  The downside is we need to make all the inputs and outputs shader friendly, which can be trivial, or very difficult, depending on the simulation requirements.

Second, we can provide better display of our simulation's outputs, by including per-pixel information such as the camera direction, lighting, contrast, etc.

Data types in GLSL work exactly like in C/C++/Java/C#.  There are some beautiful builtin datatypes:

Bottom line: programmable shaders really are pretty easy to use.  I personally find them easier to write than JavaScript, especially for vector arithmetic. 

Further Info

See also the GLSL cheat sheet (especially for builtin variables).

The official GLSL Language Specification isn't too bad--chapter 7 lists the builtin variables, chapter 8 the builtin functions.  OpenGL ES / GL 3.0 is similar, but they deprecated a bunch of the builtin variables from fixed-function GL.