Last modified on 13 May 2012, at 20:42

GLSL Programming/Blender

Blender is a popular open source modeling and animation tool for Windows, MacOS X, Linux, and FreeBSD that includes a game engine. (Via GameKit it might also support game development for Android and iOS in the future.) Since meshes, textures, light sources, etc. can be edited in a graphical user interface, it is easier to define complex scenes than in an OpenGL (ES) or WebGL application. Blender supports vertex and fragment shaders in GLSL (i.e. “GLSL programs”; not to be confused with the built-in “GLSL material” or “GLSL shading”).

PreliminariesEdit

Blender can be downloaded at the Blender Foundation's download page. Some points should be noted:

  • First, Blender's Python API (which is necessary to specify GLSL programs and OpenGL states) has been dramatically changed in version 2.5 of Blender; thus, most of the tutorials and examples about GLSL programming in Blender that you might find in the internet won't work with the current version.
  • Second, Blender's Python API supports only a single render pass and it is unclear to me how to set OpenGL states (other than blending and uniform variables) for specific materials or objects. Thus, the possibilities are somewhat limited.
  • Third, GLSL programs are limited to Blender's game engine; thus, they are only displayed when the game is started. (This is particularly inconvenient when editing shader parameters.)

TutorialsEdit

Note that the tutorials assume that you read them in the order in which they are presented here, i.e. each tutorial will assume that you are familiar with the concepts and techniques introduced by previous tutorials. If you are new to GLSL or Blender you should at least read through the tutorials in the “Basics” section.

BasicsEdit

Transparent SurfacesEdit

Basic LightingEdit

Basic TexturingEdit

Advanced TexturingEdit


LinksEdit

The most important documentation for programming GLSL in Blender appears to be:

There is a script to export the vertex and fragment shaders of Blender's internal GLSL programs. However, these shaders (and the uniforms they use) are generated automatically; thus, they are not very readable and not well suited for learning GLSL: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Game_Engine/Export_GLSL

GLSL Shaders for Image PostprocessingEdit


< GLSL Programming

Unless stated otherwise, all example source code on this page is granted to the public domain.