I am looking for a shader that does the following:
- There are two color inputs and one grayscale texture input.
- Let’s say the two colors are red and blue. The black areas of the texture show up as red, the white areas show up as blue, and the shades of gray in between will be various degrees of magenta.
This seems like a basic enough shader, but my complete lack of experience with shaders has meant that I have no idea how to build it (or even the best search terms to find it, if someone else has). Can anyone give me any direction?
EDIT: After more searching, finding someone’s shader, and adding random lines of code hoping I knew what I was doing, I ended up with this:
Shader "Custom/VertexLitAlphaColoring" {
Properties {
_FirstColor ("First Color", Color) = (0, 0, 0, 1)
_SecondColor ("Second Color", Color) = (1, 1, 1, 1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 80
Pass {
Tags { "LightMode" = "Vertex" }
// Setup Basic
Material {
Diffuse (1,1,1,1)
Ambient (1,1,1,1)
}
Lighting On
// Lerp between AlphaColor and the basic vertex lighting color
SetTexture [_MainTex] {
constantColor [_SecondColor]
combine previous * constant
}
SetTexture [_MainTex] {
constantColor [_FirstColor]
//combine previous lerp(texture) constant DOUBLE, previous lerp(texture) constant
combine previous lerp(texture) constant DOUBLE
}
}
}
}
It works pretty well, so long as the texture is by an alpha channel. Anyone have a better one? I’d prefer having one that actually works with the black and white of the image, rather than the alpha.
EDIT #2: Never mind… while it does work in certain instances, it’s not the right solution. I’ll keep looking… but any help is appreciated.