Help with bitmasks / unique mask per game object

  • updated
  • Answered


I want to use one shape to mask another for a UI slider. The idea is there is one shape underneath that slides when you drag it, but it is masked by a static shape.

I really don't understand the masking system but I do have it working with the following settings just through trial and error:

Mask element:

Compare: Always

Pass: Replace

Ref: 1

Read Mask: 1

Write Mask: 1

Draggable element:

Compare: Less

Pass: Keep

Ref: 0

Read Mask: 255

Write Mask: 255

The problem is that any slider's mask will reveal the draggable element from adjacent sliders (see attached pic). The vertical slider is revealing the purple draggable element from the horizontal one. Is there a way that I can specify that only a the mask from within the same slider will reveal the draggable element?


Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Freya Holmér
  • Answered

this is more of a Unity stencil buffer question than a Shapes question, but, effectively you can do 8 separate masks with the stencil buffer, using the masks 1, 2, 4, 8, 16, 32, 64, and 128, as they all represent a bit in the stencil buffer's bitmask. since you're using 255 in your example, 255 has all bits set to 1, which means it will read/write to all of them