Jump to content

[SOLVED] Viewport mask issue and suggestion


photo

Recommended Posts

Hello,

I'm trying to setup some viewport masks so an object/surface ("Windshield") can NOT be seen by a camera ("PilotEye"). In order to do that, I chose to reserve a bit of viewport mask to this camera, let's say the setup is:

  • PilotEye, with viewport mask = 0x02 (only bit 1 set)
  • Windshield surface, with viewport mask = 0xFFFFFD (all bit set, except bit 1)
  • All other surfaces, with viewport mask = 0xFFFFFF (all bit set, the default value)

I would have expected the PilotEye camera to view everything, except the windshield. But the camera actually renders pitch black! Nothing visible, even the sky. What did I miss?

I noticed I have to always set the bit 0 in the mask for the camera to view something, so this works, but I don't understand why:

  • PilotEye, with viewport mask = 0x03 (only bit 0 and 1 set)
  • Windshield surface, with viewport mask = 0xFFFFFC (all bit set, except bit 0 and 1)

Independently from this, I would have a suggestion:  it could be useful to have a Viewport/Shadow mask at the node level (in addition to the surface level), so a whole node/hierarchy could be masked instead of going through dozens of surfaces.

 

Thank you

Link to comment

Hi Stephane,

Looks like you've misunderstood the concept a bit. Let me explain how the whole thing works.

Each bit of the Viewport mask can be thought of as a "channel":

  • For a camera it is a channel to receive visual representation of a surface (see surfaces "sending" visual data via this channel - i.e. having the corresponding bit set)
  • For a surface it is a channel to send its visual representation to cameras (be seen by cameras "receiving" visual data via this channel - i.e. having the corresponding bit set)

By default we assume that everyone sees everything, so there's no need for multiple channels. Therefore, all surfaces have only the first bit set by default.

Each camera is an all-seeing eye by default, so it should have all its channels open. Therefore, cameras have all bits set by default.

Please note, that the Viewport mask of the material assigned to the surface should also match the camera's mask, otherwise the surface won't be seen (even if the surfaces and camera have matching masks). Material's Viewport mask works the same way as surfaces, but they have all bits set by default.(to be seen by everyone).

Lets consider your setup:

Quote
  • PilotEye, with viewport mask = 0x02 (only bit 1 set)
  • Windshield surface, with viewport mask = 0xFFFFFD (all bit set, except bit 1)
  • All other surfaces, with viewport mask = 0xFFFFFF (all bit set, the default value)
  • The PilotEye camera sees only the "channel" 1.
  • The Windshield surface is seen via all "channels", except 1.
  • The default value for all other surfaces is 0x01, not 0xFFFFFF, so they're seen via the "channel" 0 only (but the PilotEye sees only channel 1).

So, in your case the proper setting would be like this:

  • PilotEye, with Viewport mask = 0xFFFFFD (all bit set, except bit 1)
  • Windshield surface, with Viewport mask = 0x02 (only bit 1 set)
  • All other surfaces, with Viewport mask = 0x01 (only bit 0 set, the default value)

Now about this:

Quote

I noticed I have to always set the bit 0 in the mask for the camera to view something, so this works, but I don't understand why:

Light sources also have the Viewport mask, and like for surfaces, only the first bit is set by default (bit 0, I mean), so when you unset this bit for your PilotEye camera, the scene is rendered totally without lights - a "pitch black", exactly as you said. Try setting the corresponding bit for the light source and you'll see it.

You can check out our Bit Masking video tutorial, it might be helpful.

Thank you for your suggestion, we'll think about it!

Hope this helps!

  • Like 1
Link to comment
  • morbid changed the title to [SOLVED] Viewport mask issue and suggestion
×
×
  • Create New...