- Home /
Clip decal/texture onto (2d) mesh plane
Hello!
I'm trying to figure out how to put any number of textures or decals on top of my flat circle mesh for a 2d game.
The texture cannot go outside of the edges of the 2d mesh, so I need to find a way to cut or clip my texture correctly depending on where you place it on my 2d mesh.
Here's an illustration:
The circle is a flat disc 3d mesh used in my 2d game, and I need to be able to work with any number of decals/textures.
What should I be looking at to create something like this? Maybe some sort of projection or?
Thanks a lot in advance for any hints/pointers!
I've so far looked at the Unity3D bootcamp project that has a decal system but as far as I can tell it only clips against a Vector4 plane and not a complex 2d mesh.
"static public DecalPolygon ClipPolygonAgainstPlane (DecalPolygon polygon, Vector4 plane)"
But maybe the code in the bootcamp project will run this against every polygon on the mesh you put the decal on, I'm having trouble figuring out exactly what all the code does in the project.
If your circle mesh was a true sphere rather than a flat disc rendered to look flat then the Decal/projector method would definitely work. I'm unsure how to do this with the way you have it set up at the moment. :S
Yeah the solution I can think of is to use Projector with "ignoreLayers" where each object is its own layer.
Answer by Wisearn · Oct 30, 2014 at 02:41 PM
Projector with ignoreLayers and http://effectronica.com/?p=462 as shader (modified for the "straight alpha blending as written below the shader code in the article) solved my issue.
Thanks everyone who contributed!
Your answer
![](https://koobas.hobune.stream/wayback/20220613170052im_/https://answers.unity.com/themes/thub/images/avi.jpg)