procedurally generated gradient

Hello,

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) :

[1526-capture+d’écran+2012-07-03+à+11.53.46.png|1526]

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 :

[1527-capture+d’écran+2012-07-03+à+12.03.02.png|1527]

I understood you could do that by shaders, notably this one http://unifycommunity.com/wiki/index.php?title=VertexColor, 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 : http://answers.unity3d.com/questions/51283/is-there-a-way-to-make-a-gradient-material-white-to-black-in-Unity3D.html

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)”

Thanks,