My game has units that require simultaneous outlining in different colors. Here’s an example of what I have so far for it:
I am currently doing this via the standard method of sampling nearby pixels and looking for the existence of a >0 stencil value with custom depth. I map stencil values to color, and that was the result. What I would like to do now is to have the outline have a gradient going outwards, here is an example of the desired effect:
As seen here, the colorization of the outline isn’t completely opaque. My initial thoughts on how to accomplish this was to colorize the entire unit, blur it, then cut out the stencil areas, but this requires the very expensive use of a render target the size of the viewport, and the exact implementation of this proved to be somewhat difficult in practice (the Scene Capture 2D was returning different results than my camera when writing to a RT, even with identical positioning and FoV settings).
So my question is a general one of what is the optimal way to accomplish this effect?