Why is color multiplied with 2 in "Particles/Alpha Blended" shader?

This is how the fragment shader looks in the default Unity shader “Particles/Alpha Blended”(file name “Particle Alpha Blended.shader” in downloadable default shader zip):

Blend SrcAlpha OneMinusSrcAlpha

fixed4 frag (v2f i) : COLOR
{
	#ifdef SOFTPARTICLES_ON
	float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
	float partZ = i.projPos.z;
	float fade = saturate (_InvFade * (sceneZ-partZ));
	i.color.a *= fade;
	#endif
	
	return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
}

Why is final color multiplied with 2?

Colors are always multiplied by 2 in all the shaders. I asked this question myself a while ago and pretty much got the answer - that's what you do! However, somewhere, and I can't find where, I read an explanation a month or so ago. Wish I could fully remember what it was. Anyhoo - multiply * 2 to look like any normal Unity shader

I can't really find any other default Unity shader which multiplies with 2? An example? I you somehow remember where you read that explanation, please share it.

Really- well they all do it internally if it's not a vertex/fragment program. I pretty much don't use the default shaders any more - so all mine * 2.

Here's my forum question: http://forum.unity3d.com/threads/155099-Vertex-lit-shader-lighting-is-too-dark Here's my answers question: http://answers.unity3d.com/questions/333699/shader-lighting-is-too-dark.html

No idea on that reference I'm afraid.

1 Answer

1

Here’s the answer by Aras on why everything is multiplied with 2:

Short answer to “why multiply by two?” - because in the EarlyDays, it was a cheap way to “fake” somewhat overbright light in fixed function shaders. And then it stuck, and it kind of dragged along.

The link in the second post by Jessy in that topic is broken, here’s a working one
http://www.quaddicted.com/engines/software_vs_glquake#overbright_lighting

I can't find a non-Particles built-in Alpha-Blend shader, will it be strange if using this shader for non-particle objects?

I guess most of the other shaders with lighting already have the *2 killed.