Quote:
Originally Posted by Chip Midnight I don't have much of an opinion about D3D, but I will say in its defense that the alpha sorting bug we all love so much in SL is an OGL bug. How many more years are going to go by before it's fixed? My enthusiam for OGL only goes so far. |
Good point Chip.
That said, for on/off transparency, which I assume is the type we see in clothing and hair that results in perhaps the most annoying of the artifacts you note, there do appear to be some options available, even inside an OpenGL framework:
Quote:
Alpha-blending and the Z-buffer.
By Steve Baker
Introduction - Bad news. REALLY Bad News.
Shock! - Horror!...
The Z buffer doesn't work for transparent polygons.
The problem is that the Z buffer prevents OpenGL from drawing pixels that are behind things that have already been drawn. Generally, that's pretty convenient - but when the thing in front is translucent, you NEED to see things that are behind it.
.........
.........
Another Good Trick
Quite often, alpha-blended polygons are used with textured alpha to make 'cutout' objects. If you want to draw something complicated like a tree, you probably can't afford a polygon for each leaf and branch - so you use an alpha texture map and a photo of a tree.
The point is that this polygon may well have no partially translucent pixels - there are lots of utterly opaque ones in the middle of the tree - and lots of utterly transparent ones around the outside. In principle, there shouldn't be a problem with Z buffering...but there is because by default, even the totally transparent pixels will write to the Z buffer.
Fortunately, OpenGL has a function that can prevent pixels with a specified set of alpha values from writing the colour or Z buffers. For example:
glAlphaFunc ( GL_GREATER, 0.1 ) ;
glEnable ( GL_ALPHA_TEST ) ;
This will only allow pixels with alpha values greater than 0.1 to write to the colour or Z buffers. You have to use this with care though - bear in mind that if your texture filter is set to one of the LINEAR or MIPMAP modes (eg GL_LINEAR_MIPMAP_LINEAR) then even if the top level texture map contains only 0.0 and 1.0, intermediate values will creep in during the filtering process.
However, this is another thing that will reduce the number of problems associated with Z-buffered rendering of alpha-blended polygons. |
(
Alpha-blending and the Z-buffer.)
And interestingly, a one-bit alpha approach is actually under consideration by LL:
Quote:
[ Permlink | « Hide ]
Qarl Linden added a comment - 11/Jul/08 02:49 PM
Uchi just directed me to this jira -
there's an identical task in our internal jira - the concept is to provide an option in the texture parameters to switch between alpha-blending and alpha-masking.
when it'll get done is anyone's guess, but 51 votes is nothing to sneeze at. |
(
[#VWR-6713] Alpha Sorting with a 1-bit alpha channel. - Second Life Issues)