Can an occluder mesh be an occulted mesh?

In the documentation it is specified that the meshes which occluders must be created before the meshes which will potentially be obscured.

But let’s imagine a large city with several buildings facing each other.
Building 1 obscures building 2. But building 2 could also obscure building 1 depending on where the camera is located.
If the camera is behind building 1, building 2 is obscured. But if the camera is behind building 2, can it hide building 1?

Is it possible for all objects to check occlusion queries for it to be occluders and potentially occluded?

I’m wondering if we can add occlusion queries to all city meshes ? I have a doubt. How else could this be done? I have the impression that occlusion queries are made for that.

I don’t think this is the case. Can you point me to the doc about it? We may have worded it badly :wink:

You should be able to create them in any order and yes occluded objects can also be occluders because we look at that from the pixel shader standpoint so at the very end!

Hi Deltakosh,

It’s in the occlusions query doc :

In introduction :

**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 renderingGroupIdproperty to a value greater than that of the occluding meshes (don't forget to callscene.setRenderingAutoClearDepthStencil() with the appropriate parameters, as you probably won't want to clear the depth buffer between rendering groups).

Maybe I misunderstood or misinterpreted what is written since I use a translator.
If it’s like what you say, then it’s great if it can work like that.

Ok now get it:)
You can still create them the way you want and simply turn in back to front rendering (that will force Babylon to sort the meshes so they are rendered in an occluded compatible way):
scene.setRenderingOrder(BABYLON.RenderingGroup.backToFrontSortCompare, 0);


OK, thanks a lot.

Is the setRendererOrder function to be used after rendering the scene or before?

before :slight_smile:

1 Like