- Home /
How to control light/color on a combined mesh?
I have a whole bunch of little quads that I need to render, with shading that I want to control myself. I previously did this by calling DrawMesh on each one, using a MaterialPropertyBlock to change the main color according to my custom lighting. (This is all using the VertexLit shader, if that matters.)
So that worked fine, but I found that as the number of quads went up, the frame rate dropped precipitously. So I now combine them, using CombineMeshes, into one big mesh that draws super-fast.
But now I've lost my control over lighting. I suspect that there is a solution here involving shaders, but being still a newbie, I don't really understand shaders. For example, I really like the look of this shader:
http://www.unifycommunity.com/wiki/index.php?title=VertexColorUnlit
...and it talks about "vertex color values," which sound quite promising. But how in the world do you define vertex color values? If I knew the answer to that, I could probably define the right color for the four vertices in each quad as I build up the one big mesh.
Or maybe there's a simpler solution I'm overlooking?
Answer by Eric5h5 · Feb 06, 2011 at 12:14 AM
Mesh.colors contains vertex colors for a mesh.
Doh! I don't know how I missed that, but it is just what I needed. Thanks!
Your answer
Follow this Question
Related Questions
Need Help with Dynamically Building a Mesh 0 Answers
Changing alpha on specific vertexes? 1 Answer
Light Colors Vertex Lighting 0 Answers
Vertex color by face 1 Answer