We are very pleased with Java3d's new transparency sorting system.  Like
some of you we were a but stymied on how to handle the fact that most of our
transparent objects have geometry arrays which themselves need to be sorted
to render properly.  So while our shapes would sort properly, without
putting every triangle into its own geometry aray there is no way to render
"perfectly".  The cost of doing this is far too high however.  Then we
lucked on a trick which I am sure many of you already know, but some might
not.  For us, transparency is used in several places : vegetation, particle
systems, sky system, etc.  But it was vegetation that really depends on
transparency to look good.  Even with transparent geometry sorting on, we
would get noticible artifacts where the various branches would render with a
blend of the wrong geometry.  But we found a trick to radically improve the
look of this, even if it is not perfect.

The trick is to combine the rendering attribute alpha test function and
value with the transparency attributes.  99 percent of many alpha masked
objects are actually at 100 percent transparent, with 1 percent needing a
true blend.  The edges of our vegetation is translucent, the rest is either
transparent or opaque.  By using:

RenderingAttributes.setAlphaTestFunction(RenderingAttributes.GREATER) and
RenderingAtributes.setAlphaTestValue(0f)

Along with the transparency attributes in BLEND mode, you remove almost all
the artifacts caused by imperfect triangle sorting.  The rendering
attributes determine if the pixel is written for that location according to
the test, so by setting it to only write when the alpha is greater than
zero, you stop it from being blended if it is totally transparent.

The results are quite nice.  Here are some screenshots demonstrating this:


http://www.cosm-game.com/screenshots/cosm539b.jpg

http://www.cosm-game.com/screenshots/cosm540b.jpg

http://www.cosm-game.com/screenshots/cosm541b.jpg

David Yazel
Cosm Development Team

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to