Game Development Community

TGEA 1.8 Beta1 -- alphaTestEnable and particle blends

by Jeff Faust · in Torque Game Engine Advanced · 12/06/2008 (8:26 am) · 1 replies

The current particle rendering is setting the rendering-state alphaTestEnable to true for all particle blends. While this is fine and desirable for many blend choices, notably the common additive and lerp-alpha blends, it is not appropriate for all of them. For instance, when using a premult-alpha blend, a zero alpha is *not* invisible, so you don't want the alpha-test to filter out the blend operation.

Here is a quick-and-dirty fix that goes in renderTranslucentMgr.cpp in the RenderTranslucentMgr::getStateBlock() method:
// Replace This
d.alphaTestEnable = true;

// With This
d.alphaTestEnable = (d.blendSrc == GFXBlendSrcAlpha && (d.blendDest == GFXBlendInvSrcAlpha || d.blendDest == GFXBlendOne));

This is a quick fix because it merely enables the alpha-test for the common additive and lerp-alpha blends and disables it for everything else. It works, but it may not be the most efficient if many blends other than the most common are used. A more complete and efficient fix should be possible by carefully setting combinations of alphaTestEnable, alphaTestRef, and alphaTestFunc on a per-blend basis.

About the author

Jeff Faust creates special effects indie middleware and games for Faust Logic. --- Blog: Effectronica.com --- Twitter: @FaustLogic


#1
12/06/2008 (1:45 pm)
Logged. I'll look into the more complete and efficient fix (but probably just stick in the quick-and-dirt fix).