After making this changes, I got the wrong render as shown at the top of this post.
In the first place, I thought the issue was because SSAO2 was applied prior to the model down loading. But when I was trying to replicate this process, looks even SSAO2 applied before model is loaded seems fine:
So just wondering does anyone know how to make SSAO2 render correctly?
@labris
Yeah in latest PG the SSOA2 is applied even before the human model is loaded right? Then after the human model loaded, the AO still look alright.
However why it does work in the amazkn model viewer?
I tend to understand the essence of your question less and less.
SSAO2 applied as a post-processing effect after the main scene rendering.
If there is an empty scene, it willl process empty scene. If there are models, SSAO2 will calculate occlusion in screen space, using the depth buffer and normals of visible pixels.
Is there any chances to revert those changes? Seems they do more harm than good, visually
I’ve just verified that everything works fine in the PG: the SSAO2 pipeline is added before the human mesh loads, yet the effect still renders correctly. I originally thought SSAO2 had to be set up after all meshes were in the scene, but it seems you can attach the pipeline to an empty scene first and load the meshes later without any problems—am I understanding this correctly?
My actual issue is that after enabling the SSAO2 rendering pipeline in the @amazon/lib-3d-scene-viewer code-base—using the config at here —the scene develops that flat, 2D-looking artifacts:
So my question here is why does SSAO2 render correctly in the PG but produce flat, 2-D artifacts in @amazon/lib-3d-scene-viewer? I initially suspected an ordering problem—i.e., that SSAO2 must be added only after the scene and all models finish loading—but the Playground example suggests order may not be the root cause. Can you confirm that?
I inserted an onModelLoadedObservable hook:
v3dScene.observableManager.onModelLoadedObservable.add((model) => {
// some code to add/configure SSAO2 at this point
});
—immediately after -line 107 in v3dViewer.ts. Once every mesh finished loading, the handler configured and attached the SSAO2 pipeline, and the ambient-occlusion rendered correctly. Because this fix works, I originally concluded that SSAO2 must be added after all models load (it is, after all, a post-process), although the PG example now suggests that timing alone may not be the real root cause. And this is very confusing to me.
In general I am just trying to understand does execution sequence order matter for SSAO2 in general and why it doesn’t work within @amazon/lib-3d-scene-viewer?
Thank you very much for reading it through up til here and sorry for confusion.
As I see Amzn viewer uses DefaultRenderingPipeline. Try to force geometry buffer for SSAO2
var ssao = new BABYLON.SSAO2RenderingPipeline("ssao", scene, { ssaoRatio: 0.5, blurRatio: 0.5 }, undefined, true);
set the last parameter to true.
gotcha. Actually I have checked their code base in sceneManager seems they are setting forceGeometryBuffer to false. So does their config.
It seems like they are not setting forceGeometryBuffer to true by default. Are you sure they are trying to force the geo buffer? Also just wondering, is it recommended to set forceGeometryBuffertrue or false? especially for mobile devices?
Also, it seems that there is no problem for them to work together in their Sandbox - Viewer
Probably you need to check your code
Yeah I checked that sandbox setting earlier too.
So is it ok to apply SSAO2 even before loading the human model?
In case if the app only works with true it is definitely recommended to use true.
If it works with false without any hassle - even better.
Without any 3D models in your scene, SSAO2 wouldn’t have any geometry to process and would effectively do nothing. When the model will be there, SSAO2 will contunue to work as it should to. This is just a postprocess.