Search Unity

Question Animating in Shader Graph that does not loop

Discussion in 'Shader Graph' started by animator84, May 28, 2019.

  1. animator84

    animator84

    Joined:
    Jan 10, 2018
    Posts:
    14
    Hi I've been through some tutorials on animating vertex animation, looping textures etc. And alot of them use the sine-time node.

    But what If i want this animation to only play once. Like for example, i want to animate a smoke mesh to disappear. But I only want to animate it once and i don't want it to loop or ping pong. How can i achieve that in shader graph?
     
  2. animator84

    animator84

    Joined:
    Jan 10, 2018
    Posts:
    14
    This is a video to illustrate my point, The fade out is rather random and i hope to control it (play video at 1.5x speed) .
    Is there a way to control the fade using shader? I've tried animating shader attribuutes using "animator" component. Doesn't work.



    Or is there another way we I should be looking at this.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,339
    If you're using a particle system, you should be driving your animation using either the particle color alpha (use the Vertex Color node in Shader Graph) or using custom data (enable the Custom Data module, then under Renderer enable Custom Vertex Streams and add the Custom data to the stream. It can then be accessed using a UV node in Shader Graph).

    Outside of particles, an animator component would be the easiest way to go about this.
     
  4. animator84

    animator84

    Joined:
    Jan 10, 2018
    Posts:
    14
    Hey bgolous thanks for your reply, I'm sorry i don't really understand it well. do you have an image of how i can achieve that? I understand using animator component. But using particle color alpha or using vertex color node, I don't know which node plugs where , do you have a screenshot of what happens?
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,339
    In your Shader Graph, delete the sine time node and add a vertex color node. Then feed the A of the vertex color into whatever you where using the sine time for. Sine time outputs a value between -1 and 1, so you might need to use the remap node depending on what you’re doing as the vertex color is only 0 to 1. After that use the Color over Lifetime module on the particle to animate the alpha.
     
    animator84 likes this.
  6. animator84

    animator84

    Joined:
    Jan 10, 2018
    Posts:
    14
    !! ok that's great thanks i'll try it now.