freezeActiveMeshes doesn't work with layermask

Hi,

When I apply freezeActiveMeshes, it makes meshes appear/disappear without respecting layer mask settings:

PG: https://playground.babylonjs.com/#1RI2YK#5
in the PG, sphere shouldn’t become visible when I apply freezeActiveMeshes
is this a feature or bug?
Thanks

There’s not a list of frozen meshes per camera, the list used when meshes are frozen is the list built with the last camera processed, so in your case camera2.

Having a list per camera would be quite a big architectural change I think, so I’m not sure it can be done… Maybe @sebavan will have more inputs about this.

Nope, thinking like you that it is quite a huge change here unfortunately. @Deltakosh can you think of any workarounds ?

1 Like

hm thinking like hitting the rock bottom :crying_cat_face: , is there something I can do in callback function? like after freezing could I make it visible for cameras?

           scene.freezeActiveMeshes(0, () => {
                    ground.layerMask = 1;
                    sphere.layerMask = 2;
            });

I don’t see a workaround, the freezed list of meshes is global and once it is computed it is reused “as is” for all subsequent rendering (until you unfreeze). The layerMask property is used when generating this list, but once a mesh is in the list (or not), layerMask property is not used anymore.

1 Like

@Evgeni_Popov @sebavan the only workaround I could think is by creating a second scene with same meshes, example: https://playground.babylonjs.com/#1RI2YK#8. but question in this case, will not it be more resource hungry than using viewport? could I share same meshes/lights between scenes?

hope @Deltakosh could think of something :bowing_man:

Yes, creating a new scene does consume more resources as you must copy the meshes/lights (they can’t be shared).