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.
After digging around in the LensFlare editor, I found exactly what I was looking for! The Modulate Color by Source checkbox!
What this does is take the source color of the emitter instance in the scene and modulates the vertex color with it, sending that value to the shader applied.
With that, I pump the color info to the texture coordinates of the texture, modifying the position of the texture samples on a per-instance basis. So, on each LensFlare instance I can set the number displayed by simply changing the X and Y offset of my texture coordinates, looking up a different portion of my texture map.
And, here's the effect in the scene. Now I have one Material, one MaterialInstance, one Texture2D and one LensFlare. Now let's hope the client doesn't want to have each label a different color! :P
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.
After digging around in the LensFlare editor, I found exactly what I was looking for! The Modulate Color by Source checkbox!
Modulate Color By Source |
Source Color |
And, here's the effect in the scene. Now I have one Material, one MaterialInstance, one Texture2D and one LensFlare. Now let's hope the client doesn't want to have each label a different color! :P
Comments
Post a Comment