Darkwind Media Blog

Repository of thoughts and code from the Darkwind team

Archive for May, 2008

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

The bug hunt

Ogre is nearing its next major release, 1.6 (Shoggoth). Unfortunately, there are still a few bugs that plague it, and I’m sure they are related to the new script compilers. I thought I had ironed them all out but there always seems to be one more. This time around they are strange visual anomalies in the DynTex and Shadows demos.

Thus far I am completely stumped. It doesn’t help that much of my debugging time is spent waiting for Ogre to rebuild between switching the old and new compilers on and off with a preprocessor definition. And believe me, Ogre takes a long time to build.

At this point, I’ve resorted to comparing the states of the compiled materials with and without the new compilers (I’d previously attempted to step through the material compilation process in the new compilers to spot the error, but no luck). Here’s a tip that may or not pay off: you can copy and paste the state of data in Visual Studio’s watch to a text editor. Hopefully I’ll be able to run a diff on the two text files and something will pop out at me. These bugs are proving to be horribly sneaky.

Luckily enough things are going much better on all of my other projects. I’ve been here before with those, but this is definitely the first time I’ve run into this tough of a roadblock with Ogre.

No comments