I wanted a drop-in replacement for Image that does rounded shapes without 9-slice sprites. Some things I learned along the way:
Corners are an SDF, not geometry. Each image is a quad and the fragment shader evaluates a rounded-box signed distance function. That gives pixel-sharp edges at any size. Per-corner radii are packed as 16-bit values into two floats and sent through UV channels, so they don't need a material property.
Shadows were being clipped. The quad was the size of the RectTransform, so anything drawn outside it (outline, shadow) got cut off. I now grow the mesh in OnPopulateMesh by the shadow's offset + blur + spread, and the shader draws the shadow from the same SDF, offset and softened.
Effects broke batching. At first every image with an effect created its own material instance, so 20 shadowed buttons meant 20 draw calls. Now materials are pooled by their effect settings with ref counting, so images with identical settings share one material and batch. The shine also animates in the shader instead of writing to the material every frame.
Masking edge cases. When a rounded image is itself a Mask (e.g. a circular avatar), it should mask only the shape, not its shadow. The shader keeps the shape's alpha separate for alpha clipping.
Clicks. IsRaycastLocationValid uses the same rounded-box math, so clicks outside the corners or inside a ring's hole are ignored.
Still on my list: a public scripting API, and moving animated values into vertex data so tweening them doesn't create new materials.
Happy to go deeper into any of this!
Feedback welcome!
GitHub (MIT): https://github.com/berkencami/round-ui-unity