Search Unity

Animating material parameters in 4.3

Discussion in 'Animation' started by Rob-Fireproof, Nov 14, 2013.

  1. Rob-Fireproof

    Rob-Fireproof

    Joined:
    Dec 18, 2012
    Posts:
    56
    Hi,

    In our game, we do a large amount of animation on material parameters, for example animating the the emission strength of the material's shader.

    Since upgrading to 4.3, it seems we're unable to do this. Old (pre-4.3) animations still work, but we can't author new ones.

    For example, I've got a material on my object which uses a shader with an "_AlphaMult" parameter. If I add a clip to the object, and press "Add Curve" in the animation editor, I can select "MeshRenderer->Material._AlphaMult" as the parameter. It adds the curve in the editor, but animating it has no effect on the material.

    If I load in an old animation with that property animated, the name in the list of curves is different. In the new (none working) one, it's in the form:
    MyObject : Mesh Renderer.Material.AlphaMult

    In the old (working) animation its in the form:
    MyObject : Material._AlphaMult

    In the old version, the text is in bright red, like the editor's not at all happy about that being animated.

    Is this a bug in the new version? Is there a workaround? At the moment our best idea is to add a "Set Material Parameter" component, which can be animated and will just set the material's parameter.

    Thanks,
    Rob.
     
  2. metlapig

    metlapig

    Joined:
    Sep 24, 2013
    Posts:
    3
    I am having the same problem.
     
  3. deathguide

    deathguide

    Joined:
    Aug 4, 2012
    Posts:
    6
    I am having the same problem. anyone konws why?
     
  4. deathguide

    deathguide

    Joined:
    Aug 4, 2012
    Posts:
    6
    Additional, when I add a cuve for a materia property, it has no effect. but the old red property cuve has effect................
     
  5. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    I am also having this bug; it's quite annoying. Hope there's a fix soon.
     
  6. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Same here.
     
  7. kfc

    kfc

    Joined:
    Dec 17, 2010
    Posts:
    27
    Same here mate.

    $Screen Shot 2013-11-29 at 5.06.03 PM.png

    it's true that the attribute of curve made in earlier version shows bright red in 4.3

    I wish someone can provide a workaround for now.
     
  8. tetsii

    tetsii

    Joined:
    Nov 12, 2013
    Posts:
    5
    Yeah ditto.

    This thing is bothering me a lot since I'm going through some animation tutorials and I simply can't continue because of this. I'm trying to animate the main color alpha to fade out an object, but even though I get to draw in the animation for it, it simply doesn't work.
     
  9. TheAngrycrow

    TheAngrycrow

    Joined:
    Jun 16, 2013
    Posts:
    12
    I also have this issue. I think they are pushing mechanim for property animation. I'll have to try it out... it doesn't make sense to strip down the legacy anim
     
  10. TheAngrycrow

    TheAngrycrow

    Joined:
    Jun 16, 2013
    Posts:
    12
    The main color ... or material._color is highlighting the eyedropper in the editor. I feel like these were supposed to work. But there is this strange Continue : property thing going on.
     
  11. Goregaming

    Goregaming

    Joined:
    Sep 6, 2012
    Posts:
    243
    This is why programs like maya are better than unity(in terms of animation). Unfortunately I am of little help as I do not use unity for animation.
     
  12. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    All of that now has to be done through an Animator controller. Which means the pre 4.3 animation files alone seem cemented in red error (though they still play)

    You'll be able to recreate your work authoring an Animator with animation on the main node and passing animation parameters to children including material offsets (XYZW) / material/shader parameters / rgba.color etc..

    I'm desperately trying to convert 4.2 *.anim apply it through a controller to fix....it doesn't like that.

    so Unless you got some tech tool people to help you at your work I think you are going to have to leave them alone, or re-author using the new system from scratch.

    :( can't find any more support currently; maybe someone has automation answers to migrate art over to 4.3 cleanly
     
    Last edited: Dec 17, 2013
  13. Colin_17BIT

    Colin_17BIT

    Joined:
    Feb 6, 2014
    Posts:
    1
    We cannot even get this working through the new Animator controller. We are attempting to animate RGB values on Materials and it simply does not work.
     
  14. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    well first of all the animation system does not create a color changing feature, it only drives an input if the shader has a variable exposed with which to accept input.

    $colorMaterial_copy.jpg

    default cube

    1) add Animator Component (do not add Animation component as that is a Legacy operation)
    2) use "Create New Clip" pulldown from the Animation window
    3) name the anim clip
    4) click "Add Curve" and enter into the Mesh Renderer details; (I added Material._Color to affect default-diffuse's color slider) curves offered will depend on your shader

    5) The inputs accept beyond -1 1 (note with default-diffuse the .5 alpha value does nothing)

    6* looking inside the Animator state system; double click the anim node and the inspector/debug menu shows you that this "ColorChange.anim" is Animation Type = 2, that is mecanim, as opposed to 1 = legacy
    Legacy (type 1) *.anim files will not be allowed into the animator state system
     
    Last edited: Feb 10, 2014
  15. sterlingr

    sterlingr

    Joined:
    Jul 12, 2013
    Posts:
    4
    But what if you've been working on a game for about a year, and the entire engine is written around the legacy animation system. There really is no way to just key the color using the legacy anims?
     
    Last edited: Feb 14, 2014
  16. sterlingr

    sterlingr

    Joined:
    Jul 12, 2013
    Posts:
    4
    I found the solution!!!! Well, another user did, but I'm posting it because this was such a headache for us:

    The problem is that Unity has changed its Material keyframe formatting when it saves animation clips. If you need to use the legacy animation system here's how to fix it:

    Change animation type to 1
    open the clip in a text editor, and replace classID 23 with classID 21
    Still in the text editor, remove material. from the beginning of each Material attribute

    Please Unity, fix this problem. A majority of your users have started games using the legacy system, and simply switching to a newer system is not an option for many.

    -Sterling Sr. Animator - Proletariat Inc.
     
  17. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    @Sterlingr, your fix does not work for me, sadly.

    @Torbach78,

    Animator is not working for me either. Trying to animate Material.Ting Color on Particles/Alpha Blended is completely unresponsive and fails to animate. Pre 4.3, It worked perfectly, and logically on Legacy.


    This was annoying in November, but now it is simply infuriating.

    Why are the unity devs dragging their feet on this huge bug?
     
    Last edited: Feb 28, 2014
  18. josessito

    josessito

    Joined:
    Feb 14, 2014
    Posts:
    57
    Hi, I was having the same problem, apparently you can't access the alpha but you can access the color as a hole. I tried this and it worked

    Code (csharp):
    1.  
    2. public class AlphaAcces : MonoBehaviour
    3. {
    4.     public float alpha;
    5.  
    6.  
    7.     void Update () {
    8.  
    9.         Color newAlpha = renderer.material.color;
    10.         newAlpha.a = alpha;
    11.         renderer.material.color = newAlpha;
    12.     }
    13. }
    14.  
    Just put that code into the object with the material you want to modify and then acces the alpha variable from the animation.
    Hope this helps someone.

    EDIT: I did set the animation to legecy (select the animation and from the dropdown at the top right of the inspector panel select Debug, then change animation type to 1)
     
    Last edited: Mar 28, 2014
  19. RElam

    RElam

    Joined:
    Nov 16, 2009
    Posts:
    375
    Yea, this is pretty amazing to me, whoever owns this bug needs to properly prioritized or replaced. In 4.5, I'm unable to animate ANY material setting. I try to defend this engine, but when they depreciate a system without having a replacement, and just turn a blind eye to massive bugs while producing a large list of bug fixes, it's pretty easy to lose faith. I spent a day hunting down a new serialization bug in 4.5, and now I have to hack around this too, so 4.5 has been a massive disappointment for me. Ugh, c'mon unity devs, you're better than this!
     
  20. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    This is what I mean when I say the shader must be setup to suite your needs. I guess >4.2 _.Tint no longer works (shuriken only?)

    the question is what does? this is outside my skill set, but seems possible because "Marterial._Emis Color" which can be used with //>Particles>"VertexLit Blended" will alter color of the entire emitter system in both editor playback and game mode like so
    shurikenLitVertex.png

    compiled shader #12:
    'Material { Emission [_EmisColor] }'

    I suppose that operates on the vertex level - AFAIK rbga data for particles must be on the vertex level but it will not drive alpha, that property is color only
     
    Last edited: Jul 22, 2014
  21. Amitloaf

    Amitloaf

    Joined:
    Jan 30, 2012
    Posts:
    97
    Worked for me! Thanks :)
     
  22. msklywenn

    msklywenn

    Joined:
    Nov 28, 2014
    Posts:
    67
    Still broken in Unity 5.
    Bug tracker says "resolved" with status "by design". Could we know the reason behind that design ? We lost hours of work today looking to fix this while it really was a bug. The documentation still says to use the legacy animation for simple stuff instead of mecanim.

    http://docs.unity3d.com/Manual/MecanimPeformanceandOptimization.html
     
  23. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    perhaps the legacy anim don't code-nice with the new system and bringing it over just isn't in the scope of unity's future for time/money sakes

    But that literature just because it ambiguously says simple - don't think of material changes as 'simple' post 4.3

    if they are it should be easy to refactor i'm guessing, And all curve data is still saved in legacy .anim file (material.* calls just won't operate without being in a controller post 4.3)

    There's hope though, it's simple to translate them over manually
    1. set the *.anim file type using debug to value = 2 [image 6* above]
    2. remove the Animation Component from object (it won't work)
    3. create a new Animation Controller
    4. put the Animation Controller on the object
    5. Drag the *.anim into the "animator" (window>animator) state machine as it's default clip
    6. check it's operation, should work fine now without having to remake the curves
    Dec 2013 since 4.3 and we have all had a fair bit of time; legacy anims will not start operating

    The "bug" is resolved by design i.e. it will not be fixed and that's now an intentional limitation
    limitation My car won't fly; it was not designed to...
     
    Last edited: Mar 7, 2015
  24. DrakinClaw

    DrakinClaw

    Joined:
    Apr 10, 2014
    Posts:
    1
    Shame on Unity for not fixing this!!!!
    SHAME!
    Seriously, we have this MASSIVE PROJECT and we are STUCK on unity4.2 because you all just decided to change animation formats!!?? SHAME!

    Please for the love of all thats good, FIX THIS.
     
    Last edited: Sep 12, 2015