Multi-canvas and post-processes

Hey, we are trying to add support of multi-canvases in the Babylon.js editor but we are facing a problem.

When using SSAO2 or Motion blur post-process (maybe other may generate this bug too), the rendering is broken: try to move the camera on the first canvas to see the problem. On line 79, try to change the camera the motion blur post-process is attached on.

As it is hard to have multiple canvases in the playground (at least I failed), @Soullnik created stackblitz that is available here: Motion Blur in Multi Views (duplicated) - StackBlitz

Is that a bug or a bad usage of multi-canvases?

Again, thanks a lot for you help !! :heart:

I guess @Evgeni_Popov will be able to answer. cc @sebavan

1 Like

Sounds like a limitation of multiview. I will see if I can find a quick fix.

2 Likes

I think it is connected with the active camera, because when adding motion blur, it is the camera that is setup for motion blur that becomes active in all views. And if you setup a camera in motion blur that is used as a camera with attachment control, then the behavior of all views breaks, because it does not find the camera.

1 Like

I also tried to implement mutli view from this topic registerView question - #4 by nazmouse22, but see the same behavior

1 Like

also i see the same behaviour using activeCameras and viewport

1 Like

This is a limitation we currently have relying on PrePass / GeometryBuffer renderer.

Let me check what is possible.

1 Like

I do not think that there is an easy solution unfortunately and this might require to rely on the scene graph later. Currently I think you might need two copies of the scene :frowning: cc @Evgeni_Popov

Is there an easy way to basically create a new scene that is not just a copy but is synchronized with another one? If a mesh is added or moved in the first scene, do we need to manually synchronize it to take effect on the second scene?

Thanks a lot :heart: for you help.

The multi-view feature is based on changing the active camera for each view and calling renderFrame, which is incompatible with frame graphs. We will have to think about supporting the multi-view feature with frame graphs, maybe by registering a graph with each view, instead of registering a camera?

That’s interesting what you say @Evgeni_Popov. In that case, the bug we have maybe it can be fixed easily. It looks like the geometry buffer renderer or prepass renderer are not cleared properly or something like that. calling renderFrame with camera1 and SSAO2 then calling renderFrame with camera2 and the same SSAO2 pipeline should work in theory. Resources are flushed or cleaned between 2 renderFrame, do you agree?

It will work, but only by using two scenes, because the (default) geometry buffer renderer / prepass renderer can only run a single time per scene.

You can create geometry buffer renderer instances yourself and set a different camera for each, though (not possible with the prepass renderer). See Viewport issue when using PrepassRenderer - #2 by Evgeni_Popov for an example on how to do it.

However, SSAO2 can currently only use the default geometry buffer renderer. In your case, you would have to pass the instance you want to use, which is not possible.

We could perhaps allow an existing instance to be passed for the forceGeometryBuffer constructor parameter…

What do you think @sebavan?

totally not opposed if it helps @julien-moreau

Awesome !! thanks a lot that would help a lot for sure

But for the initial problem, @Soullnik if you are available tell me if I’m wrong, I encounter the problem when the main camera has SSAO2 (with geometry buffer renderer) and the second camera has 0 post-process. Passing a custom geometry buffer renderer may be awesome to prepare the future but will not fix the current problem we face.

Or, that’s possible, I understood nothing :rofl:

Hey everyone, I am arriving a little later to the discussion. Recently, I tried the same as @Soullnik mentioned but creating a viewport to display a PiP camera. I want to add this feature to the editor.

I am facing the same issue, I can see the viewport but if the scene has SSAO2 or motion blur enabled the viewport disappears. Even if I turn off the processing pipeline in the camera.

If you guys have any ideas, please share.

1 Like

Sorry, I forgot to create the PR that allows you to pass an existing instance of a geometry buffer renderer.

This will enable you to do so:

Once it’s merged, you will be able to do:

    const geomBuffer = new BABYLON.GeometryBufferRenderer(scene);

    scene.customRenderTargets.push(geomBuffer.getGBuffer());

    const ssao = new BABYLON.SSAO2RenderingPipeline("ssao", scene, 1, undefined, geomBuffer);
2 Likes

I’m not sure it will fix your problem, though, as it seems this thread is about several problems.

If not, I will need a repro in the PG to investigate the issue.

1 Like