Dynamic Gradient Mask?

First off, I’m not super knowledgeable on materials in general, so forgive me if I use any language that’s not totally accurate.

So, I’m looking to make a material that uses multiple solid colors and masks said colors to be able to apply effects to each one, and one of the effects I would like is some sort of raising of the colored areas, with differently colored areas not connecting, instead having a decline back to the surface’s “normal” height before raising again for each color independently. Essentially, something like either of these (side view):

I’m currently using a plugin to drive the actual painting of the surface, and have achieved a (currently) passable effect using material layer blending to mask the painted colors from the “background” color using an alpha channel provided by the plugin’s special node to selectively blend the paint on top of the background, with ALL painted colors sharing the same “layer” in the material attributes, thus allowing the colors to all overwrite one another and preventing any one color from taking priority over another aside from new paint strokes covering old ones. Obviously, this makes all of the resulting vectors dynamic, preventing the usage of texture samples for most purposes.

Because of the way the plugin’s special nodes that allow the actual painting to work, displacement maps are impossible as they produce errors, preventing the material from properly rendering at all.

In order to achieve masks that are on a per-color basis, I’m currently using the maximum hardness for brush “strokes” from the plugin via blueprint node, as for potential gameplay and rendering reasons, opacity between multiple colors is undesirable. I am currently using a material function that I found somewhere else (currently can’t remember where it came from, but it was somewhere here on the answers site) that is able to mask out solid specific colors with a configurable tolerance, as seen here

But these resulting masks are binary, so creating any kind of raised effect with them as-is will result in strange behavior, and even if I wanted to / could use opacity, the masks resulting from paint effects using opacity could have unusual results (Such as blue and red creating purple, which may not successfully trigger either red or blue masks, depending on tolerance, which is troublesome as purple could for example need to be its own unique color). Currently, I am trying to find a way to “soften” these masks around the edges so that the edges between colors can hopefully be separated, something like the following:

So I’m here to ask if anyone is aware of that being possible dynamically in-engine? As the painting is dynamic, using texture sample based masks is not possible, unless there’s some method that I’m unaware of :frowning:

I’ve found a way around this for my purposes (at least as far as I can tell for now), so finding a way to do this isn’t super important to me anymore, but if anyone figures out a way to do this (Though I honestly doubt there is without substantial overhead or coding prowess, if it’s possible at all) I’d still love to know how.

Thanks for your time.