Search Unity

Question about applying multiple materials to the same mesh

Discussion in 'Scripting' started by itsDmajster, Jan 31, 2015.

  1. itsDmajster

    itsDmajster

    Joined:
    Oct 27, 2014
    Posts:
    45
    Hello!

    I have this mesh which is dynamically created, and can be deformed in real time, basically i am creating a custom terrain engine, now i wonder how should i go about adding multiple materials support to it since 1 material can be quite dull to look at.

    Here is a picture of the current terrain:

    Desired effect:


    Thank you for even looking at this post and even furthermore if you help me in any way !
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
  3. itsDmajster

    itsDmajster

    Joined:
    Oct 27, 2014
    Posts:
    45
    So this would mean when i start painting triangles with different materials i should reassign them to different sub meshes which are tied to that material ?
     
  4. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Alternatively, you could write a shader that takes multiple textures, and then you paint vertex colors to blend between them. This would get nice boundaries between the textures, not hard edges
     
  5. itsDmajster

    itsDmajster

    Joined:
    Oct 27, 2014
    Posts:
    45
    hmm, that would be the effect i am going for, but shaders aren't something i am good at
     
  6. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    I think the better approach is via vertex color and using that to blend based on it.
     
  7. itsDmajster

    itsDmajster

    Joined:
    Oct 27, 2014
    Posts:
    45
    cmcpasserby please explain, that sounds like something i would be actually able to do myself
     
  8. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    Its possible to have your shader lerp between multiple textures via vertex color on the verticies of your mesh.

    So after this you could either use a tool to paint vertex color on your mesh, or if its procedural have your system that makes the mesh assign certain colors.