I’ve been looking for a shader in unity that does both additive with an alpha channel. But seems like there isn’t much talk about the alpha channel part. I found a simple additive shader online, but has no alpha channel.
I’m not much of coder, but can someone shine a light on this simple shader. Your help is greatly appreciated.
Thanks in advanced.
Kue,
Shader "My Shaders/ColorAdditiveShader" {
Properties {
_Color ("Main Color, Alpha", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
Category {
ZWrite Off
Lighting Off
Tags {Queue=Transparent}
Blend One One
Color [_Color]
SubShader {
Pass {
Cull Back
}
}
}
}
This is easy to do. But before I tell you how to do it, please tell me why you’d want to. Why can’t you just premultiply the RGB by the A? Are you using the RGB elsewhere, without muliplication?
You could also invert the alpha channel, and use Blend One SrcAlpha. The results will be identical if you’re not using compression. However, I recommend the shader above, if you do use compression, because the textures should compress better when you have black RGB matching with black A, instead of white A.
I’ve tried using the code you provided but, i’m not getting the result i needed.
Here is another illustration of the additive plus alpha. The texts on the buttons in the first illustration is not part of the button.
the effects on the button is what i wanted.
Hopefully the second illustration can help explain.
Again thanks for looking into this, Jessy.
Like I said in my first response, there’s no point in using an alpha channel. The only reason you’d need that is if the text were part of the rest of the graphic, which you probably should do. Just multiply the alpha you have currently, by the RGB you have currently, and then just use the RGB with an additive shader. Or, because your shape is so simple, just model that - it will take only 6 triangles, require no texture at all, given the uniform color*, and it will be resolution-independent.
I think that’s what I’m seeing. I see a brighter outline in the last shot, but I don’t know if that’s intended or not. If it is, that would be 22 triangles, and you could use vertex colors.