• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# (Order Independent) Transparency

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1gnomgrol  Members

Posted 22 December 2012 - 07:02 AM

Hello guys,

I started implementing transparency in my engine, and I got stuck on the usualy problem, I think, even thought I can't find very much helpful stuff on this.

I use a classic blendmode for transparent objects, and order them by the distance from the cam before drawing. This works fine if they are just a bunch of objects on behind another, but as soon as I rotate them or a model contains multiple polygons which have to been blended over oneanother, it becomes problematic.

For the rotationpart, I suppose I need a way to check the point of the object closest to the cam, and order them by this point rather than by just their position.

But I can't see someone preordering the triangles inside a mesh to get which transparent one needs to get drawn first.

As a solution, I have read about Order Independent Transparency, which is only for dx11, but that would be fine with me. I can't seem to pick up a good tutorial on this, so I may aswell ask you for one.

Or do you have another way of fixing those two problems?

Thanks so much!

-gnomgrol

### #2PhillipHamlyn  Members

Posted 22 December 2012 - 07:51 AM

I had some help earlier on a similar issue, if you search for the topic "Rendering Intersecting Premultiplied Transparent Planes" and look at the Billboard example in the Microsoft XNA samples site they show how two passes can be used to prevent intersecting planes from creating weird depth effects.

### #3eppo  Members

Posted 22 December 2012 - 11:25 AM

There's the 'OIT11' sample in the DirectX SDK. It's an expensive technique, though. You can often get away by using simple additive blending.

### #4deftware  Prime Members

Posted 22 December 2012 - 02:37 PM

Additive blending is the only blending that can be drawn without drawing back to front, yes, for everything else I always implemented a simple binary tree that receives all the triangles being sent to the renderer, inserting them into the tree based on their distance, and then when its time to draw them to the screen I just walk the tree drawing from back to front, deconstructing the tree as the triangles are rendered. This entails building a new tree each frame, but it could be set up to only build a new tree once things have moved around enough to require a new tree being built. Also, for large triangles that could be intersecting eachother this won't work properly, but it works well enough for most cases. If you have a lot of triangles in your scene, its better to precompute something like a BSP tree for the static geometry, as it wouldn't be very efficient to rebuild a distance binary tree every frame (or even every couple of frames) for tens-of-thousands of triangles.

### #5gnomgrol  Members

Posted 23 December 2012 - 03:21 AM

Thanks to all of you, calling

clip( Input.Color.A < 0.1f ? -1:1 );
in the pixelshader did it for me!

### #6Tsus  Members

Posted 24 December 2012 - 05:10 PM

Hi!

What you ended up using is called „alpha test“ and is not truly a solution to the blending of many transparent objects, though it is a common hack to avoid the problem.

Whenever you really need to approach true order-independent transparency, there are a number of methods:

• Depth peeling [Everitt 01, Bavoil & Myers 08] (Requires to know the number of layers, but was used quite often in research papers. Also works on Dx9.)
• Concurrent linked list construction [Yang et al. 10, Yakiimo 10]-> do not look into the DxSDK sample (OIT11). Last time I looked, it was poorly implemented (didn’t use shared memory at all).  Check the version of Yakiimo. He implemented it faster, even with multi-sampling. This technique grew more useful by the recent advances of the graphics hardware. Requires Dx11.
• Stochastic transparency [Enderton et al. 10] (also rather a research thingy. It can handle an arbitrary number of layers, but consumes much performance to get it frame-to-frame coherent). Needs Dx 10.1 if I recall correctly, as it works on the coverage mask.
• The list goes on... stencil routing etc... (Look into the related work of the papers I linked, if you want to learn more.)

AFAIK, true order-independent transparency was yet too expensive for games. (If someone knows a game that used OIT, please let me know!) It is easier to work around it or just sort the transparent objects by depth. (Of course, this doesn’t work in all cases, but you can tell your artist to circumvent the ugly cases.)
I’m creating technical demos and prototypes, so I can afford to use the concurrent linked list construction.

Best regards!

PS: Links don't seem to work at the moment, so I post the URLs.

Enderton et al. 10: http://www.enderton.org/eric/pub/StochasticTransparency_I3D2010.pdf

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.