Lightshaft Quirks

The more I do with the UDK, the more it becomes apparent that it was never designed to do anything larger than a square kilometer or so.

When viewed from near the origin, as seen in the old screenshot below, lightshafts being cast from a DominantDirectionalLightMovable look just fine. However, the further you travel from (0,0,0), the more offset the lightshafts appear, until they are coming from a completely different point in the sky than the sun’s current position. I’m not entirely sure what causes this, but it seems like the lightshaft-casting object is placed in the world by the engine based on a Rotator centered at (0,0,0) rather than a vector. So, as the player moves through the world, even if the DDLM does not move, the lightshafts coming from it will appear to move, albeit very slowly. Granted, the problem is only cosmetic, but it’s really annoying.


A screenshot from January 2014 showing a very, very early version of the dynamic sky system and the first inclusion of health, stamina, mana, and experience meters in the HUD.

After a bit of reading, I remembered that Spotlights can also cast lightshafts, so I added a SpotLightMovableto the world, turned on lightshafts, and turned off all shadowcasting and set its brightness to 0, then tweaked the lightshaft settings to taste. In code, I hooked the SLM into the Astrolabe code, giving it a a world position of the Sun’s rotation (a Rotator) coerced into a Vector, multiplied by -512000 (negative because the Rotator describes the direction at which incoming light is traveling; opposite of the direction in which you would look to see the sun in the sky), then rotated it using the same Rotator calculated for the Sun’s rotation. Finally, and this is the part that actually does the fixing, that Vector is combined with the player’s Location Vector and applied to the SLM. This has the effect of parenting the SLM to the player, and orbiting it around the world at the same rate and same position in the sky as the sun. Additionally, the BloomTint is updated each 1/30 second to match the color of the sun’s light.

This works, and seems (so far) to work perfectly.

A slight note about Lightmass on maps this large: calculating lighting information takes about 7.3 minutes on a 2500k @ 4.3GHz, and that’s just on Preview lighting. To get Lightmass to even run without crashing because it ate up all 16gb of RAM, I had to add a 384gb swapfile on an SSD, though I’m pretty sure this is overkill.


Properly-working crepuscular rays, cast from a helper spotlight instead of the DominantDirectionalLightMovable.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *