Trying to figure out how to do my own 9-slicing

I’ve found that Unreal’s basic 9-slicing tool for images and UI materials seem pretty bad, or I’m just not understanding how it works.
I want to make my own 9-slicer because i feel hampered by the tools that are out there already, but for the life of me i can’t seem to find any good information on how to do it.

So the question is, how can I separate an image or material into it’s segments based on inputted margins? Is there a resource somewhere I’ve not found yet that can help me discover what I desire?

I’ve already found the ultimate SDF resource in Indigo Quilez (Inigo Quilez :: computer graphics, mathematics, shaders, fractals, demoscene and more), and i want to combine the awesomeness of his work with a well crafted 9-slicer.

Which specific aspect of the built-in solution is not working for you? Any examples?

Things to note:

  • margins are percentages
  • in Border mode use the smallest image dimensions you’ll ever need and only scale up
  • not all images can be 9-sliced
  • when working with materials, don’t forget to set Image Size (256x256) below - it will affect how the material behaves

The margin of .1 is enough in this example, as 10% of the edge is just enough to exclude from scaling.

It will always break at very small sizes as there’s not enough pixels to work with.