How to determine if a mesh is fully hidden behind other mesh?

Hi all,
I am trying to make this selection demo better but stuck on filtering out fully hidden meshes.
The existing solution is very slow due to raycasts.
is there any better solution to filter hidden meshes or selecting meshes in general?

PG: https://www.babylonjs-playground.com/#Q5KMXP#116

Thanks

1 Like

Thanks for the response.
Yes i tried occlusion queries but it’s didn’t work and made scene slower too.
Selection with occlusion: https://www.babylonjs-playground.com/#Q5KMXP#117 (not working)

octree.select also doesn’t filter the occluded meshes.

1 Like

Using occlusion queries in this scenario won’t work anyway (TIL!) From the docs:

Very important : The meshes you activate for occlusion requests must be rendered after their potential occluders! The easiest way to do this is to set their renderingGroupId property to a value greater than that of the occluding meshes (don’t forget to call scene.setRenderingAutoClearDepthStencil() with the appropriate parameters, as you probably won’t want to clear the depth buffer between rendering groups).

As far as other methods go, there may be a way via stencils or by GPU picking in the selected screen area.

Are you trying to filter out occluded objects for performance reasons?

I am developing a feature in an app where users can select machine parts and set texture/color to the group.

I ended up implementing color picking. Its faster than raycasts and pixel perfect so partially visible meshes can also selected.
Color picking: https://www.babylonjs-playground.com/#Q5KMXP#129

What i have if a tiny bug where in imported meshes, sometimes after drawing selection box for first time it does not select meshes but after that it works fine.
do you have any idea what might be causing this issue?
:beetle: https://www.babylonjs-playground.com/#Q5KMXP#130

I’ve recently added this one:

2 Likes

That’s great!
I’ll use it in my annotation viewer piece next.

1 Like

I bet your render target is not ready yet.

1 Like

You are right.
Shader compilation takes more than a frame thats why rtt was blank.
I fixed it by adding a flag to check if shader is compiled.

thanks @roland for the help!

1 Like