Draw a line on a surface


I would like to be able to do something like in the picture below. Basically some kind of a"laser" on a wall which in the best case is parented to the object in front so it moves on the surface when the object is moved but is only visible on the surface/wall.

If it is easier if the object that projects the lasers is static that would be great as well :slight_smile:

What would be the best way to implement something like this?

Thanks in advance :slight_smile:

might a transparent texture with a layer mask?which is right befor the surface? or have a look at stencil shaders!

Well, the easiest solution is to use a Projector. Though keep in mind that the projector actually redraws all objects that intersect itโ€™s projection volume / frustum. So having more than one can get quite expensive if the scene contains more or less complex objects. This is often a killer for mobile apps since the drawcalls / SetPass count goes up.

Though in your case if you just want to project it against a wall there really isnโ€™t any issue

First of all thanks for the answers but I found a solution which probably works best in my case. It might be a very heavy solution but it seems to work nicely.

I added a few spotlights to get a big enough area covered and then added a custom โ€œCookieโ€ texture to the spotlights to mask out everything but a thin line in the center. It seems to run perfectly fine so far which is why I will keep it like that for now.

thanks again :slight_smile: