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

Material Swap Animation Issues

Discussion in 'Animation' started by Berandas, May 27, 2019.

  1. Berandas

    Berandas

    Joined:
    Jan 4, 2013
    Posts:
    15
    Hello!

    I am solving an issue with material swap animation in the Mesh Renderer Component. I am trying to swap several materials in that component by replacing them with different ones and keyframing everything in the animation clip. (btw, is this the right procedure to do such thing?)
    While it all looks allright in the animation clip keyframes, it does not behave that way while previewing the animation in edit mode and it does not work that way in play mode.

    It seems that it’s a general issue with any kind of Mesh Renderer (I was able to reproduce the exact behaviour on three different meshes, both dynamic and static). The affected material is ALWAYS the Element 4 slot. So when I have a random mesh with at least 5 materials (Image Fig.1) and I keyframe them, for each material 3 keyframes are added (Image Fig.2):

    Mesh Renderer.Material Reference[n]
    Mesh Renderer.Material Reference[n].File ID
    Mesh Renderer.Material Reference[n].Path ID


    at this state, although you can clearly see the material change keyframes being correct (switched transparent material is visible in the preview), only the Element 4 is behaving correctly (switching the materials properly).

    However, when I delete the keyframes that are unnecessary, since their value is constant the whole time (Image Fig.3), the effect is inverted, all materials are working correctly, EXCEPT the material in Element 4 slot, although again, the preview keyframes show the correct values.

    Additionaly to that, as you can observe from the model (Image Fig.1 and Fig.2), that the materials appear to be offset, or their order changes in some way (notice the material change on the nose and inside ears during the whole process), it seems that Element 4 content also replaces the content of Element 2 (Image Fig.3) for some reason.

    When the model contains less than five materials in total, everything works correctly.

    I'm having this problem with Unity 2018.4.0f1, but I was also able to reproduce it with 2019.1.3f1.
    Any ideas what I might be doing wrong, or is this some kind of bug?

    Here is the image depicting the problems:
    Material_Messup.png
     
  2. AliceFaere

    AliceFaere

    Joined:
    Oct 10, 2020
    Posts:
    2
    I don't mean to revive an old thread, but I'm currently encountering this same exact issue (in both 2018.4.28f1 and 2019.4.12f1) and this was the only scrap of information I could find. Situation is a bit like this classic.

    If anyone knows something or has any suggestions, or if the original poster had found a solution, I'd be much obliged
     
  3. Berandas

    Berandas

    Joined:
    Jan 4, 2013
    Posts:
    15
    Sadly I was not able to find a solution to this problem yet.
    Recently one of my colleagues was facing this issue again and his final workaround was to simply replace the game object with a different one using different materials through a script.
     
  4. AliceFaere

    AliceFaere

    Joined:
    Oct 10, 2020
    Posts:
    2
    That’s the workaround I’m using at the moment as well. Just seems like a shame to need to duplicate/hotswap meshes when there’s a better(?) way that’s seemingly been bugged for a while now
     
  5. cheese_man1000

    cheese_man1000

    Joined:
    Oct 26, 2020
    Posts:
    1
    I just got this issue too and this seems to be the only thread that has any information on it. Unfortunate that it hasn't been resolved.
     
  6. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Has anyone reported a bug with this?
    A bug report with a reproduction project will be extremely helpful in getting this addressed, and making sure we are actually addressing the problem that you are having, and not our perception of what your bug is.
     
  7. Berandas

    Berandas

    Joined:
    Jan 4, 2013
    Posts:
    15
    Thanks for your reply David, if we can close this as a bug on the Unity side, then I will prepare the example project and submit a bug ticket once I get some time.
     
  8. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Perfect.

    I can't guarantee a fix; sometimes all ramifications of two features working together can't be resolved without unreasonable performance cost, but it does look like a bug to me.
     
  9. ShingenPizza

    ShingenPizza

    Joined:
    Nov 24, 2020
    Posts:
    1
    Hello,
    this seems to be the same bug that i've encountered myself, and i've reported it yesterday.
    today i got a reply that they already know about it and they're tracking the issue here: https://issuetracker.unity3d.com/is...al-to-a-single-slot-while-recording-animation
    (the issue describes something slightly different than i've reported, but it seems to stem from the same bug)
    so if you want to incentivize them to fix it faster: vote on it :)
     
    Berandas7 likes this.