# Mask and RenderingGroup don't work, rectangle and cube visible by two cameras not only one

**URL:** <https://forum.babylonjs.com/t/mask-and-renderinggroup-dont-work-rectangle-and-cube-visible-by-two-cameras-not-only-one/37484>\
**Category:** Questions\
**Created:** [January 18, 2023, 6:44am UTC](https://forum.babylonjs.com/t/mask-and-renderinggroup-dont-work-rectangle-and-cube-visible-by-two-cameras-not-only-one/37484 "2023-01-18T06:44:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joffrey\_Vedlem\_Ved](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joffrey_vedlem_ved/32/28882_2.png) [@Joffrey\_Vedlem\_Ved](https://forum.babylonjs.com/u/Joffrey_Vedlem_Ved)\
**Post date:** [January 18, 2023, 6:44am UTC](https://forum.babylonjs.com/t/mask-and-renderinggroup-dont-work-rectangle-and-cube-visible-by-two-cameras-not-only-one/37484/1 "2023-01-18T06:44:10Z")

</div>

line : 371 and 377. Thanks \<3 / PS : click on corner right for look code

https://codepen.io/joffrey-courty/embed/preview/zYLEyML?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=zYLEyML

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 18, 2023, 11:54am UTC](https://forum.babylonjs.com/t/mask-and-renderinggroup-dont-work-rectangle-and-cube-visible-by-two-cameras-not-only-one/37484/2 "2023-01-18T11:54:16Z")

</div>

RenderingGroupId is not for camera visibility, it’s used to change the _order_ of objects when they are rendered. As for the layerMask, to determine if a mesh is rendered by a camera, the operation done is a bitwise AND ( [Bitwise AND (&) - JavaScript | MDN (mozilla.org)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND)), `(mesh.layerMask & this.activeCamera.layerMask) !== 0`. Since your cube had layer mask of 3, which is 11 in binary, the bitwise AND with both cameras was returning 1:

- `11 & 01 = 01, 01 != 0`
- `11 & 11 = 11, 11 != 0`

As for the AdvancedDynamicTexture, the correct way of setting the layerMask there is `advancedTexture.layer.layerMask = 1;`.

EDIT: I think the docs can be clearer in what operation is being performed to determine visibility so I expanded upon it a bit [Update layerMask docs by carolhmj · Pull Request #753 · BabylonJS/Documentation (github.com)](https://github.com/BabylonJS/Documentation/pull/753)

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [January 18, 2023, 3:41pm UTC](https://forum.babylonjs.com/t/mask-and-renderinggroup-dont-work-rectangle-and-cube-visible-by-two-cameras-not-only-one/37484/3 "2023-01-18T15:41:55Z")

</div>

> [@carolhmj](#):
>
> I think the docs can be clearer in what operation is being performed to determine visibility so I expanded upon it a bit

This is always good for such a complex topic. Just remember that we also added with the help and expertise of @Evgeni_Popov

> **[In-Depth layerMask | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/scene/layermask)**
>
> Learn how the layerMask property work accross the library

May be a link or a bit of reorganizing the content? FYI only,

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 18, 2023, 3:42pm UTC](https://forum.babylonjs.com/t/mask-and-renderinggroup-dont-work-rectangle-and-cube-visible-by-two-cameras-not-only-one/37484/4 "2023-01-18T15:42:30Z")

</div>

Oh it’s a great idea to add at least as a link! Thanks mawa 😃

---

<div class="post-metadata">

**Author:** ![Joffrey\_Vedlem\_Ved](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joffrey_vedlem_ved/32/28882_2.png) [@Joffrey\_Vedlem\_Ved](https://forum.babylonjs.com/u/Joffrey_Vedlem_Ved)\
**Post date:** [January 19, 2023, 3:40am UTC](https://forum.babylonjs.com/t/mask-and-renderinggroup-dont-work-rectangle-and-cube-visible-by-two-cameras-not-only-one/37484/5 "2023-01-19T03:40:40Z")

</div>

oh some much answers thanks, i read this :DDD yo mawa my savior haha
