Projector shadow showing through objects

I have a shadow projector that’s making some weird visual artifacts.

In this image, a row a wall segments is partially covered by a shadow projector. The projector is pointed straight down. The walls are about twice as thick as they look. The upper half is in the shadow, along with the rest of the top of the image.

Lines appear between each segment, when they’re nearly perpendicular to the camera, but these aren’t gaps between the meshes. The lines are being drawn by the projector. My best guess is that these are the faces of the cubes that are facing each other, with the shadowed parts being drawn on top of the walls’ front faces. I’m not sure why this is happening, or how to fix it. I tried tweaking various properties of the projector component and shaders, but nothing seemed to have any effect on it at all. How do I make these things disappear?

Edit:
Here’s a better view of the problem: http://i.snag.gy/4WdgM.jpg
On the left, the two cubes are selected so you can see how they’re positioned. The projector is casting a black shadow downward onto the ground, and on half of the back cube. On the right, the cubes are viewed from the front. The shadowed part of left face of the back cube is visible, despite it being clearly covered by the front cube.

Do you need the shadow on your wall to be real time? If not "bake" the wall instead, as long as the segments overlap the baking should work ok. I had no end of problems with projectors in the past and stopped using them. They double your poly count as the create a duplicate of the geometry they shine on then display the shadow on the transparent duplicate. Also they will give you one extra draw call per projector(min). So if you use a lot of these the draw calls will quickly stack up as will your poly and vert count :(

1 Answer

1

I’ve found a solution, though I’m not really sure why it works.
I switched to using a slightly modified version of the ProjectorAdditive shader seen here: http://wiki.unity3d.com/index.php?title=ProjectorAdditive
I set the shader to “Blend Zero OneMinusSrcColor”, and inverted my shadow image.