Download

Lighting a Sprite

The goal of my post is to, primarily, gain a better understanding of the use of 2D sprites in the 3D world of UE4. Thus far, I’ve been working with purely unlit sprites and, in this simplistic model, found them to be very friendly to the amateur programmer. Now that I’m moving into the realm of lighting (which, theoretically, should still be applicable to 2D), I’m finding a couple issues that I hope the fine UE community can help with. As a guide through the issue, I’ve tried the following simple exercise:

First, the creation of a very basic material using the Default Lit model…
LitTexture2D.jpg

Applying an instance of this material to a sprite in the scene editor and shining a spotlight on it results in a very black square.
8093fba43ec2eb5684170f3c7249c077590dd2da.png

Switching to an unlit view certainly proves that the sprite exists…
SceneUnlit.png

Investigation of the material editor informs me that there is, in fact, a blank side (due to face culling), and enabling “two sided” forces visibility of the back side.
1cf572851e1bded4bfc05c0bc567f2c69dc95144.png LitTexture2D_3.png

A little research tells me that face culling is an optimization feature of 3D graphics environments. Returning to my exercise, I postulate that I’ve been looking at the culled face of my sprite and that, logically, a visible side must exist as well! Yes, by switching the side of the sprite that the spotlight is on, it becomes visible…
2c4ab59f8806ec20d04b0504eb2a3fcea9742bb5.png

Making sure “two sided” is enabled, and returning the spotlight to the “front” side of the perspective also renders the sprite visible…
SceneLitTwoSided.png

So, after a whole lot of probably useless screen captures, what does this all mean? I could be crazy, but it seems like the default culling face for a 2D sprite is, sadly, on the same side as is viewable from the “front” perspective of the scene editor. The same perspective that is the suggested view for 2D development. Sprite actors can obviously be rotated to bring their visible side to the “front” (although the texture ends up mirrored), and “two sided” can be used to completely bypass the problem (but with a performance penalty). Is there a better alternative approach? Or, is a 2D project simply forced to make compromises to fit into a true 3D environment?

Any light that can be shed on this subject would be greatly appreciated!