- Home /
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) :
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 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 :-)
Thanks in advance !
"I'm procedurally generating buildings" it seems like the whole world is doing that these days! Heh!
yes, I think the word "procedurally" and "generating" together in the same sentence are actually pretty fashionable.
But even if it looks serious and professional, I must confess my buildings are extremely basic procedures :-).
Answer by Piflik · Jul 03, 2012 at 12:59 PM
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 ins$$anonymous$$d 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,
Answer by nerial · Jul 03, 2012 at 03:41 PM
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,
Your answer
![](https://koobas.hobune.stream/wayback/20220613073626im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
is there a way to make a gradient material, white to black, in Unity3D? 2 Answers
How to avoid Texture.Apply() 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Shader Graph | How to create gradient from scratch 1 Answer
How to properly modify a multi-material object shader? 0 Answers