Page MenuHome

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

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

Details

Summary

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.

e.g:

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?

Hi!
@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: http://www.pasteall.org/pic/93763

So I re-enabled it in RenderText3D and it works: http://www.pasteall.org/pic/93762

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

source/gameengine/Ketsji/KX_KetsjiEngine.cpp
1109

you should not call renderfonts after this ?

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
1436

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);
 
 	glDisable(GL_LIGHTING);
 	glDisable(GL_COLOR_MATERIAL);
@@ -1432,7 +1432,6 @@ void RAS_OpenGLRasterizer::RenderText3D(
 {
 	/* gl prepping */
 	DisableForText();
-	glEnable(GL_ALPHA_TEST);
 	/* the actual drawing */
 	glColor4fv(color);

Hi, I've just seen this bug report: https://developer.blender.org/T29804 . @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!