Thanks a lot @Evgeni_Popov !!!
Because it was reproduced using viewports, it’ll be easier to reproduce on playground. We’ll provide you one ASAP
@Evgeni_Popov I reproduced successfully in a playground: Babylon.js Playground
Here, if you deactivate motion blur, viewports work, else it doesn’t. In the Babylon.js Editor I also expriment this bug using multi views and, what I observed, it looks like the depth/position/normal buffers used in motion blur (attached to the main camera) are based on the result of the second camera. Do you see what I mean?
Also @Evgeni_Popov using this playground with SSAO2 (https://playground.babylonjs.com/#2S2XU7#1) the result works as expected when not forcing geometry buffer renderer (using prepass I guess). Once we put “true” to force gbuffer renderer the issue is noticable.
EDIT: using multi views (multiple canvases), I noticed that calling this.scene.prePassRenderer.markAsDirty() at each rendering loop (in engine.runRenderLoop) it fixes the bug. It looks like what I noticed in the Editor is a good thing to track!
Thanks again for your help ![]()
Thanks for the repro!
It’s not really working, because the second viewport doesn’t display anything.
Using post-processes that rely on the prepass renderer in a multi-viewports scenario won’t work, because we can’t use multiple instances of the prepass renderer during a frame.
It’s possible to make it work by using multiple geometry buffer renderers, though. For this to work (at least with SSAO2 and motion blur), this PR has to be merged:
When done, this PG will work:
It uses a SSAO2 + motion blur post-process for each of the cameras.
Make sure to set:
geomBuff.getGBuffer().ignoreCameraViewport = true;
geomBuff.getGBuffer().activeCamera = camera;
after all pipelines / post-processes have been created for camera, because the gbuffer used by the geometry renderer could be disposed/recreated during these creations!
Let me know if it works for you.
I can confirm that in the editor it works using prepass renderer and calling markAsDirty, at least using multi views.
See the rendering loop of the preview panel. I noticed also using multi-views, the rendering loop is called twice so it makes sense: Editor/editor/src/editor/layout/preview.tsx at master · BabylonJS/Editor · GitHub
I attached SSAO2 in the main camera only and boosted the strength to see it. Here a result showing nothing is blurred or glitched and the second camera is free of post-processes as I attached only in the main camera:
Thanks a lot for your fixes, I’ll try it ASAP and tell you if there is any problem. In my case, setting only activeCamera on the GBuffer may do the trick but of course I’ll test with both.
Yes, using multiple views is a little different, because the scene.render function is called once per view, which allows you to reuse the pre-pass renderer (I think you need to call markAsDirty, because the camera is different for each view). But in the case of multiple viewports, scene.render is only called once.
Really makes sense, thanks for the confirmation!
