Search Unity

Question How can I add a delay in sine time?

Discussion in 'Shader Graph' started by TheRealDanielMihaila, Sep 9, 2020.

  1. TheRealDanielMihaila

    TheRealDanielMihaila

    Joined:
    Jul 1, 2020
    Posts:
    2
    Hello guys,
    I am struggling with modifying an animated blink shader for a collectible.

    What I want to achieve:

    I want to show the pbr textures as usual. But from time to time the emission channel should have an animated "swoosh/ blink effect".

    My current state:
    shader blink.PNG

    I've already managed to get the desired effect by using a sine node and remapping it to animate the offset of an overlay texture. But I want to have a bigger delay between two blinks. When I just decrease the frequency of the sine, I get a bigger delay, but it also affects the speed of the blink itself.

    Does anyone know how I can modify the sine to get more delay between two blinks?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi and welcome @TheRealDanielMihaila,

    I'm not sure if I understood your question completely correct, but here's one idea:

    I think you could tile the UV space you use for a sine curve, then isolate one full sine wave to a certain region of the UV space. I know this sounds a bit high level but that way you can get intervals to your blink/pulse effect, and the curve shape is not affected, there's just space between pulses. i.e. something like this, when visualised:

    sine_curve_pulses.PNG
     
    TheRealDanielMihaila likes this.
  3. TheRealDanielMihaila

    TheRealDanielMihaila

    Joined:
    Jul 1, 2020
    Posts:
    2
    Hi @Olmi,
    thanks a lot for replying! Just for clarification. You basically want to skip every other sine wave with the branch node?
    That would be a good idea in theory. I don't really get how to do it though. When I plug in the branch node it either stops the blink effect or just takes the sine waves it gets from the nodes being plugged in. I'm quite new to shaders so maybe I do not fully understand how it works. Do I need some sort of logic that controls the branch node's predicate?

    Here is a gif that better shows the current effect:
    shader-blink.gif

    I want the pause between two blinks to be longer, but keep the current speed of the blink.