Culling Mask script help

I have a script attached to my camera which does some layer culling. I also would like to prevent the Default layer from being shown at various times, but I cannot make any sense of the documentation dealing with culling masks. I know how to “reset” the culling masks so that everything is displyed, but my attempts to hide the default layer have not been successful. Can anyone help?

if (_myTransform.position.y < -1)
        {
            Camera.main.cullingMask = 1 | 1 << 8;      //show all layers

            camera.layerCullSpherical = true;
            distances[0] = 5.5f;
        }
        else
        {
           Camera.main.cullingMask =  ?????            //hide default layer
            distances[0] = 0;
        }
        camera.layerCullDistances = distances;

byte operations…

Camera.main.cullingMask = ~1;

Note that’s a tilde (~), not a minus sign (-). Layers are stored as a 32-bit value where each bit represents a layer, so it’s worth knowing bitwise operators if you’re working with layers a lot. (Namely, “”, “|”, “^”, and “~”.) For example, this will toggle the default layer on and off:

Camera.main.cullingMask ^= 1;

In the case of using “= ~1” to remove the default layer, it’s ANDing the value with the inverse of 1, since with , anything that’s 1 is left alone, and anything that’s 0 is changed to 0. In other words, the process is this, using only the last 4 digits for brevity (as mentioned, there are actually 32),

  0001
~
  ----
  1110

And then:

  0111  //IgnoreRaycast, TransparentFX, and Default layers
 1110
  ----
  0110  //IgnoreRaycast and TransparentFX layers

–Eric

Thanks, Eric - that’s very helpful!