Need help with baked vertex shader

Alrighty, so what I am trying to do is (using a modified version of the BakedVertexLit shader) add an additive part to the shader, since the shader multiplies the vertex color by the texture on the mesh, it darkens the mesh where the vertices get darker, but if the vertex color is pure white, color defaults to the texture brightness. This isn’t exactly what I want, because the result will be something Darker then what it should be.

Well, its partly what I want, but what I would like to do is take the multiplied result, but ADD the brightness of the vertex colors back on top of this, so the colors get blown out past their original values to closer to white. I have something kinda working now:

Shader "/Baked Vertex Lighting"{
	Properties{
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB)", 2D) = "white" {}
	}
	SubShader{
		Pass{
			Material{
				Diffuse [_Color]
			}
			Lighting Off
			SetTexture [_MainTex]{
				constantColor [_Color]
				Combine texture * primary DOUBLE, texture * constant
			}
		}

		Pass{
			Blend One One
			Lighting Off

			BindChannels{
				Bind "Vertex", vertex
				Bind "TexCoord", texcoord
				Bind "Color", color
			}

			SetTexture [_MainTex]{
				Combine primary * texture
			}

			SetTexture [_MainTex]{
				constantColor [_Color]
				Combine previous * constant
					Combine previous + primary
			}
		}
	}
}

The " Combine previous + primary" is what I want and is responsible for making the texture brighter, but if you use this shader you will notice that it blows the values out too much. LONG WINDED question, how would I go about using a fraction of the value of the vertex colors, and adding that instead of the full value? Like if you could take all the values of the vertex colors, multiply them by 0.2 and then use that to add on top.

Is this possible with ShaderLab or would I have to dive into Cg?

You’ve got Double in the first pass. Try Quad. If that’s really not enough, I think you probably just need to repaint your vertex colors, or set Main Color to something brighter. Your first pass is written in an overly complex way, also. The default is Lighting Off and the Material block isn’t useful without Lighting On.

SubShader {Pass {
	BindChannels {
		Bind "vertex", vertex
		Bind "color", color
		Bind "texcoord", texcoord
	}
	SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]}
	SetTexture[_] {Combine previous * primary Quad}
}}

Lol, no I think you misunderstand me, I don’t want it brighter, I want to take a fraction of the amount of the vertex colors and add that instead of the full value. So if I could multiply 0.2 by the vertex color then add that.

I understand what you said you wanted to do, but I don’t see why you’d want to, considering you you just described wanting overbrightening. If you’re just talking about getting black values closer to white, then why not add in the vertex alpha? But let us know why setting 25% grey all over, and coloring from there, isn’t good enough.

Well, from what I have seen, using DOUBLE, or QUAD makes it way too bright. I just want to take a fraction of the vertex color and add it back on top to make the bright areas pop a bit. Reason I would like to use the vertex color is because the darker the vertex color, the less it will effect the final output. Cranking the brightness up uniformly will brighten up and wash out the dark areas, which is not what I would like to do. I just want to make the bright areas, slightly brighter.

Bake or paint better. Or use “Main Color” to account for it. If you set Main Color at 25% grey, no overbrightening can occur even with Quad. Better to not rely on Main Color, and take it out of the shader, if you don’t need it to change, though.

Thanks, but that doesn’t answer my question. Trust me, it’s not a matter of repainting the vertex colors. Here hopefully this will illustrate it better:

If it’s not possible to do in shader lab, I’m ok with that. Just curious if it were possible to take a fraction of the value of the vertex colors and add it back on top.

It’s possible. Display why double or quad aren’t good enough and I’ll write you a shader.

Hmmm, I’ve been messing around with DOUBLE and kinda got something close, so I’ll just roll with it. Thanks again for the help and code optimization Jessy.