Start Page » Module System » OpenGL Graphic Module » Environment maps
Environment maps are used to provide reflections due to the reflectivity texture property. In most games the environment maps are static and precalculated offline. For a fully dynamic day-night cycle with variable lighting this is though not a suitable option. For this reason the OpenGL Grpahic Module implements a dynamic environment map system. It may sound a bit strange to call static environment maps dynamic. Static refers here to the location of the environment map probes. The updating of the individual probes though is dynamic.
The module tracks the sky object assigned to the world for changes in lighting parameters and orientation. If the accumulated changes are large enough environment maps are marked dirty and update the next possible time. This way the environment maps adapt to day and night automatically. The developers thus has not to worry about lighting conditions this way.
The updating is currently done by rendering the world into a cube map using the render code used also for conventional rendering from cameras. This is a temporary solution as the performance is not optimal. To compensate for this during each frame update only one cube map face is rendered. Hence updating an entire environment map requires 6 frame updates in total. This distributes the updating of environment maps across many frames. The next environment to update is picked according to the location of the camera. This updates environment maps near the camera before updating more remote environment maps. While this puts less strain on the frame rate the reaction time to quick changes in the world lighting as for example in fast forwarding time is not good. This will be tackled later on with a new rendering code geared for environment map updates. This is though something for a rainy day right now.
Placing environment maps dynamically is the final goal. Dynamic placement though is also difficult to achieve. For now the placement of the environment maps is done by the level designer. The final way on how to do this is not yet written in stone. For the time being this is achieved using a special texture property. A component with a texture containing this texture property name turns into an environment map probe and thus becomes invisible to rendering. This solution is quite hacky but for some reason it is a nice solution. Using texture properties this additional “feature” is fully legit while not interfering with level design or other engine parts. Furthermore it allows to simply defined a new element class the level designer can simply add to his world and get manual environment map placement without adding extra code to the editor or any other place. Maybe this solution will be kept, maybe not. It certainly works and I like how it works right now.