BGE: Fix T29882: Add anti-aliasing filtering for fonts
Needs RevisionPublic

Authored by Thomas Szepe (hg1) on Mar 21 2015, 1:21 PM.

Details

Summary

This patch adds anti-aliasing of fonts to improve the rendering quality in the game engine.
It also fixes a z-order bug with overlapping text.

This patch was done by z0r (Alex Fraser) T29882

Diff Detail

Not really keen on this patch, but if its not effecting the existing code paths for 2d drawing then it could be OK.

source/blender/blenfont/intern/blf_glyph.c
179

why is this needed?

322–340

Would prefer to have a different draw function. blf_texture_draw_3d or blf_texture_draw_texfilter

Campbell Barton (campbellbarton) requested changes to this revision.Mar 21 2015, 2:52 PM
This revision now requires changes to proceed.Mar 21 2015, 2:52 PM
source/blender/blenfont/intern/blf_glyph.c
179

This modification was done by Alex Fraser (z0r). I think it is related to his comment in T29882 at Jan 18 2014.

Alex Fraser (z0r):
Note that this reverts commit 7c6d52e which stopped initialisation of the font image; initialisation is actually required for glyph padding when using mipmapping. Thanks to @Campbell Barton (campbellbarton) for assistance with this update.

322–340

I am unsure about this.
Because making a different draw function means I need to duplicate a lot of code (up to BLF_draw).
KX_FontObject::DrawFontText > RenderText3D > BLF_draw > blf_font_draw > blf_glyph_render > blf_texture_draw

Should I make new draw function BLF_draw_3d > blf_font_draw_3d > blf_glyph_render_3d > blf_texture_draw_3d functions?
Or should I make a function BLF_twist to switch in blf_glyph_render between the blf_texture_draw and blf_texture_draw_3d function?
Or do you have something else in mind?

Would rather postpone this patch,
its nice to have, but not really essential and theres many more urgent areas of the BGE to work on.

source/blender/blenfont/intern/blf_glyph.c
322–340

The callers of blf_texture_draw could check for BLF_TEXFILTER.

@Mike Erwin (merwin) : Is an equivalent of this feature (mipmap generation of text textures) existing or planed for the 2.8 viewport ?

I don't know what is planned for the 2.8 viewport. But I think they will not add a font texture filtering.

@Porteries Tristan (panzergame) Nothing like this is planned for the 2.8 3D viewport or 2D UI. We always draw screen-aligned text at a known size/scale.

source/blender/blenfont/intern/blf.c
527–528

Alpha test is not part of OpenGL core profile, so this would be ok for Blender 2.7x but not for 2.8+.