SSAO not respecting disabled mesh in glb

I’m just starting out in Babylon.js and was trying out the SSAO on my .glb files. My .glb has several objects in it, and when I load just one, the SSAO works just fine:
But when I import all of the objects in the glb file, then disable all but the same one in the above playground, the AO looks like it might still be calculating all of the objects, even though they’re disabled:
I tried closing the little eye in the inspector, turning off visibility… it still thinks they are there. Is there another way I should be disabling them or should I be loading them separately for this to work? The models are a morph sequence for a protein… essentially I plan to create a slider to toggle between them to fake an animation.

Welcome aboard!

Your PG does not work because of CORS security problems.

I tested it locally and it seems it does work, the meshes you disabled by code are disabled and not displayed.

SSAO is applied at the end on what is displayed on the screen, so if a mesh is not displayed it can’t generate SSAO.

So, this does work for me (with the animation):

Thank you for your kind reply. When I tried your playground I get a 404 error for the .glb load, is that expected?

I’m running the Allow CORS: Access-Control-Allow-origin :: MyBrowserAddon extension in my browser and added my domain to the whitelist. CORS is currently allowed for GET, PUT, POST, HEAD and GET(with credentials). The models have always loaded ok with this, would something different be required for the AO? What I’m seeing is:

#13 is what it should look like, but #14 is what I’m seeing. These numbers refer to my playground links in my original post.

My playground is using a local directory to get the asset, you should change it (line 31).

What I’m seeing at start if I disable the animation (comment lines 50-59):

That seems ok to me (?)

I took a look and your file was having the same issue as mine in #14 where the AO wasn’t sitting in the proper groves etc. I played with it some more, and I stumbled into the problem.

In #14 and your playground (#15) I was scaling the root object: newMeshes[0], but in #13 I was scaling the first spike newMeshes[0]. When in #14 or #15 I instead scale all of the spikes by themselves, the AO behaves exactly as I would expect.

For some reason the playground wouldn’t let me save my changes (it suggested the file was too big?), but the change was at line 33: newMeshes[1].scaling = new BABYLON.Vector3(1000, 1000, 1000);

was changed to:

for (var i = 1; i < newMeshes.length; i++){
newMeshes[i].scaling = new BABYLON.Vector3(1000, 1000, 1000);

You can see how the AO changes and when you zoom in will look like #13 instead of #14.

Thank you for your kind guidance and patience with my newbiness.

Note that the scaling of new BABYLON.Vector3(1000, 1000, 1000) on the node #0 in PG #14 is wrong, it should be new BABYLON.Vector3(1000, 1000, -1000) instead to retain the correct handedness (look at the values of this node with the inspector before the change).

Thank you :slight_smile: Everything works, the problem just wasn’t what I guessed it was :smiley: