How do I invert the color of ui text to make it more readable, on a messy background?

I want to invert text color against a background, in order to make it more readable.

This is the effect I want (It’s a photoshop):
110599-screen-shot-2018-02-03-at-64314-pm.png
I’ve tried setting the text’s material to a material with an inverting shader, and it works, but it makes the text go blocky:
110600-screen-shot-2018-02-03-at-64232-pm.png

Any ideas on how I should do this?

-Thanks

You can create different inversion effects by playing with blend options and the output color (for example, only invert one or two of the channels). For more advanced background processing, you can use unity’s GrabPass and have the background accessible in a texture from your shader, but that’s far more expensive

Donwload the build in shaders then use the text shader as a base for your shader. You can find them in the unity download archive.

I found an answer here that seemed to work:

I think the best way is to convert the RGB color to HSV space (where the color is in the H value), and invert it, then convert it back:

public static Color Invert ( Color rgbColor )
{
    float h, s, v;
    Color.RGBToHSV(rgbColor, out h, out s, out v);
    return Color.HSVToRGB((h + 0.5f) % 1, s, v);
}

I’ve managed to do something similar. Using this setup:

image

"DateText" and "DateTextInverted" contain only Text components with inverted colors.
"DateIndicator" has Image and Mask components

Result:

image