Wednesday, November 26, 2008

Ogre Progress

So far all high-priority bugs have been fixed for the 0.2 release. That leaves a few medium-priority bugs, and the creation of a more fun example game, which I hope to do in a week or so.

Alongside that, I find myself spending an equal amount of time on Ogre rendering, as it's more challenging. The latest issue I've been working on is shadows. One nice thing about Ogre is that, as a general-purpose 3D engine, it has various shadow techniques that you can apply with a single command. Here is an example of stencil shadows:


However, this approach would almost certainly lead to significant slowdowns, for more complex maps. So a better idea would be to use the already-existing Sauerbraten method of baked shadows, which are pre-calculated using ray-tracing techniques. After some helpful explanations on IRC by the one and only eihrul about Sauerbraten's rendering pipeline (thanks again!), I managed to get the brightness part of the Sauerbraten lightmaps to render in Ogre:


The next stage would be to set up materials that combine the underlying ('diffuse') textures with the lightmaps, giving the correct final appearance. This is not trivial as it requires processing two sets of texture coordinates at the same time, one for the diffuse texture and one for the lightmap (which should multiply the diffuse texture, thus either darkening or lightening it), but hopefully it won't be too hard to do.

The next tricky bit would be to combine these shadows with dynamic shadows for moving objects. They all need to look well together, even though they are generated by entirely different procedures. So the angles, intensities, etc. must match.

No comments: