Darkwind Media Blog

Repository of thoughts and code from the Darkwind team

The bug hunt comes to a close

I finally tracked down those nasty bugs I was facing in Ogre’s script compilers. The shadows bug (normal mapped model appeared black when using stencil additive shadows) was an old one that had been plaguing me for a long time. As you could have guessed the error was very subtle.

Ogre’s lighting system, when uses additive lighting, goes through three phases: ambient, per light, and decal. The system has to know which material passes are intended for each phase. In the past (and as was the case in the shadows demo) this was done with “magic” color values. After determining that the problem was with the illumination stages – which was a chore on its own – I finally narrowed it down to the default values colors get when you don’t explicitly set all the channels. Like, say, the alpha channel. Specular automatically got a 0 set in its alpha channel. It should have been 1. And that was pretty much it. It’s the simple mistakes which take the longest to track down.

To avoid all this confusion I suggest that if you are using version 1.6 you just make use of the new illumination_stage property in passes to explicitly tell Ogre which stage the pass belongs to. Much cleaner and easier to understand.

material Test{
    technique{
        pass{
            illumination_stage ambient
        }
        pass{
            illumination_stage per_light
        }
        pass{
            illumination_stage decal
        }
    }
}
No comments

No comments yet. Be the first.

Leave a reply

You must be logged in to post a comment.

Mexico