How to hide glow layer when in background

Hi there,
i’ve a scene in which i use some glow effect to higlight some meshes. The problem is that the glow is always visible even if it is hidden by a foreground mesh like in this PG: Babylon.js Playground

I tryed also using two cameras with mask, but in this case the masked mesh is always in foreground even if it is not supposed to be: (try to rotate the scene: the sphere is always in foreground).

Is there a way to hide the glow effect without using two cameras technique?
Thanks :wink:

EDIT: if i don’t use

gl.addIncludedOnlyMesh(box); gl.addExcludedMesh(sphere);

it seems to work.

But in this way i don’t know how to include/exclude multiple meshes. In my application i have many meshes that can be higlighted depending on user selection. It is for this reason that i use


You can select several meshes using your method in the last PG:

You can also try to use the highlight layer:

It was my first choice but i’had to abandone it becouse higlight layer requires more calculus and slow down my application. Glow layer is the best for performance issue.
I’ll try to focus on my last PG. Thank’S