Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Apply effect to only part of the mesh

Discussion in 'Scripting' started by landon912, Sep 20, 2014.

  1. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Hey guys! I'm going to try to explain this as clearly yet shortly as possible, however please forgive me if it is not clear as it is a small part of a huge project.

    I have a mesh that is generated from many smaller meshes, in this case hexagons, akin to a chucking system. Textures are read from a texture atlas. My question is what would be the best and most efficient method to make a change to one hexagon without adding an extra element to the texture atlas? For example, to gray one hexagon out without having to add a grayed out texture for each hexagon texture to the atlas?

    A vertex shader?

    While code is always welcome, simply a push in the right direction would be tremendous help.

    Best regards,
    Landon Kirk.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Vertex colors? 50% alpha would probably work.

    --Eric
     
  3. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    I'm not rehearsed in these areas very well. Is this the same as vertex lighting?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Nope, it's Mesh.colors32. Each vertex has an associated color. That requires a shader that makes use of vertex colors; most of the built-in shaders don't, although the particle shaders and sprite/ui shaders do.

    --Eric
     
    landon912 likes this.