Light projector showing unexpected lines across scene

Hi!

I’m trying to show selection circles around objects.
For that i found light projectors with a shader and images for the patterns as a solution.

Now i’ve got that working, but i get straight cross-like lines showing up across the scene from the projector (both in editor & in-game), spanning much further then the image:

Those are not part of the image, which has a red circle and transparency otherwise.
From searching for previous discussions i checked different things, so mipmap generation is disabled on the image used.

The shader i’m testing with is this one here.

Any ideas on what would cause these lines?
Am i missing something trivial here?

I bet it’s the wrapping of the texture, in your case, clamping. Test quickly by setting the wrap mode to repeat, see if the line is replaced by the copy of the image.


The reason why this happens is because how clamp works. Any UV that’s outside the <0; 1> range is clamped to this range. The projector doesn’t simply black out the rest, it shows the edge color. So in order for this to work as intended, your texture needs to have black borders - all pixels on the edges of a texture should be completely black. This should hold true even when using texture compression that might alter the color of the pixel (either use border area of the size of ‘compression cell’, or don’t use compression), and when using mipmaps - luckily, unity can generate mipmaps with borders downsampled separately - just tick the “Border MipMaps” toggle in the mipmap generator settings.