[request] Premultiplied alpha support
by Manoel Neto · in Torque 3D Professional · 09/03/2009 (1:05 pm) · 5 replies
It would be nice to have one extra blend op on the materials: preMultAlpha, for premultiplied alpha. It should work like this:
Premultiplied alpha has several advantages over lerpAlpha. Here's an article on it:
home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]]
The most important is that you get visually the same results as lerpAlpha, but completely avoids haloing artifacts and don't need to de-fringe your textures. Also you can transition between simple additive blending and lerp blending by manipulating the alpha value.
desc.blendSrc = GFXBlendOne; desc.blendDest = GFXBlendInvSrcAlpha;
Premultiplied alpha has several advantages over lerpAlpha. Here's an article on it:
home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]]
The most important is that you get visually the same results as lerpAlpha, but completely avoids haloing artifacts and don't need to de-fringe your textures. Also you can transition between simple additive blending and lerp blending by manipulating the alpha value.
About the author
Recent Threads
#2
09/03/2009 (2:46 pm)
Quote:I... I didn't know that. You mean pre-mult stuff can be drawn out-of-order? The pre-mult awesomeness knows no bounds!
Also, you forgot you can render pre-mult alpha stuff front-to-back, which also rules ;)
#3
Edit: Not finding a source on that drove me crazy, I finally found my source: realtimecollisiondetection.net/blog/?p=91
09/03/2009 (3:05 pm)
Yep, because pre-multiplied alpha is all about how much of the "background" you are occluding IIRC. I could be totally wrong, that's just something I seem to remember.Edit: Not finding a source on that drove me crazy, I finally found my source: realtimecollisiondetection.net/blog/?p=91
#4
09/03/2009 (3:21 pm)
Wouldn't that require destination alpha? If you write the alpha and invert the blending formula so...dst.rgb = dst.rgb + src.rgb*(1-dst.a) dst.a = dst.a + src.a*(1-dst.a)...then enable destination alpha and clear the buffer alpha to 0, you can draw the translucent surfaces from front to back, yes, but not out-of-order. This completely reverses the scene drawing order: the opaque objects would need to be rendered last and they would need to have blending enabled as well so they "back-blend" against the already drawn translucent objects, unless translucent objects are drawn to a separate buffer and composite with the opaque ones.
#5
09/03/2009 (5:48 pm)
Ah yeah, that is the key. You can draw front to back, but not out-of-order. The cool thing, though, is that this should let us sort all render instances the same way: front-to-back.
Torque 3D Owner Pat Wilson
Check out the renderParticleMgr and the particle shader (there may be a bug in there in B5 that is fixed, I can post fix if needed). I am using pre-multiplied alpha to emulate blend types (except subtract).
I hope to have this behavior integrated into the material system for 1.1, meaning that all translucent objects (not just particles) will have the same abilities.
Also, you forgot you can render pre-mult alpha stuff front-to-back, which also rules ;)