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

Compositing Shaders


1. Intro

This in an extension of X3D that allows to use shaders to define effects on 3D shapes, textures and lights. You basically provide small pieces of shading language code that will be seamlessly integrated with the engine internal shaders (and with each other). This allows to create graphic effects using the powerful shader langauges (like OpenGL Shading Language, GLSL, in case of Castle Game Engine). Contrary to the traditional approach (using ComposedShader node, see shader component support), our system allows to create the effects easily. There is no need to replicate existing functionality (you don't have to reimplement existing lighting or texturing operations in your shaders, if you don't want to modify them). Your shader effects automatically cooperate with each other and with standard rendering features.

2. Examples

The examples are available inside our VRML/X3D 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 view3dscene.

I'm incredibly happy to note that we have two independent implementations of this concept now:

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

3. Documentation

  1. "Compositing Shaders in X3D" documentation, HTML version. This is my Ph.D. thesis, enjoy :)
    (Note that the Ph.D. thesis was not yet formally "defended". Mostly due to my lack of time to finalize it...)
  2. "Compositing Shaders in X3D" documentation, PDF version. Exactly the same content as above HTML version, just in PDF — probably much better for printing.
  3. Slides from my presentation (on TPCG11) about the compositing shaders (8.5 MB).
  4. 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.
  5. My paper about this idea was also accepted to the Theory and Practice of Computer Graphics 2011 conference. I don't have permission to redistribute it here publicly, but basically it's a shortcut of my Ph.D. thesis. Anyway, you can buy it from EG digital library (along with other papers from TPCG11 proceedings).
  6. You can also get the sources of above documents from the GitHub repository on https://github.com/castle-engine/cge-documentation/.
    • The Ph.D. thesis sources (in DocBook) is inside compositing_shaders_doc/ subdirectory.
    • Slides and conference paper (in TeX) are alongside, in the compositing_shaders/ subdirectory.

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