Ogre: 'illumination_stage' pass option

· by Steve · Read in about 2 min · (387 Words)

Free Image Hosting at www.ImageShack.usAdditive lighting modes are a great thing - they allow far more realistic lighting results than modulative shadows do, and they generally look great. However, they do have a slight problem, in that the rendering sequence has to be split into categorised sections - ambient or pre-lighting passes, per-light passes and post-light decaling. This of course increases the rendering cost and also means you are more restricted in your sequencing. One of the particular problems was that specular effects get muted because decal texturing modulated the final additive lighting result, rather than being added afterwards. Doing another specular pass afterwards was both costly and difficult to integrate with some shadow types, particularly stencil (because by that time you'd probably overwritten the stencil buffer).

One way around this has been to use Integrated Texture Shadows; that is where all  your lighting and shadowing is done directly in your own shaders so you have absolute control. This is still the most powerful of mechanisms available, but it only works with texture shadows (not stencils) and requires some additional expertise (and often more powerful cards, especially if you're using it to collapse passes right down).

What we really needed was a way to control the additive pass system a little more, for people that wanted the ease of use of auto-additive lighting but who also had some materials that didn't automatically split well. My solution was to add a new option to pass called 'illumination_stage', where you can explicitly assign passes to the 3 categories and not have the pass compilation mess with it. That means, if you know you can do your albedo texturing within the per-light pass (because you have enough spare texture units and the math works), now you can, instead of Ogre trying to insist that your per-light passes only use lighting-related textures (like normal maps). This is an easy way to get specular effects in the auto-additive lighting modes without having to resort to full-on shader based integrated texture shadow modes (see screenshot - that's stencil shadowing).

It was a relatively simple addition but adds another string to the bow of material authors wanting to tweak their lighting modes. The shadows section of the manual is getting quite cluttered now (in Shoggoth) with all the lighting mode options, I might have to reorganise it sometime.