How to make the raycast ignore an object?

When the object is hidden, the Scene.raycast ignores it. But for what I intend to do, the object needs to be visible in some way.