Vertex color blend shader issue

Hey all,

So I was hoping someone could shed some light on a rather odd issue I’m encountering with vertex color blending in Unity. I’m working in Unity 4.6.9 (The team I’m working with isn’t on 5 yet), and I’m trying to create a simple vertex color texture blend shader with three textures for R, G, and B. I made one in Shader Forge and it works just fine, except that the actual texture blending between vertices isn’t working correctly.

For instance, if I try to blend between two vertices, one of which is 100% green and one of which is 100% blue, both textures will look correct in the spots where the vertices are, but in the area between them where the two textures should be blending smoothly together, my base texture (in the red channel) will show through slightly.

It might make more sense if I show you- in the following screenshot I have a dark rock texture in the red channel, and the same grass texture in both the green and blue channels. In the areas between the green and blue vertices, you can see the dark texture showing through in Unity. I made sure all the verts were either 100% green or blue with no opacity or other color blended in, so I don’t know why this would be happening.

I don’t think it’s a problem with my shader as it’s just a very basic vertex blend shader, but if you want to see it here’s a screenshot of it in Shader Forge-

Does anybody know what could cause this to happen? I’ve been pulling my hair out over it for a while and I’m about ready to give up. Thanks in advance for any info or ideas you guys might have.

Try multiplying each texture with the equivalent vertex color channel and then adding all 3 together.

1 Like

Wow, that did it, thanks so much! That didn’t even occur to me, I guess I gotta learn to stop relying on lerp so much. Still not quite sure why doing it that way didn’t work, but the important thing is that it’s working now, thanks again!

Because the first lerp you do with the green channel assumes everything else is the red channel → also the two small areas in the middle. So you get a bit of the red texture map in there. A small percentage comes through when you do the other lerp.

1 Like