Simple fading, QUEUE_TRANSPARENT and culling


I want to fade out Boxes in my game, doing something like this:

        node.getChild(0).setRenderState(getTransparence());  //gets the right AlphaState
        node.addController(new Controller() {
            private float time = 0;
            public void update(float f) {
                time += f;
                ms.getDiffuse().a = (2 - time) / 2;        //ms is the MaterialState
                if (time > 2) {

This minimalistic approach works well, I have just one problem: When fading out, the inner sides of the box get visible, and they don't seem to fade out as the front sides, they just don't change in any way. I don't understand why only the front sides get transparent. That looks really stupid...

My idea was to cull the back sides away, but it seems that this doesn't work in QUEUE_TRANSPARENT mode. To verify this, it set the cull mode to CS_FRONT, so I had "hollow" boxes in normal node. As soon as I switched to QUEUE_TRANSPARENT, the front sides appeared. I don't understand why it's implemented that way: Even if I can see a back side because of transparency, it is still a back side, and if I say "throw it away", the renderer should do it...

I also tried to comment out the QUEUE_TRANSPARENT mode, and this was OK with all nearby objects (and culling was working), however the Skybox was not shining through, and the part of the sky covered by the box was full black.
There is not more than one box transparent at a time, so this approach could work for me (if I get this problem with the skybox fixed).

Hmmmm... transparency seems quite "intransparent" to me...

Any ideas?

Did you apply your material to Front AND Back faces?

Also, culling appears to not be working in transparent queue mode because of two pass transparency (it forces its own cull state.)  You can toggle that off in RenderQueue, but transparency may not look as nice as you'd like.  (Play with toggling it in TestRenderQueue.)

No, I put material just on the front sides (the node just contains a simple Box), but it's visible from the back. If I could turn this off, my problem would be solved.

I'll try to turn off two pass transparency…


Without two pass transparency, everything looks excellent. Because I have never more than one transparent object, I should be fine. Thank you, renanse!