Jump to content
  • Advertisement
Sign in to follow this  
godmodder

Alpha blending without sorting?!

This topic is 4712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I've read somewhere that the use of destination alpha can (partially) solve the issue of having to sort transparent objects for proper blending. It wasn't practical in the old days because almost no card supported it, but it IS supported on allmost all graphics cards nowadays. It seems that this technique has somewhat slipped away from most programmers' mind, cause I can't find many recent sources about it. Has anybody got any experience on how to use destination alpha to render transparent objects? It would be great to render them allmost perfectly (I can stand a few glitches) without the damned sorting. Thanx, Jeroen

Share this post


Link to post
Share on other sites
Advertisement
How about emulating alpha blending in the pixel shader as described in ShaderX2 by Francesco Caruzzi?

Share this post


Link to post
Share on other sites
while nice blending can be acheived using the blend modes, It doesnt really solve the sorting problem: either a pixel writes to the z buffer or it doesnt.

however, Carmack has discussed a novel way of doing order-independent transparency: render all translucent objects to a separate screen-sized render target, with alphablending off, and alphatest on, using a sort of dither pattern to approximate the level of alpha. Then blur the result a bit somehow, then render the final thing to screen aligned quad, using dest alpha. I dont see why this cant work for most purposes.

Share this post


Link to post
Share on other sites
Could you point me to an article of Carmack explaining this technique. Or do could you elaborate on it a bit more? I'm very eager to learn about this new way to handle transparency.

Jeroen

Share this post


Link to post
Share on other sites
doesn't sound really "novel" to me, as that seems to just be an advanced form of screen-door transparency. btw, you might want to check out "alpha to coverage" as seen in http://www.humus.ca/index.php?page=3D&ID=61

Share this post


Link to post
Share on other sites
Thanx for the replies everyone,

I want to render transparent glass in my game. Is alpha coverage even an option here? Anyway I'd love to here about the way Carmack handles this. A clicky to an article/tutorial would be very much appreciated.

Jeroen

Share this post


Link to post
Share on other sites
I've heard of a method which involves multiple renders and the accumulation buffer to get it to work without sorting, but I've never tried it myself. That's the only thing I've seen refrencing it properly and regretfully I don't have the article, hopefully it helps.

EDIT: Here is a paper on it http://developer.nvidia.com/object/Interactive_Order_Transparency.html though I don't know if this is the technique I was refrencing or not. It's called "depth-peeling"

Share this post


Link to post
Share on other sites
Quote:
Original post by godmodder
Thanx for the replies everyone,

I want to render transparent glass in my game. Is alpha coverage even an option here? Anyway I'd love to here about the way Carmack handles this. A clicky to an article/tutorial would be very much appreciated.

Jeroen


i think alpha to coverage should look ok for glass (alpha blending isn't particularily realistic for glass either), best you just try it, for example download the humus demo and replace the wire mesh texture with your glass texture (just draw the appropriate alpha into the texture map). source code should also be included with the humus demo, so that's a good starting point for understanding the usage. (basically just load the extension, and enable/disable the right variables)

depth peeling is way too slow on most current graphics cards

Share this post


Link to post
Share on other sites
It's in this QuakeCon talk by Carmack, I'm surprised everyone here hasnt read this :)

http://www.gamedev.net/community/forums/topic.asp?topic_id=266373

His method is more complicated than I described, but thats the basic idea. I dont really get this alpha-to-covereage method though..

Share this post


Link to post
Share on other sites
Alpha to coverage does exactly that: it uses the pixel alpha to generate the fragment's "coverage" mask. Thus if you're using N-sample multisampling, you get N levels of "free" sorted transparency levels.

It's certainly not a perfect solution, but it's practically free if you're using multisampling already, and works well enough for small objects. Larger objects can be easily sorted.

The only really sure-fire method that will work in all circumstances is to sort per-fragment... depth peeling seems to be the best current option for that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!