memononen / fontstash

Light-weight online font texture atlas builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blending only works partially

behrisch opened this issue · comments

Thanks a lot for providing this library! We are currently converting our project to use it and it may be entirely my lack of GL understanding but I am not able to make the blending work out correctly. Some background polygons are blended correctly but some are not, see the picture. Sometimes the streets are blended correctly (see for instance the "am" of the upper amenity.restaurant) but sometimes not (see the last "a" in the same text). Every street has the same z value while the text is drawn slightly above. The code for text drawing is here: https://github.com/planetsumo/sumo/blob/master/sumo/src/utils/gui/div/GLHelper.cpp#L458 Any help is welcome!
grafik

I haven't looked at the code but judging just from the image this might be a draw order issue. With transparent objects just plain z-buffering is not enough to get correct blending (depending on the blend mode). You need to issue the draw commands in order so that the objects "further" away are drawn before the ones on top of them. Here is some basic info: https://www.khronos.org/opengl/wiki/Transparency_Sorting

Thank you, I am using alpha testing now instead of blending and it looks just fine.