Search Unity

Adding a material only affects part of the mesh

Discussion in 'General Graphics' started by LootlabGames, Apr 13, 2017.

  1. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    I have a skinned mesh renderer that has 2 materials.
    One is for the hair (cutout) and the other for the face/body(opaque).

    I have a poison effect material that I want to apply over the entire mesh(cutout).
    If I add it as a 3rd material it works great, but the problem is it only shown over the hair.
    How do I get the material to show over the entire mesh?
     
  2. UziMonkey

    UziMonkey

    Joined:
    Nov 7, 2012
    Posts:
    206
    You'll have to replace both materials with that material. Adding a third material slot when there is no faces in the mesh that use a third material slot should do nothing.
     
  3. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    Thanks for your reply.
    I know for sure that that would work of course.
    But I want those materials to be present, but have the poison material "overlayed".
    That way you can see the character underneath.
    Like I said it does work perfect when I add it as a 3rd material, but not on the whole mesh.

    If I use it on a mesh that only has one material it works perfectly, just not when a mesh uses more than one.
     
  4. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    After much research...
    If you have more than one material a custom shader is needed.
     
  5. UziMonkey

    UziMonkey

    Joined:
    Nov 7, 2012
    Posts:
    206
    You're right, I just tried it and it does indeed apply both materials, somehow. But I get warnings and I've never seen anyone do this before. If I were to do this, I would make a custom shader with ShaderForge or Amplify Shader. Writing your own shaders by hand is hard, but hooking a few things up with Shader Forge or Amplify Shader is easy. They're a bit expensive, but one of the best investments you can make as far as generic Unity assets goes.

    Barring that, you can use the standard shader and add a detail texture. This detail texture will be mixed in over the normal texture, but you won't have much control over it at all. You could lerp the tint color of the standard texture up and down to do some effects, you'd have more control over that but then you get no texture for your effect.
     
    theANMATOR2b likes this.