Page MenuHome

Fix T35606: Font object visible through object with Z transparency set at zero

Authored by Ulysse Martin (youle) on Oct 2 2015, 3:02 PM.



Fix T35606: Font object visible through object with Z transparency set at zero

Render 3D fonts before the scene in KX_KetsjiEngine::RenderFrame (KX_KetsjiEngine.cpp)

Diff Detail

Event Timeline

Ulysse Martin (youle) retitled this revision from to Fix T35606: Font object visible through object with Z transparency set at zero.Oct 2 2015, 3:02 PM
Ulysse Martin (youle) updated this object.
Ulysse Martin (youle) updated this revision to Diff 5104.
Porteries Tristan (panzergame) requested changes to this revision.

@Ulysse Martin (youle): I'm not totaly agree with your patch. If the user want that a font be rendered after meshes ? A better fix will be to add a mode to select the font render order.


font.renderOrder = KX_FontObject::RENDER_PRE / RENDER_POST

And the same kind of thing in UI.

This revision now requires changes to proceed.Oct 2 2015, 8:36 PM

I'm not certain this is the correct fix. We need to figure out why the font objects are not interacting correctly with alpha polygons. How do fonts currently interact with the depth buffer?

@Porteries Tristan (panzergame): It could be an option, but I think it's normal that texts behind an object are masked... I'll tchat with you about this on IRC if you're here tomorrow or later :)
@Mitchell Stokes (moguri): I don't understand openGL enough to answer, but I thought that rendering font process was totally "separated" from Scene objects. I tell this because of RenderText3D function in RAS_OpenGLRasterizer.cpp which seems to disable many things (DisableForText() function). That's the reason why I thought it was simpler to render fonts before scene objects. But I'm not sure that wouldn't cause problem... Maybe a fix is possible in RenderText3D or DisableForText() functions... I'll make some tries :)

Ulysse Martin (youle) updated this revision to Diff 5110.

In DisableForText() function, GL_ALPHA_TEST is disabled. This causes this issue with my patch when the text is in front of plane:

So I re-enabled it in RenderText3D and it works:

Of course it needs review because I'm not sure of what I make...


you should not call renderfonts after this ?


instead of this you can apply the patch :

diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 24bf754..29f1b44 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -1352,8 +1352,8 @@ static void DisableForText()
 	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */
-	glDisable(GL_BLEND);
-	glDisable(GL_ALPHA_TEST);
+	// Set proper alpha settings.
+	GPU_set_material_alpha_blend(GPU_BLEND_ALPHA_SORT);
@@ -1432,7 +1432,6 @@ void RAS_OpenGLRasterizer::RenderText3D(
 	/* gl prepping */
-	glEnable(GL_ALPHA_TEST);
 	/* the actual drawing */

Hi, I've just seen this bug report: . @Dalai Felinto (dfelinto): I didn't understood all, but do you think reanable alpha_test to render fonts is a bad idea? Using GPU_set_material_alpha_blend(GPU_BLEND_ALPHA_SORT); is better? Thanks!