Material CapsuleMask (Instead of SphereMask)?

Is it possible to create custom masks other than the standard SphereMask?

For reference, you can easily create a sphere on a surface with a material like this:

But what I want is something more complex, something like a capsule instead of a sphere.

More specifically, I want a material with two different ‘Location’ and two different ‘Radius’ parameters that creates a SphereMask at each location with each corresponding radius and finally, and most importantly, masks everything in between the two spheres. And I want it to have a hardness of 0, creating a soft edge.

How do I accomplish such a feat?

A good starting point would be the DrawLine-3D material function. It draws a line with a certain thickness between two locations, creating a capsule, and, when cleaned up a bit, looks like this:

There are however two things that needs changing:

  1. Currently, only one Radius parameter is used for both locations. Each location should use its own Radius, allowing one end of the line to be thicker than the other.
  2. The Hardness parameter is currently dependent on the Radius, meaning that modifying the Hardness also modifies the resulting Radius. I want it to behave like the Hardness parameter of the SphereMask, where a Hardness of 1.0 (or above) means sharp edge and a Hardness of 0.0 (or below) means fully opaque at the line and fully transparent at the edge of the radius, scaling linearly in between.