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.

Unity 4.2 Multiple Materials draw order.

Discussion in 'Editor & General Support' started by NeeravM, Jul 24, 2013.

  1. NeeravM

    NeeravM

    Joined:
    Jul 9, 2013
    Posts:
    4
    Hello,

    I upgraded my project to Unity 4.2, everything went fine. But one of the functionality seems to be broken. I was using multiple materials( 7 to be precise) on a plane and had arranged them in the draw order in renderer.materials[] array. After the update they are being drawn in random order. I am using Transparent/Diffuse shader for all the materials. Has anyone else also faced similar problem ? Is there a better way of going about this?

    Let me know If you think I should add a screen shot of my property inspector

    Thanks,
    Neerav
     
  2. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    I have a problem where a model with multiple materials was showing other body parts through the outer mesh. So boots show through/on top of cape/robes for example, after upgrading.
     
  3. CiroContns

    CiroContns

    Unity Legend

    Joined:
    Jan 28, 2008
    Posts:
    82
    I'm having a similar issue: I have a plane with two materials layered one on top of the other. The draw order is messed up, but this only happens randomly (like, I have 7 instances of this plane and only 3 exhibit the issue, randomly).
    This also happened to me since I upgraded to 4.2.
     
  4. CiroContns

    CiroContns

    Unity Legend

    Joined:
    Jan 28, 2008
    Posts:
    82
    Ok, I found a workaround: if you have an object with (say) 2 materials whose sorting is wrong, simply attach a script to the object that reloads the materials at runtime by loading them from Resources, and recreating and reassigning the whole array of materials.
    Not the best, but it works and will sort your broken game if you have a presentation tomorrow like me.

    Eg: 2 materials (holographic panels)

     
  5. NeeravM

    NeeravM

    Joined:
    Jul 9, 2013
    Posts:
    4
    Thanks for the update. This does not seem to work for me. Although, I am not loading materials from resources, but textures from resources. Any Ideas ?
     
  6. edkim

    edkim

    Joined:
    Jul 26, 2013
    Posts:
    1
    I am experiencing the same problem. I was able to use the runtime workaround by ccontinisio to get the order drawn correctly..thank you!
    As a note, the materials need to be assigned every frame, not just once in your start...however, the resources can be loaded once
     
  7. fallingbrickwork

    fallingbrickwork

    Joined:
    Mar 16, 2009
    Posts:
    1,072
    Will reassigning materials break batching? I don't knowing so, I'm just thinking out loud.
     
  8. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,241
    I am having a similar experience. My thread is linked to this thread, so I'll link back there as well:

    http://forum.unity3d.com/threads/192467-Unity-4-2-submesh-draw-order?p=1309435#post1309435

    If we can get enough people to submit bugs, hopefully Unity will see this as a legitimate problem and get a fix. This is a major break in the established process!

    To submit a bug report in Unity go to the menu "Help > Report a Bug". Be sure to include screenshots and project files to help them diagnose the issue.
     
    Last edited: Jul 26, 2013
  9. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,241
    Unity support has confirmed the bug in 4.2 with me and has sent it on to their developers. They have no timeline for the fix, however.
     
  10. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,241
  11. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,241
    Just in case anyone is watching this thread, Unity has released v4.2.1 that has the hotfix for the draw order bug.
     
  12. hotozi

    hotozi

    Joined:
    Nov 19, 2012
    Posts:
    5
  13. Sikfreeze

    Sikfreeze

    Joined:
    Oct 27, 2015
    Posts:
    1
    Hi, I'm using Unity 5.2 now and seems to have the same problem here. I have a base 3d model, a character with clothes. each part can be swapped with meshes that are loaded from Resources folder (FBX files) at runtime. The problem is most of my meshes contain multiple materials and once I swapped a certain mesh, sometimes, the materials are not mapping to the right submeshes. For example, the Top part has cloth and skin materials, when I swap the meshes and assign new materials to the materials[], some meshes (loaded from the Resources folder) will have skin texture mapped to the submeshes that are supposed the be mapped with cloth texture and vice versa. Has anyone experienced this with Unity 5.2 as well? Any suggestions or work arounds? Thanks