- Home /
Create color changer in strumpy shader editor
I am curious on how to make a shader that changes my font color from black to white and vice versa. I have played around with this a bit, and am unsure how to do this. I basically want to emulate this:
(The font changes from white, to black per pixel, as the progress bar overlaps it. This also seems to take into account the bar color, as if the bar is very light the text is black, and if it is dark, the text is white.)
I am curious how to do this. I wanted to compare the rgba values to all zero, or to all black, but i am unsure how to do this. I would guess you would use step, or any or the all nodes, but am unsure. How would i split the rgba values to their respective components? Similar to Vector2 split node.
I tried using the Assemble node and fed in 4 float values, and then wired the result to diffuse, but to no avail. It only stays white (assuming from wrong input type and defaulting to all zero).
And will strumpy shaders work for guiTexture fonts and for when they are overlapped and blocked, to be rendered still?
How would i accomplish this? I am unsure how to start on this....
Answer by Sanky · Feb 19, 2013 at 05:54 AM
following script will help you to blend your font texture or material
Shader "Myshaders/ChangeMaterial" {
Properties {
_Tint ("Main Color", Color) = (.9, .9, .9, 1.0)
_TexMat1 ("Base (RGB)", 2D) = "white" {}
_TexMat2 ("Base (RGB)", 2D) = "white" {}
_TexMat3 ("Base (RGB)", 2D) = "white" {}
_Blend ("Blend", Range(0.0,1.0)) = 0.0
}
Category {
ZWrite On
Alphatest Greater 0
Tags {Queue=Transparent}
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
SubShader {
Pass {
Material {
Diffuse [_Tint]
Ambient [_Tint]
}
Lighting On
SetTexture [_TexMat1] { combine texture }
SetTexture [_TexMat2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
SetTexture [_TexMat2] { combine previous +- primary, previous * primary }
}
}
FallBack " Diffuse", 1
}
}
Thanks for the script, but I am curious how this works. I like to have scripts made when I don't know how to implement something, but I want to learn cg. Can you explain this script to me?
Can you also post the strumpy graph of this and explain it? Also how do you do condionals in cg / strumpy?
Please explain this shader. I tried it and it doesnt work. I believe I have to get the color of the pixel befor rendering the font (i'll have the status bar behind my text so its rendered first).
Your answer
Follow this Question
Related Questions
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
Use cg shader to change text color based on previous color rendered 0 Answers
Material doesn't have a color property '_Color' 4 Answers
Font Color changing shader [color changes based on what background color is] 1 Answer