the simplest shader

would really appreciate if someone can direct me,

i am looking for a simple shader which will have:

  1. flat color
  2. alpha
  3. blending mode (need additive but would be great to have a drop down to choose the common ones)

nothing else, not lit, no textures…
i have used particles/additive till now but is giving me troubles with its alpha and its _TintColor…

thanks!

First, welcome to the forum!

“alpha” is not something to “have”. “alpha” is a color channel that you can read or write. What do you mean? If you have a flat color, and you’re using additive blending, there’s no point in multiplying by an alpha value, because you can just use a darker color to begin with.

Unity doesn’t provide a drop-down interface like you’re talking about. You need separate shaders for each blending mode you want to use.

Here’s a solution that gives you the flexibility you want, but probably at the expense of usability. Separate additive and alpha blending shaders would be easier to use, I think, but feel free to try it:

Shader "Premultiplied Color" {

Properties {
	_Color ("Color (A = background contribution)", Color) = (1,1,1,0)
}

Category {
	Tags {Queue = Transparent}
	Blend One SrcAlpha
	ZWrite Off

	SubShader {Pass{
		GLSLPROGRAM
		#ifdef VERTEX
		void main () {
			gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
		}
		#endif

		#ifdef FRAGMENT
		uniform lowp vec4 _Color;
		void main () {
			gl_FragColor = _Color;
		}
		#endif
		ENDGLSL
	}}

	SubShader {Pass{
		Color [_Color]
	}}
}

}