Usage of Layer masks, what am I doing wrong?

I’m looking into using layer masks to make my raycasts ignore certain layers. I’ve named Layer 8 (the first one open to editing) “Ground” and set my ground object to this layer, and then tried to use the following code (the idea is to only make the ray hit register if it hits the ground object):

        Ray ray = Camera.main.ScreenPointToRay(origin);
        RaycastHit hit;
        //set layermask to test for "Ground" layer (layer 8)
        int groundLayer = 8;
        int layerMask = 1 << groundLayer;
        if (Physics.Raycast(ray, out hit, layerMask))
            return hit.point;

It operates just like a normal raycast and hits everything not in the “ignore raycast” layer. What am I doing wrong?

I tried looking into it and found links like these:

But I don’t really get what I’m doing wrong.

You are passing the layerMask in the distance parameter not the layer mask one.