Transparency sorting question

A scene with directional and ambient light (used with their default constructor, ie no boundingsphre or such):

All the test models have got a transparent “head” (the claret one). There’s a huge textured and transparent plate on the floor (consisting of a Shape3D with IndexedTriangleArray: two large triangles).

If transparent parts of one model are behind the transparent parts of another model everything looks OK. However, when you move the models down below the plate, what you see is their transparent head just disappear. :expressionless: Depending on the camera view position they’re actually not always disappearing but mostly.
I’ve tried to capture that effect:

http://mitglied.lycos.de/nautis/Publik/Sort.jpg

I’m aware that the sorting of the transparent Nodes and the large plate is difficult because of that large plate. So in case they’re rendered in a “wrong” order, the transparency effect won’t be right… but why does it disappear? I don’t understand this. Maybe I use Xith3d in a wrong way? So I’d like to ask you 3d experts out there. :slight_smile:

PS: The models I load with Kev’s nice 3ds loader, the plate I construct like this:

Can be related to depth test/depth buffer writes. If your transparent plate was rendered first (because of rendering order sortind, i.e. it was farer) but its depth values are closer to the viewer than smaller shape (because of it is big), and you have depth writes & depth test enabled, then smaller shape does not pass depth test because of it is “occluded” in depth buffer by bigger shape.

Yuri

[quote]Can be related to depth test/depth buffer writes. If your transparent plate was rendered first (because of rendering order sortind, i.e. it was farer) but its depth values are closer to the viewer than smaller shape (because of it is big), and you have depth writes & depth test enabled, then smaller shape does not pass depth test because of it is “occluded” in depth buffer by bigger shape.
[/quote]
I’ve not set any special Xith options on the objects or the plate. So does Xith does handle the transparent surfaces to “have to be sorted on 2nd render pass”? I would say yes for the normal objects, because their transparent parts do look right (so are being sorted).

For OpenGL transparency drawing I’ve read that at the first render pass only the non-transparent surfaces are being drawn (with depth write & depth test enabled), and on the second pass all the transparent surfaces are being drawn in sorted order (but with depth write off). {*}

Still this leaves the question, why could the transparent plate “occlude” the transparent (red) hat, when both are being handled on the 2nd render pass?

Or put it in another way: which Xith options would I have to set in order to make my example work?
Or is it generelly impossible to have such a large transparent plate which covers the entire game area, plus transparent objects?

{*} OpenGL Redbook, Chapter 7. Blending, Antialiasing, Fog, and Polygon Offset, “Three-Dimensional Blending with the Depth Buffer”:[quote]If you want to render both opaque and translucent objects in the same scene (…) The solution is to enable depth buffering but make the depth buffer read-only while drawing the translucent objects. First you draw all the opaque objects, with the depth buffer in normal operation. Then you preserve these depth values by making the depth buffer read-only. When the translucent objects are drawn, their depth values are still compared to the values established by the opaque objects, so they aren’t drawn if they’re behind the opaque ones. If they’re closer to the viewpoint, however, they don’t eliminate the opaque objects, since the depth-buffer values can’t change. Instead, they’re blended with the opaque objects.
[/quote]

[quote]So does Xith does handle the transparent surfaces to “have to be sorted on 2nd render pass”?
[/quote]
Yes. You can specify sorting policy with View.setTransparencySortingPolicy(…).

[quote]For OpenGL transparency drawing I’ve read that at the first render pass only the non-transparent surfaces are being drawn (with depth write & depth test enabled), and on the second pass all the transparent surfaces are being drawn in sorted order (but with depth write off).
[/quote]
Of course, this is right, but you have to set this (depth write off) manually on your translucent shapes using setDepthBufferWriteEnable(true) on RenderingAttributes for given shape.

Yuri

Thanks for the hint. This method is also Javadoc’ed I see. :slight_smile: I’ve not changed the value from its default TRANSPARENCY_SORT_GEOMETRY to TRANSPARENCY_SORT_BOUNDING_SPHERE_AND_EYE_RAY_INTERSECTION and the result looks very well (the problem doesn’t exist anymore.)

Are there any major drawbacks (aside more needed CPU) ? Ie does it “hurt” a lot?

[quote]Of course, this is right, but you have to set this (depth write off) manually on your translucent shapes using setDepthBufferWriteEnable(true) on RenderingAttributes for given shape.
[/quote]
OK. I did this (with view set to default TRANSPARENCY_SORT_GEOMETRY). However the result is not what I expected: doesn’t look good and I’ll leave the RenderAttributes to its default value and use the view’s advanced TransparencySortingPolicy.

Thanks for your help, Yuri.

[quote]Are there any major drawbacks (aside more needed CPU) ? Ie does it “hurt” a lot?
[/quote]
It is even not more-cpu-intensive. Depending on the nature of your scene, either default or advanced withh work better.

Yuri