Volumetric fog
Scene for the volumetric fog, here visible with fog turned off
Volumetric fog, with normal lighting turned off
Textured spot light with shadow
Flowers bending under the wind, transformed on GPU in object space
Toon and Fresnel effects combined
3D and 2D smooth noise on GPU, wrapped in ShaderTexture

Shader Effects (Compositing Shaders)

Contents:

1. Intro

Castle Game Engine defines a few nodes that allow to use shaders to define effects on 3D shapes, textures and lights.

You basically provide small pieces of shading language code (OpenGL Shading Language, GLSL) that will be seamlessly integrated with the engine internal shaders (and with each other). This allows to create graphic effects using the powerful shader languages. Contrary to the traditional approach of using shaders (using ComposedShader nodes, see shader component support), this new system allows to create the effects more easily. There is no need to replicate existing functionality (e.g. you don't have to reimplement existing lighting or texturing operations in your shaders, if you don't want to modify them). Moreover, your shader effects automatically cooperate with each other and with standard rendering features, hence why we call this feature compositing shaders.

2. Examples for Pascal developers

For engine developers using Pascal:

3. Examples for X3D authors

The example models are available inside our demo models. Download them, and look inside the subdirectory compositing_shaders there. Also the water subdirectory contains water implementation using our effects.

You can open the example models with any of our engine tools, like Castle Model Viewer.

4. Nodes implementations

The specification of these effects is an extension of the X3D standard. We have two independent implementations of this concept now:

  1. Inside Castle Game Engine and Castle Model Viewer. By Michalis Kamburelis, the author of this paper.
  2. Inside FreeWRL, another excellent VRML / X3D browser. By Doug Sanden.

5. Documentation

  1. "Compositing Shaders in X3D" documentation, HTML version.
  2. "Compositing Shaders in X3D" documentation, PDF version.
  3. Source of this documentation is in cge-documentation, compositing_shaders_doc subdirectory.

If you have any questions, please ask on Castle Game Engine forum or Discord.

6. Conference paper and slides (a bit outdated)

The original description of this idea was Michalis Kamburelis' Ph.D. thesis. (Although never formally defended, due to lack of time.)

I was also presenting it on Theory and Practice of Computer Graphics 2011 conference and at seminar at Institure of Computer Science, Wrocław.

So I have some additional content about this idea, that may be useful -- but be careful, as it was not updated in the last years. While the idea and syntax remained unchanged, some advised PLUG names have changed.

  1. Slides from my presentation (TPCG11 conference) about compositing shaders (8.5 MB).
  2. Paper (TPCG11 conference) about compositing shaders (12.5 MB).
  3. Slides in Polish from my presentation (on seminar on ii.uni.wroc.pl) (6.4 MB). These slides have roughly the same content as above TPCG11 slides, but in Polish.