I planed to do a different topic in this news post but I have changed it in the last minute. The reason is that some parts of the news post would shows lots of stuff which comes in a later one which would be odd. Even with this change there is no way around having tidbits of later news posts to be shown but it's less this way. So enjoy this news post. And don't worry, the „dragon in narrow spaces" will come in another news post.
Video decoding support
This had been on my wish list since quite some time and I eventually got around to pull it off. Video resources have been added now to the game engine to support loading (and later on saving) videos of various kinds. To begin with Theora is supported as video format (hence *.ogv files). The implementation of videos in the game engine works similar to the way streaming sound files are handled.
The Video resource is obtained once a video is loaded from a file. This is a streaming resource object hence the actual file is kept open and the video is not yet loaded. To use a video in your game you have to use a Video Player resource object. Simply create one and assign it the video resource you loaded. Video player resources provide support to obtain individual video frames from the attached video resource. This is done internally using a decoder object provided by the Video Module that loaded the video file. To make it easy to use videos the video player provides support to define a play range, play speed as well as pause/resume support. Playback can be either looping or not in which case the video player stops playback after the play range is left. Otherwise playback loops endlessly. The playback speed determines as expected how fast the video plays back. You only have to call the „update" method with the amount of game time elapsed. The video player takes care of doing all the calculations.
Videos are usually used for textures. For this purpose you need a Dynamic Skin object. Simply create a renderable with the matching name and assign the video player to it. The graphic module then takes care of picking the right video frames from the video using the settings you made in the video player. Since you can use renderables for all kinds of texture properties videos can therefore be used also for all kinds of texture properties.
Here a sample video showing the video object and video player in action. See the image description for some further infos.
Video encoding support will follow later on.
Sky system improvements
The sky had been one of the few places left in the OpenGL module which have not been yet using OpenGL 3.0 shaders. They are now changed to use this shader version. Furthermore the shadow casting has been altered at the same time. Sky shadows now support too PCF filtered shadows. As another change the boundary calculation for the Cascaded Shadow Maps technique has been altered. The shadow system though still requires some changes as the stock CSM technique does not work well with the large shadow range the engine supports.
Besides these changes ambient lighting has been added. So far the engine decided how much ambient light a sky light has. This is though not flexible and designer might wish to have specific lighting situations. The introduction of an explicit ambient lighting takes care of this. Sky lights now have two light intensity properties the light intensity and the ambient intensity. The ambient intensity defines the strength of light in shadow areas where the sun light only reaches over multiple bounces. The light intensity defines the strength of areas in plain sight of the sun light. The two values are additive in nature. Hence geometry in the sun shadow receive ambient-intensity light. Geometry in the plain sight of the sun receive ambient-intensity + light-intensity. This allows to implement daylight effects like clouds obscuring the sun in a dynamic way. By altering the light-intensity parameter this effect can be simulated. Moving the light intensity towards 0 the areas lit by sun light come closer to the areas only light by the ambient intensity. At 0 all areas have only the ambient intensity. This allows to break up the monotonicy of typical sun lighting as found in many games.
The image below (click, it's a GIF animation) shows a sequence of direct light values for showing the effect.
In a next step an explicit sun occlusion will be added to make lighting distribution inside buildings more natural.
The next news post will take a look at some game changes including the Day-Night cycle using the modified Sky System.