Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved get time 0? or another easy way?

Discussion in 'Shader Graph' started by brave_unity, Apr 28, 2022.

  1. brave_unity

    brave_unity

    Joined:
    Feb 14, 2022
    Posts:
    2
    My plan was to make the texture Blink(add float 0 to 1) once I turned on boolean as a function of branch.



    It's a blinker like this. But I want a soft, long flicker.



    So once there was no twinkling threshold, but I don't know how to get it to start at time zero the moment it triggers on. (you know, Time itself just keeps going up)


    I thought simply, "Should I subtract time from time?" But then, since time flows the same way, it's infinite zero...



    It's not hard to just repeat it infinitely, but it's hard to implement it by blinking it out in a timely manner

    The planner wanted to adjust the blinking time, so that's how the structure works.

    I'm not sure if it's something that can be solved with a shader graph or if need a custom function.



    I would like to blink spontaneously on the shader graph using the boolean trigger, so I would appreciate it if you could give me advice on what to do.
     

    Attached Files:

    Last edited: Apr 29, 2022
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,123
    This video is not the best way to blink textures. It would be better to use single sprite and let shader do all the work. I am not sure what exactly you mean by long flicker, but my advice is:
    Think this way - instead enabling/disabling whole renderer you can set shader property to some value. If you send current time (Time.time), then you can subtract this value from current time (in shader) and the result will be 0 for that moment, however with time passing it will grow again. You can use this value to animate your blink. For example if you do this
    clamp01(1 - (shaderTime - timeYouSent))
    you will get values going from 1 to 0 for duration of 1 second.
    You can change blink math to anything else you need.
     
    brave_unity likes this.
  3. brave_unity

    brave_unity

    Joined:
    Feb 14, 2022
    Posts:
    2
    Thank you for your answer.
    In theory, it kind of makes sense.

    The realization of blink once was to add 0 to 1 to the texture as a sign function like the upload image, and only go to 3.14 time once and then suppress it with clamp.
    When I turn on the bool function,
    I want to save the current time and use the saved value, but I'm a 3D designer, so it's hard to use a technique to save the time value.
    I was wondering how I could solve it with just the nodes on the shader graph, but I think my capabilities are limited, so I'm going to talk to the programmer

    i like gintama!