Search Unity

What shader to use for mesh vertex colors?

Discussion in 'Shaders' started by cblarsen, May 8, 2007.

  1. cblarsen

    cblarsen

    Joined:
    Mar 10, 2007
    Posts:
    266
    I am trying to figure out if I am doing something wrong, or if my graphics card is just too old.

    I have created a mesh and assigned a bunch of colors to the vertices using mesh.Colors

    I have tried both the diffuse and the vertexlit shaders (and in fact all the others too) but the only color that shows up on the rendered object is the "Main Color" from the material, not the colors from the vertices.

    I am not sure that my graphics card has ever heard of shader languages (Geforce4 MX), but what I am trying to do is very simple. The equivalent, when I was writing OpenGL 1.1 code would be something like a call to glColor() before every call to glVertex()
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    The builtin shaders in Unity don't take vertex colors into account, so you need to use custom shaders in that case.

    A couple of vertex color shaders are on Unify wiki, for example this one

    The reason why vertex colors are not supported by default is called "shader combination explosion". In fixed function OpenGL, you can enable and disable specific pieces of functionality, and everything is handled for you. When you start using real shaders, nothing is handled for you, so you need to write separate shaders for any combinations you want to use. Thus supporting vertex colors would make us create 2x more shaders. Which we might do at some point, but haven't done yet.
     
  3. cblarsen

    cblarsen

    Joined:
    Mar 10, 2007
    Posts:
    266
    Just what I was looking for. Thanks.