Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Animating Lighting or Material Properties in Timeline

Discussion in 'Timeline' started by frogwise, Dec 3, 2017.

  1. frogwise

    frogwise

    Joined:
    Nov 27, 2009
    Posts:
    92
    Hey I'm trying to use Timeline to animate a sunrise, and I would like to

    A) animate the Fog properties under Lighting
    B) Animate the Sky Tint property under the Procedural Skybox material I'm using.

    Is this possible? I cannot seem to add an objects porperty to the timeline unless it exists on a gameobject. Both Lighting Properties and Materials do not live on gameobjects.

    Thanks guys!

    upload_2017-12-3_13-45-44.png
    upload_2017-12-3_13-46-3.png
     
  2. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    DChap likes this.
  3. frogwise

    frogwise

    Joined:
    Nov 27, 2009
    Posts:
    92
  4. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
     
  5. DChap

    DChap

    Joined:
    Dec 24, 2016
    Posts:
    23
    Thanks for linking the video, lot of good info in there.

    After watching it though, I'm still not sure I'm entirely sure how to go about editing a material's value (color, etc). The Timeline Playable Wizard still seems like it is set up to edit objects in the scene, but I don't see an option for Material anywhere in there. How can I set up a custom track to control a material value?
     
  6. coggycog

    coggycog

    Joined:
    May 19, 2013
    Posts:
    1
    DChap,

    Here's the skinny:

    Add an animation track
    Drag your object with the material into the track
    Set your timeline to 0
    Hit the record button
    Change your material along the timeline where you see fit

    VIOLA!

    GLHF
    Cog
     
  7. Diesign

    Diesign

    Joined:
    May 15, 2016
    Posts:
    16
    @coggycog Is it possible to throw the Window>Rendering>Lighting Settings onto an object?
     
  8. metroidsnes

    metroidsnes

    Joined:
    Jan 5, 2014
    Posts:
    64
    I'm not sure about that but you could create a Playable that modifies settings on a GO with your custom script attached that in turn modifies the RenderSettings.
     
  9. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    414
    THANK YOU!!!!
     
  10. DChap

    DChap

    Joined:
    Dec 24, 2016
    Posts:
    23
    Hi @coggycog, I tried what you said but it doesn't work for me. What version of Unity are you using? (I'm on 2019.1.3)

    I can drag the object onto the timeline as an animation track and hit the record button, but it isn't recording any keyframes for changes I make to the material. Are only certain types of materials or gameobjects animateable?

    For reference, I'm trying to animate a UI sprite.
     
  11. Maarja

    Maarja

    Joined:
    Jul 21, 2019
    Posts:
    12
    @DChap did you manage to animate a fog property on timelne in the end? Im trying to do the same, but no keyframes are being added on timeline. I only found a conclusion that "This is by design, the Animator in Unity only supports basic properties on MonoBehaviour components." https://issuetracker.unity3d.com/is...on-when-changing-values-in-sky-and-fog-volume But I didn't figure out the solution yet.
     
  12. Maarja

    Maarja

    Joined:
    Jul 21, 2019
    Posts:
    12
    @JakubSmaga do you have any idea if this approach would still work in Unity 2019.3 HDRP? Is there any other way which would not requiring coding necesarilly?
     
  13. DChap

    DChap

    Joined:
    Dec 24, 2016
    Posts:
    23
    @Maarja I think I gave up on that hehe. I don't think it's possible without making a custom script with a variable that is referencing the scene fog value, and then animate that variable.
     
  14. markfrancombe

    markfrancombe

    Joined:
    May 26, 2009
    Posts:
    153
    Too old thread, I wonder if it will wake up if I post here?
    So, now in 2021, how can I do this.
    1) animate the fog value over time
    2) animate a material property over time. NOTE, the example above worked fine, except its only referencing the EXACT object that you drag to the timeline, I want ALL objects that use the same material to be affected by the animation of the material property.

    REAL USAGE: I wanted to use the timeline to create the day/night cycle. Its fine for lights that dim and change over time, as you can drag them in, the sun rotating works fine. But the Emission slot on the material of a building has the lighting information for the windows, so lights come on ALL OVER THE CITY, when I wiggle this property on the material. The important thin is that everything is contain within one timing "Track" so I can add sound changes, and events to that same track (Including animating the city hall clock!)
     
  15. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    478
    @markfrancombe

    I have discussed this with others more familiar with the Graphics side of things, and your best bet seems to be to create a custom track that uses Shader.SetGlobal<Something> to change global values on your shaders.

    Every other method I can think of will either dirty the scene, or be very painful to maintain.

    Still, be aware that whatever changes you make to the shaders may stay "stuck" for the duration of your editor session unless you make efforts to reset the values to the original, scene ones once the preview is over
     
  16. atiq_qazi

    atiq_qazi

    Joined:
    Dec 2, 2020
    Posts:
    2
    @DChap
    Create a script
    Add it to timeline
    usea public or serialized float member in inspector to change rendersettings.fogdensity on update

    Screenshot 2021-04-29 001220.png Screenshot 2021-04-29 001245.png
     
unityunity