Monday, January 12, 2009

Unified terrain mods

Since this summer's Google Summer of Code we've had support in both Ember and Cyphesis for terrain modifiers. The server side implementation was however incomplete and didn't support all of the shape types available. Furthermore, Sear didn't have any support for terrain mods.
When working on providing a more unified functionality for both the clients and server it quickly became apparent that we needed to push some of the functionality in Ember down to lower level libraries in order to avoid code duplication.
The first step was to extend WFMath to have atlas parsing and generating methods for the more complex shapes. Previously only primitives such as Position and Vector had such methods. One of the advantages of this is that all clients and servers won't have to bother themself with the format of the atlas data, since that's taken care of by WFMath.
Another issue was that the actual code for connecting terrain modifications to the entities to which they belonged was duplicated in both Ember and Sear. The main issue was that it would normally go into the Eris library, but Eris didn't have any dependency on Mercator. That was easily fixed by adding such a dependency, after which the bulk of the duplicated code could be moved into Eris.
The end result of all this is that we now finally have correct and unified support in both Cyphesis, Ember and Sear for all available terrain mods and the shapes used by them. One of the most useful of the mods are the level mod, which makes sure that an area of the terrain is levelled. This is extremely useful when placing houses and other structures, because you want to make sure that the house sits on level ground. If not, you run the risk of having ground poking through the floor, or the foundation of the house seemingly resting on air.
In the following movie you will see a house to which a rectangular polygon shaped level mod is attached. The level mod doesn't have any specific height set and will therefore use the height of the entity itself.

Higher quality can be found here.

Sunday, January 11, 2009

Improved shadows

Alexey has spent some time lately improving both the shader and shadow support in Ember. The shaders for both the terrain and the regular meshes have been reimplemented in GLSL and have had a nice slew of improvements added to them. One of the most exciting feature is proper support for real time shadows.

One of the issues we've been having is that regular texture shadows tends to result in very low res and jagged shadows when used with a large scene such as our outdoor scenes. This is because the texture that is used can only be so large, and the outdoor scenes makes it hard for the shadow system to setup the most optimized camera setup for the shadows. However, thanks to the new support in Ogre 1.6 for PSSM shadows, which basically is a technique where multiple shadows maps are used for variable distances, we now have the option of having shadows that looks good both up front and in the distance.
Alexey has already done a great job in adding support for this, which can be seen in these videos showing off the shadows. Note that they are still a work in progress, so some things such as taking texture alpha into account or shadowing of normal meshes are not yet implemented.

Some more videos can be found over at YouTube.

There are still some work to be done, but the shadows are already looking mighty nice. Of course, lower end machines won't be able to take advantage of this, and one of the things that we need to work on is better support for fall back materials.