Inner shadow on procedural 2D surface

I have arbitrary 2D shapes that are created at runtime by slicing other shapes. They are often very close to eachother and need the “shading” inside the mesh.

I have spent hours on end finding out a way to write this shader. Been searching the web for people doing something close to this and found none.

I guess I need a shader that gets all the mesh triangle edges and find the border of the mesh by removing those lines with an opposite line. And then somehow shade pixels based on their proximity to this border. But this sounds very heavy to me and I don’t know if its even possible :S

Or maybe I’ll procedurally create a purely visual mesh in 3D to get the distinction between my meshes I want (in addition to an invisible simple 2D mesh for further cutting).

I’m open to any suggestions, thanks in advance!

*Note:

  • Very low poly shapes.
  • Camera is static, Orthographic, Side-view
  • Mobile (Android)
  • Meshes are created by user slicing meshes.*

EDIT: spelling

Have you considered using the “colors” channel in the mesh? RageSpline uses this technique to put outlines around its spline based shapes. Its very easy to write a shader that uses colors in the mesh. You probably need to create an extra row of vertices slightly inset from the edge. Then give the edge vertices a dark color and the inset vertices a light color and write your shader to use these vertices.