x


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?

more ▼

asked Feb 05 '11 at 11:34 PM

JoeStrout gravatar image

JoeStrout
177 8 8 16

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Mesh.colors contains vertex colors for a mesh.

more ▼

answered Feb 06 '11 at 12:14 AM

Eric5h5 gravatar image

Eric5h5
80.2k 41 132 519

Doh! I don't know how I missed that, but it is just what I needed. Thanks!

Feb 06 '11 at 01:36 AM JoeStrout
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x33
x18
x16
x13
x1

asked: Feb 05 '11 at 11:34 PM

Seen: 1232 times

Last Updated: Feb 05 '11 at 11:34 PM