- Home /
Use cg shader to change text color based on previous color rendered
I want to make text that sits on top of a progress bar, and would like the font color to change to make it easily readable as the progress bar fills.
I want the text to invert color from black or white, depending on if the background color is light o dark (respectively). How can this be accomplished?
My current shader is based off the the example diffuse shader. I want to make the inversion using hardware, and not based on grabpass for mobile performance reasons.
Shader "FontEffects/BlendInvertWhite" {
Properties {
_MainTex ( "Texture to Blend" , 2D ) = "White" {}
}
SubShader {
Tags {}
Pass {
Blend OneMinusDstColor Zero
SetTexture [ _MainTex ] { combine texture }
}
}
}
Your answer
Follow this Question
Related Questions
Create color changer in strumpy shader editor 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Font Color changing shader [color changes based on what background color is] 1 Answer
Invert Color Shader (without see-through) 0 Answers
How do I invert the color of ui text to make it more readable, on a messy background? 4 Answers