- Home /
How to crop or mask a sprite to a specific shape?
I'm trying to do a procedural terrain generation. I've managed to make the function to generate the points, and I've been testing/debugging by creating the terrain using a polygon collider on an object.
Now that it's done, I want to use this shape to crop a large sprite using the shape so that I obtain the shaped terrain. If I have a square terrain sprite, is there any way to crop the top or mask it to the shape of the polygon collider (or the shape of the function I'm using).
Answer by NivF · Jan 24, 2014 at 10:53 AM
Well, you haven't specifically specified by looking at that screenshot I assume you are talking about a 2D terrain.
If that's the case I believe the best way would be to manually create a 2D polygonal mesh that represents your terrain (very much like the image you have there). Then you can assign a texture to it and assign of UV coordinates.
With X/Y based naive UVs you should get your texture naturally cropped by the mesh edges.
I see. Yes, I meant 2D terrain, sorry! I don't have much experiences with $$anonymous$$eshes, I will have to check out how to do a sinus shaped mesh. If you have any info on that it would be very appreciated. :)
This seems like excatly what I've been looking for. Im trying to crop a sprite/texture by mesh edges. How excatly do you do this? I've tried searching and have come up with similar things, but not excatly this.
Your answer
Follow this Question
Related Questions
Crop/Mask a Sprite on runtime 0 Answers
Dynamic sprite mask 1 Answer
how do i mask a sprite against a canvas? 1 Answer
Why is my sprite not the original resolution? 2 Answers
How do I crop a sprite? 1 Answer