0

I'm trying to render some label textures with transparent background using OpenTK in Xamarin. At first the labels seemed display properly (see picture 1) but when the view rotated, the some label background are not transparent any more (see picture 2).

The enabled BlendFunc is GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha).

My question is how can I always have labels transparency on despite of their positions? The same code and shader can run properly on Android Devices by the way. Labels displayed OK

Labels cover each other

Heobien
  • 70
  • 1
  • 6

1 Answers1

0

Ah yes, the good old transparency problem. Unfortunately this is one that a graphics programmer has to solve on his own.

For just a few labels, the most straight foward solution is likely to sort your labels by z-depth and then render them from farthest to closest. You'd probably need to do some matrix math on that label position to adjust for viewport rotation.

For the 3d game I'm working on I have chosen to implement the order-independent transparency method called WBOIT by Morgan McGuire, which is fairly simple to implement and yields relatively good results.

Tyron
  • 1,938
  • 11
  • 30
  • I'm not sure if 50-100 labels are considered as "few" but for now I guess I have to sorting them by z-depth before rendering. Your link is also worth to check out as well. Thank you so much. – Heobien Jan 11 '21 at 14:49
  • You're welcome, z-sorting 50-100 labels should be perfectly fine – Tyron Jan 11 '21 at 15:40