Monday, March 12, 2012

Single Pass Order Independent Transparency - the beginning


Transparency is an important visual technique in real time rendering - think water simulations or tinted car windows in games. Unfortunately, one of the main limitations of the Z-buffer is its ability to handle transparency. The Z-buffer stores just the closest fragment for each pixel cell. This approach works fine for opaque scenes as there is no need to remember farther away fragments if we cannot see through the closest fragment. But when transparent objects are present in the scene, the final color of the pixel is dependent on all the transparent fragments. The Z-buffer does not give us the storage space for that.

There are several approaches to cutting around the transparency problem. One method is to sort the transparent surfaces from back to front and render after the opaque object pass. This can be both slow and hazardous. Another method, called depth peeling, avoids the sorting problem but requires multiple rendering passes. If there are many transparent layers, this can become quite slow.

With advances in DirectX 11 and OpenGL 4, single-pass OIT is now possible. ATI has presented a solution involving atomic operations and append buffers where each pixel stores a linked list of its transparent fragments. The image below is a screenshot from a real time demo using Direct X 11.




I hope to implement single-pass order independent transparency in OpenGL and C++, specifically using the atomic operations introduced in OpenGL 4.2. One of my key resources will be the first chapter of Patrick's book OpenGL Insights. The chapter is called Efficient Layered Fragment Buffer Techniques and is written by Pyarelal Knowles, Geo Leach, and Fabio Zambetta. One nice thing is that they tested their implementation on a GTX 460 which is the same card I have.

Their explanation is concise and detailed. While their primary target is transparency, their approach is general enough that it may be applied to other rendering techniques involving multi-fragment storage per pixel. I feel like there is a LOT on the horizon for atomic buffer reading and writing.


No comments:

Post a Comment