I’m making a 3D game with 2D characters. When the player walks behind some geometry I’d like to show the shape of the character in front of everything. A common technique, however I’m having some issues with using Paper2D sprites.
This is how the effect appears in the editor. Everything looks good as an emissive layer is drawn using Post Process and Custom Depth.
However, as soon as I play the game, hiding certain parts of the character (which are separate sprites) behind geometry hides those components. In this example image the same character is only showing the hat in the post process effect, because the hat is slightly sticking from behind the tree and thus isn’t culled.
As far as I’ve seen from tutorials and other users this doesn’t happen with anything except Paper2D Sprites. I can personally confirm that it works fine with meshes. Even a fully occluded mesh will be drawn. Is there any way to force the Sprites to render so they can be used for custom depth?
This is old, but I’ve come into this issue myself, and solved it.
The issue is in occlusion culling, so when the whole sprite is occluded, the engine won’t render it at all.
To fix this, go to your object (sprite, flipbook, etc.) and increase the parameter for bounds scale.
Read more about occlusion culling here: Visibility and Occlusion Culling | Unreal Engine Documentation
I’m having the same issue (UE 5.0.3).
I’ve heard about using
Bounds Scale before but I was told that it was a bad idea to mess with that setting. Moreover, I was lead to believe that enabling the
Render Custom Depth setting in the actor was supposed to disable occlusion culling for that particular actor. And yet, it looks like this is not working for sprites.
Going back to the
Bounds Scale, the documentation mentions something about the shadow quality being degraded. What does it means? How does the setting affect the shadow? Does the quality degrades more with higher scale values? Since sprites have no depth, the bounding box itself is only 0.5 deep. So to have a custom depth that still works at some distance, the scale must be quite big, like 4000x just for a 20m. With such a high value, it makes me wonder if this is a good idea.
@NahorCA it’s fine! Numbers are just numbers, and sometimes they get strangely high, but it’s safe. 20m isn’t very far in this use case. Now if it was enough to encompass the entire world, I’d worry then. The size that would be important for the gameplay isn’t going to be big enough to affect load in any large way, so go for it! Make it a little bigger than you need and the program will be almost completely unaffected.
@GMchris Did this solve your issue?
That’s 20m in depth, and depth only. On the other two axis, it depends on the world size of the sprite, which for my use case is the standard capsule size (i.e. with a 4000x scale, the width x height are ~2x7 km). Is that still OK?
As for numbers being high, it all depends on how their usage, does it not? A high velocity can wreck havoc with physics and collisions for instance. Here, the fact that the
Scale Bounds documentation has a red warning, coupled with the km scale, is what concerns me.