I’m wondering if there are any clever hacks for depth masking a sprite with alpha values. View the below screenshot:
The player has a box where it’s clearing the pillar behind it. If I don’t apply depth testing the player appears behind the model. I’m thinking the best way would be to somehow define a background color and remove it somehow via a shader but I’m still inexperienced in this field. Has anyone encountered this type of rendering conundrum before?
Thanks if anyone has some sage advise 
2 Likes
Try to add this to the box’s fragment shader (.fp):
if (color.a < 0.01) {
discard;
}
That’s slow on GPUs with tiled renderers (like on mobile)
2 Likes
Yes. If @Epitaph64 uses it for a small sprite, the performance will be OK 
I like this note from Mali GPU best practises guide:
For example, we tell you not to use discard in fragment shaders. It is inevitable that there are cases where you must use a feature that we do not recommend using, because the feature is required for some algorithms. Therefore, do not feel restricted by our advice to never use a feature. However, always keep in mind that there could be an underlying performance risk.
2 Likes
Thanks for the info! I’ll bear that in mind. I think at this point I’ll likely either go with all sprites or all models however for the performance benefits. I’m still trying to figure out the model rendering for HTML5/Android however.