2D Sprite round corners

Hi all,

I am trying to create a tiled sprite with round corners with a dynamic width. See image attached.23508-island.png

The challenge here is the fact that the tiling goes on until the corner itself. Here’s the thoughts I have so far:

1 - Mask shader http://wiki.unity3d.com/index.php/TextureMask . But this doesn’t work because I want to stretch my image. Somehow I’d like to 9-slice the shader… If that were possible.

2 - Round-corner shader. I’m no shader expert but I guess I could draw/not draw pixels based on the y-coordinate, using a sine-function to make it round. That’s what I’ll try to figure out now.

3 - Create separate sprites&materials for the corners, making them masked and automatically updating the sides based on the width of the centre sprite (anchoring). I could update the material offset based on the width of the sprite, so it would connect to the middle piece smoothly.


The best method I could think of for this would need to be a GUITexture with the top and side borders (at least) set to the radius of the curve.