MultiPass & Rendering Order

I took a quick look in the source. To configure the CanvasPeer to draw the render passes on top of each other, you have to call


// clear the buffer...
canvasPeer.setDisableClearBuffer(false);
// ...but specify, that depth-buffer clearing is not necessary
canvasPeer.setFullOverpaint(true);

The MultiPassView however only calls the first in it’s prepareRenderOnce() method:


// MultiPassView:195 ...
prepareRenderOnce(RenderPass pass, boolean forceClearBuffer, boolean forceSwapBuffers, Canvas3D canvas3D)
{
        // (...)
        if (canvas3D.get3DPeer() instanceof com.xith3d.render.jsr231.CanvasPeerImpl)
        {
            com.xith3d.render.jsr231.CanvasPeerImpl canvasPeerImpl = (com.xith3d.render.jsr231.CanvasPeerImpl)(canvas3D.get3DPeer());
            // set clear buffer state
            canvasPeerImpl.setDisableClearBuffer(!forceClearBuffer);
            // set force swap state
            canvasPeerImpl.setForceNoSwap(!forceSwapBuffers);
        }
        else if (canvas3D.get3DPeer() instanceof com.xith3d.render.lwjgl.CanvasPeerImpl)
        {
            com.xith3d.render.lwjgl.CanvasPeerImpl canvasPeerImpl = (com.xith3d.render.lwjgl.CanvasPeerImpl)(canvas3D.get3DPeer());
            // set clear buffer state
            canvasPeerImpl.setDisableClearBuffer(forceClearBuffer);
            // set force swap state
            //canvasPeerImpl.setForceNoSwap(!forceSwapBuffers);
        }
}

which results in either no clearing at all or full clearing including the color buffer.

So to solve this, a new property - named “layered” for example - should be added to MultiPassView. If this is set to true, the two canvasPeer-properties should be set like the code at the top of this post for all render passes but the first one.

I’ll try this tomorrow, maybe :wink:

Ha!.. just tested it and it seems to work. The only drawback is, that you also loose the stencil buffer in “layered-mode”, but I don’t know, if someone might miss it in this context…

Great! Great! ;D Thank you very much.

Isn’t multipass rendering always layered? At least it should be the default. What is the effort of multipass rendering when it’s not layered?

Marvin

Dunno… maybe to better organize your scene by using multiple independent scene graphs!? Anyway, making the layered variant the default is a good idea as long as there are no compatibility concerns to change the default behaviour of the MultiPassView…

cylab, great to see you contribute !

When I saw “clearBuffers” I also had suspicion that it may be not only the depth buffer.

How to proceed? Should I send a patch or can I have write access to the cvs rep?

I might contibute a little (render-to-texture in MultiPassView and terrain maybe), but I have little time due to work and am not always very motivated to code after a 10hour day with J2EE :wink:

Please register at xith-tk and I’ll give you Developer access as soon as possible.

Great work cylab, I was waiting for multy-pass to really start working :wink: So looking forward to try it out when fix is comitted.
Thanks!

The I’d suggest you to further concentrate on terrain. It is a frequently requested feature.

I thought about porting this, but haven’t analysed it’s source yet.

Looks really really great. Would be fine, if we had it in xith… :wink:

just registered…

I tried this out. But with no success. for all passes the following code is executed:


canvas3D.get3DPeer().setDisableClearBuffer([b]!isFirstPass[/b]);
canvas3D.get3DPeer().setFullOverpaint([b]!isFirstPass[/b]);
canvas3D.get3DPeer().setForceNoSwap([b]!isLastPass[/b]);

Did I misunderstand anything?

I uploaded the new version. Please refer to this for further discussion.

btw. If you’re not utilizing the layered mode, you can even not-use the MultiPassView or put everything in one RenderPass.

Marvin

EDIT: Yeehaa! 500 Posts! ;D ;D ;D

:frowning:
I was just waiting for cvs-access to check my changes in…

Sorry, but I made further changes of cleanup and your changes were just a matter of about three lines of code. So I just made it for quick.

But it doesn’t work anyway. So please check, what I made wrong and check it in.

Marvin

Nevermind… I’ll merge it as soon as Amos gets back from whatever is keeping him away and gives me cvs access :wink:

I have also made a fix for texture-loading in the MD2Test, so…

In layered mode you have to enable the buffer clearing for every pass:


canvas3D.get3DPeer().setDisableClearBuffer(false);
canvas3D.get3DPeer().setFullOverpaint(!isFirstPass);

If you test this, don’t commit; in my changes I have already refactored the different renderOnce()-Methods to contain an additional parameter and the MultiPassView to contain the layered property along with getters and setters.

What do you mean? Why?

Mathias

access just granted… :wink:

It’s called Lycée.

;D

[quote="<MagicSpark.org [ BlueSky ]>,post:37,topic:27917"]
access just granted… :wink:
[/quote]
Thanks!

[quote="<MagicSpark.org [ BlueSky ]>,post:38,topic:27917"]
It’s called Lycée.
[/quote]
I was just about to ask you about a photo of her, but then I noticed google only found pictures of crappy schools ;D

Anyway - school on sunday ? :stuck_out_tongue:

I was just about to ask you about a photo of her, but then I noticed google only found pictures of crappy schools ;D
[/quote]
Aow ;D funny.

Oh no, no school on sunday, but err… no computer either (parents, grrr…).