# Occlusion effect is affected by mesh creation/load order - is this intentional?

**URL:** <https://forum.babylonjs.com/t/occlusion-effect-is-affected-by-mesh-creation-load-order-is-this-intentional/53110>\
**Category:** Questions\
**Tags:** material, occlusion, depth\
**Created:** [August 30, 2024, 11:27am UTC](https://forum.babylonjs.com/t/occlusion-effect-is-affected-by-mesh-creation-load-order-is-this-intentional/53110 "2024-08-30T11:27:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rasmus\_Rune\_Andersen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/rasmus_rune_andersen/32/40371_2.png) [@Rasmus\_Rune\_Andersen](https://forum.babylonjs.com/u/Rasmus_Rune_Andersen)\
**Post date:** [August 30, 2024, 11:27am UTC](https://forum.babylonjs.com/t/occlusion-effect-is-affected-by-mesh-creation-load-order-is-this-intentional/53110/1 "2024-08-30T11:27:13Z")

</div>

When using the `occlusionMaterial` or the `engine.setColorWrite(false)` for a mesh, the occlusion only has effect on meshes loaded or created AFTER the occluder mesh itself. Is this the expected behavior?

> **[Babylon.js Playground](https://playground.babylonjs.com/#8N1WJQ%2339)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

I would expect the occlusion to have effect on other meshes based only their relative depth and not on creation order. Am I missing something I should do after creating the meshes? Should I update some buffer or something. Or is it simply a bug?

---

<div class="post-metadata">

**Author:** ![alexchuber](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alexchuber/32/52000_2.png) [@alexchuber](https://forum.babylonjs.com/u/alexchuber)\
**Post date:** [August 30, 2024, 6:20pm UTC](https://forum.babylonjs.com/t/occlusion-effect-is-affected-by-mesh-creation-load-order-is-this-intentional/53110/2 "2024-08-30T18:20:53Z")

</div>

I do know that documentation for some of our other occlusion features warn that your occluders must be rendered first, followed by your occludees (e.g., [Occlusion Queries | Babylon.js Documentation (babylonjs.com)](https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries))  
I assume the same applies for OcclusionMaterial, where the user is responsible for maintaining a [rendering order](https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/transparent_rendering) that follows that principle. cc @sebavan Is this true?

---

<div class="post-metadata">

**Author:** ![Rasmus\_Rune\_Andersen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/rasmus_rune_andersen/32/40371_2.png) [@Rasmus\_Rune\_Andersen](https://forum.babylonjs.com/u/Rasmus_Rune_Andersen)\
**Post date:** [September 2, 2024, 8:06am UTC](https://forum.babylonjs.com/t/occlusion-effect-is-affected-by-mesh-creation-load-order-is-this-intentional/53110/3 "2024-09-02T08:06:34Z")

</div>

Ah yes, I did not read the docs for the Occlusion Queries. So it does indeed work like this by design. Thank you very much. This solves the issue.
