Thursday, August 30, 2012

UDK Lens Flares as Labels (+Using the Emitter Color to modify the UV coordinates of the texture)

So, I've needed to put floating labels in some of my scenes. For this, I've been using lens flares to good success.
Here's an example:


As you can see, it's pretty straight-forward. I'm just using the source of the LensFlare and adjusting the  properties to fit the scene. With this, I get fading up close, fading far away and other nifty transforms based on distance and screen position.

In my current project, I needed sequentially numbered labels from 1-9. I really didn't want 9 textures, 9 material instances and 9 lens flare objects in my library. If I had to update any of those things, it would be an ordeal. Admittedly, a MaterialInstance would have helped a lot, allowing me to make changes to all the labels fairly easily. However, the LensFlare system does not have an instancing system, so I'd still be stuck with 9 lens flares to adjust. Blech! I REALLY wanted to find a way to avoid that and have a single texture/material/lens flare to deal with, and I think I found a good way of doing it.