How to mask the borders of a mesh inside a material ?

Hello,

I’m desperately trying to mask the borders of meshes, like would inlines do but inside a standard material (not post process as i plan to use it as an opacity mask).
Here is an exemple of what i’m looking for :

9xn44vf

First thing that came to mind was Fresnel and it works well on a simple sphere but absolutely not on more complex mesh as you can see :

Does anyone have an idea how to do it please ?

i reckon you could use the distance field functions and some screenspace math.

just spitballing.