David's Blog

Mostly Hobby Stuff

Archive for May 2010

Light Fade Volumes and Filter Overrides

leave a comment »

One problem with the system I mentioned in my last post was that the transition from outdoor to indoor lighting was rather harsh. So in order to improve this I added something I call light fade volumes, these are simply trigger volumes which cause the influence of a set of lights identified by a filter group to scaled based on the distance of the object through the volume. For example I can place light fade volumes in doorways to gradually reduce the influence of sky lights on the player as they move through the doorway.

In order to support this I needed to add an additional feature to triggers/collision geometry, i.e. a direction for the volume. This direction can be set and displayed in the editor(as shown below). A further motivation for a direction is to support things such as force fields, push volumes, gravity volumes, anisotropic friction etc.

Once I had this working, I noticed that I often wanted a bunch of lights to only affect the static geometry (e.g. steps) but not the dynamic object resting on them (player). To achieve this I added a property set which can be applied to collision geoms which specifies an alternative light filter for objects resting on them.


may12 may12_2 may12_3


Written by therealdblack

May 12, 2010 at 9:55 pm

Posted in Hobby Game, XNA

Occluder Fusion Cells and Light Filtering

leave a comment »

Today I added support for optionally setting the occluder fusion cell size for each model.

I should probably explain what the occluder fusion cell size is: When rendering multiple instances of an object, for example patches of grass, objects are grouped/fused into chunks. This allows everything in a fusion group to be drawn in a single draw call. In addition to reducing the number of draw calls this reduces the amount of overhead for lighting, material setup, occlusion culling etc.

Hence it becomes trivial to support large numbers of identical objects without the need for special case code. Which in turn simplifies other features such as editing, object painting, decals and particle mesh emitters(TODO).

Anyways, the reason I needed to set the cell size was that for most objects a default size suffices, but for distant/background objects, like buildings in the distance the cell size should be much larger. The cell size can also be tweaked to allow more detailed lighting, since light bindings are shared between all objects within a fused group.


Next I added a component which sets a models light filter group based on the object which it is standing on. The reason for this is that objects like the player move from outside to inside. When inside, the player should not have lights such as the directional light simulating diffuse light from the sky affecting them.

One pleasing thing about this feature was that it is a good example of the power of my component based architecture. The entire implementation is about 130 lines, with the ability to apply this component to any model and full editor configuration support:-)

Written by therealdblack

May 2, 2010 at 8:33 pm

Posted in Hobby Game, XNA