How can I make something that is invisible, but blocks lights?

How would I go about creating an object of varying size, that is invisible to the player (hence, is not rendered), but blocks lights like spotlights and projectors and that sort of thing?

Basically, I want the same functionality as the Block Light tool texture in the Source engine.

In Unity 5, you can change your Mesh Renderer’s “Cast Shadows” setting to “Shadows Only”. The object will now display as a bounding box in the editor, invisible while playing, and will block light.

Maybe this is too simple to be the solution - couldn't you just use a not-closed object (something like a plane) with normals facing away from the player? That would cast shadows while being invisible.

Depends on what how you define 'blocks'.

if its sufficient to simply disable the lights blocked by the occulder, then that should be straightforward. Use simple primitives for the occulder, then extrude their silhouette from the view point of the camera to create a frustum or volume. Any lights in the frustrum are disabled for that frame. Obviously you'll have to keep track of which lights where turned off and need to be turned back on when they exit the frustrum.

However if you don't want to disable the lights, then its much more tricky. Problem being that with standard rendering models have no comprehension of whether lights are blocked and just treat every light in range as lighting it. This is far less noticeable these days as we have pretty good shadow algorithms that can hide this fact.

Projectors and the very old texture shadow mapping technique got around this by some clever method of mapping the S texture co-ordinate to a 1D texture of two pixels, one black, one white, depending upon whether the projection was in front or behind the projection point. Don't know if that might help here.

I guess if you we're happy to just have the lights 'shadowed' by an invisible object, that is possible. I don't think making the mesh non-render-able will work though since its needed in the shadow pass. Instead just edit whatever shader you want to use (i guess simple diffuse) and add 'ColorMask 0' line before the subshader, next to the blend mode. That wil prevent the object being rendered to screen, but will still render to depth buffer, which i'm guessing is what Unity uses for shadows. It works but you can get a ghostly image of the object due to the shadow.

There may be other ways, though everything that comes to mind is extremely convoluted. Can you give any more details in how its being used? Any restrictions or specific goals you need to achieve?