Camera rendering with multi layerMask

Is camera possible to render target more than one layerMask ?

Yes and No. The point of having a layerMask is precisely to isolate/re-order the rendering from the rendering done by a camera. Basically, everything that has NO layerMask value will be rendered by the camera that also has no layerMask value (or in other words, everything where the AND result == 0 from the camera layerMask will be visible from this camera).

But then, if that was your question, you cannot set multiple layerMasks to a render target (not as far as I know). In a way, when you think of it, it wouldn’t make sense since it is: “a layer”. I suppose you could still create an instance or a clone of the mesh and assign it a different layerMask and clone the camera to assign this same layerMask. Not sure of the use case for this though.

Edit: If you need a debug, best would be to deliver a PG along with your requirements.

1 Like

The layerMask being a bit mask, you could potentially set your camera layer mask to 3 meaning it would render every objects having 1 or 2 in their layer mask values.

1 Like

It seems not work. I had test something,

mesh.layerMask = 0x0FFFFFFF, ui.layerMask = 0x20000000, camera.layerMask = 0x40000000

then camera renders nothing

Try setting mesh layer mask to 0x1, the ui mask to 0x4, and the camera mask to 0x3 and see if that works.

That’s essentially what @sebavan was saying. Your current setup won’t render anything because none of the masks yield TRUE when they are AND’ed together

0x3 AND 0x1 = TRUE
0x3 AND 0x2 = TRUE
0x4 AND 0x3 = FALSE



Looks my explanations still aren’t as clear as yours.:wink: Working on it :student:

The keyword is “bit mask”, and i got it at last :smiley: