- Home /
Mask intersection between Line Renderer and Sprite (Shaders)
Hi there!
I'm having an issue I'm not quite sure how to resolve, so I decided to post it over here.
I'm working with Line Renderers and Sprites (using tk2d), each one of them having their own materials and colliders. What I need is to find the way to hide the parts of the Line Renderer that aren't in contact with the Sprite, meaning that the Sprite has to stay just like it is and the LineRenderer must show its material only on the segments that are colliding with the Sprite (the remaining parts must have their alpha set to 0).
In the following images you'll see what kind of materials they currently have:
Sprite Line Renderer
My case applied in images: The red cone is the sprite that is a trigger and the line renderer is the gray spline that is created between the two green dots: https://gyazo.com/e597518757a0d6801f7f8a1e17db1599
The collider of the sprite occupies the entire red area that I show in the following image. The clearest blue on the line renderer is the segment that MUST have the desired material visible, while the darkest blue is the part which should be transparent: https://gyazo.com/80a1980b88350df8438e3bbb8eb96821
Just like this: https://gyazo.com/5fe3032229bfed54d6b6b5fa84fdcb30
I haven't found many answers to a situation like mine. I think it's likely that the solution is going to be Shaders, but I have almost no knowledge on them. I'm guessing I must have two different shaders, one of them acting as a mask but... How do I apply this with Line Renderers?
Thanks a lot for your help in advance! I hope I've explained enough my case.
Your answer
Follow this Question
Related Questions
Sprite Masks not working in Build 0 Answers
How can I obscure a 3D object behind the AR marker with ARToolkit and Unity? 0 Answers
Help Turning Sprites into 3D Objects and Casting Shadows 1 Answer
Alpha masking multiple 2D Sprite GameObjects with 1 Sprite GameObject 0 Answers
Need some help with sprite-masking or similar solution 0 Answers