Unlimited Vertex Color Mask?

Hey,

I’ve been going around and around on this problem, does anyone have any ideas?

I’m trying to use the vertex color painted on a mesh to generate masks. BUT I need more than the four/five channels which can be held in RGBA info. I’m not trying to blend more textures, but rather dissecting the mesh into more specific areas.
The vertex color is already being used for another related system so hijacking it would be useful.
I’ve tried an if statement comparing the color of the vertex paint against the pure color and turning that into a single 0 or 1 output (which would open a lot of possibilities). And it “kind of” works. I am getting the right output in the right vertex color, but it’s also rendering the wrong output as well and they fight to render on the mesh.

Anyone know why I might be getting this dual output on an if statement like this?

I am actually working in shader forge (because its usually faster for most things I need), but if I need to write the dumb thing I guess I’ll do that.

Thanks!

Did you ever have any luck with this one?

Well, sort of.
I made some progress with the whole “vertex color to color mask” thing by getting shader forge to do some math for me. Unfortunately every solution like this I got working would have little stripes where the vertex colors blended together that would be seen by the shader as other colors I was masking out. And I really wanted blended groups, not per-face groups, so ultimately I abandoned this approach.
I ended up just making a shader that would take two colors masks and painted them based on the vertex colors. It looks much cleaner than using the vertex colors, though I have to change the masks if I change the vert colors. :confused: I really wanted an elegant solution that pulled on existing information, but the vertex painting wasn’t really a good source of that information in the end.

1 Like

Thanks for the detailed reply!
I figured that might be the case. Do you mean you created a shader setup that allowed you to vertex paint the different colors in Unity?

That sounds like the route I will have to go down then, thanks for the advice and if you have any more tips that’d be amazing!

Oh no, we had some vertex information that was painted in Unity using a third part application (PolyBrush, I think) and I wanted to utilize this info to drive some info in the shader. The vertex colors were being used to give information to a raycast and they worked for that, but separating them out as distinct colors in the shader was more difficult.
I just painted RGB masks in Photoshop based on the UVs ('cause I’m a 3D artist so thats accessible to me, haha), and based on where I knew the different vertex color groups were. I basically took screenshots of the vertex colors and painted the RGB masks accordingly. its a little rough, but close enough for what I needed, and it looked best.
Yeah, best of luck! I’m sure there’s a solution that could actually use the vertex colors to do this kind of thing, but its beyond my abilities at this moment.

1 Like

Thanks again! Great info, something I can work with for sure and you’ve been a massive help.