procedurally generated gradient


I’m procedurally generating buildings. Everything is fine except materials. I want to be able to create gradient by code between vertices.

Let’s take an example : I created a simple triangle with three Vertices (1, 2 and 3) :


I would like to be able to create a not-too-slow gardient by defining different mesh.colors and interpolate colors. For example if I set vertex1 and vertex3 color to red and vertex2 to green, I would like to generate smtg like this :


I understood you could do that by shaders, notably this one, but it doesn’t seem to work (everything is white). Basic I imagine, but I’m still quite lost :slight_smile:

Thanks in advance !

Vertex Colors is exactly what you want. As t why it doesn’t work, we’d need more details.

Actually I find some answer here :

I tried a particle shader instead of VertexColor on the wiki and it works. I don’t know exactly why though…

Unity Docs says “(Note that most builtin shaders don’t display vertex colors, you can use eg. a particle shader to see vertex colors)”