Search Unity

Animating Emission Intensity on a material on an object no worky

Discussion in 'Timeline' started by mherbold, Feb 20, 2021.

  1. mherbold

    mherbold

    Joined:
    Jun 4, 2017
    Posts:
    35
    This is using Unity 2020.2.5f1, using HDRP.

    I am trying to use timeline to animate the emission intensity on a material. I can see the emission intensity numeric value changing when I move the time during preview. The value is changing from 0 to 50000 on a curve and I can see the emission intensity value box is red to indicate it is animated, and the value changes when I change the time. However, the actual material rendering in either the editor scene window or the game window does not change at all.

    If it makes any difference, this material is on 4 objects in the game. None of them changes visually during the timeline animation.

    Please help.
     
  2. mherbold

    mherbold

    Joined:
    Jun 4, 2017
    Posts:
    35
    Update - I just tried to animate the base color and it worked! The base color is animating. The emission intensity still does not animate. Why does emission intensity animation not work?
     
  3. mherbold

    mherbold

    Joined:
    Jun 4, 2017
    Posts:
    35
    Ok... playing around with it some more - it seems like animating material emission does not work when "Use Emission Intensity" is checked. If you leave it unchecked and animate Emissive Color instead, it works. Sigh.
     
    DavidGeoffroy likes this.
  4. Thall33

    Thall33

    Joined:
    Sep 18, 2013
    Posts:
    134
  5. Freakish

    Freakish

    Joined:
    Jun 3, 2015
    Posts:
    81
    Yes I would like some clarification as well. I've spent hours chasing my tail on this issue, and it seems to have been fundamentally broken for many years (when searching for answers) without any kind of input from the Unity team.

    The workaround listed at bottom of the page here by DavidDreamer was very helpful.

    https://forum.unity.com/threads/hdr...d-lead-to-black-material.732350/#post-6820094

    That works well enough to work around the bug and adjust intensity via code, but I cannot get it to then also work with an animation clip. Driving me completely insane.

    Emission_Intensity seems to be absolutely and fundamentally broken, and I'd really like to see someone say they are working on fixing it.
     
  6. AlessioCarini

    AlessioCarini

    Joined:
    Feb 22, 2018
    Posts:
    1
    I am not sure if I understood the issue correctly, but if what you are lookin for is to be able to change the emission intensity purely via animation clip, have you tried enabling the keyframe recording mode and changing the emission intensity directly from the inspector? At least, that's how I solved my problem with animating the intensity.
     
  7. RulioOW

    RulioOW

    Joined:
    May 27, 2018
    Posts:
    7
    I had a similar problem and had to create a script to get the material and enable the emission to work around it:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. //[ExecuteInEditMode]
    4. public class EnableMaterialEmission : MonoBehaviour
    5. {
    6.     private Material mat;
    7.  
    8.     private void Awake()
    9.     {
    10.         mat = GetComponent<MeshRenderer>().sharedMaterial;
    11.         mat.EnableKeyword("_EMISSION");
    12.     }
    13. }
    Or you can create your own shader, I only had this problem with the default shaders.
     
  8. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I was running into this today in HDRP, and found this page (HDRP-specific) that may explain why this property seems to be broken with respect to animation:

    https://docs.unity3d.com/Packages/c.../adjusting-emissive-intensity-at-runtime.html

    The gist is, _EmissiveIntensity isn't used at runtime. It's only used to serialize the emission color. So, it's confusing that this property can't be adjusted at runtime, but it's not a bug, it's by design. I'm not sure if this is exactly the same using SRP or URP.

    In any case, the guidance on that page is probably the same for all render pipelines: You can't animation the _EmissionIntensity. Instead, you need to multiply the color by the intensity manually via code. Probably the best option is to animation some property on a script and have the script constantly update the color via mat.SetColor().
     
  9. Freakish

    Freakish

    Joined:
    Jun 3, 2015
    Posts:
    81

    I worked around it by creating a custom shader in Shadergraph that uses a vector4 node with a multiply node to control the intensity. This way I can animate the axis values on the exposed vector4 to increase RGBA intensity and or colour in realtime in the editor or via a slider or anim clips etc. It ended up having several benefits to the other workarounds for me.

    But thanks for the link.
     
    dvelasco likes this.