Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Video: Trouble using Bolt Toggle To Lerp ThExposed Material Properties Belonging to URP Shader Graph

Discussion in 'Visual Scripting' started by UnityXizor21, Jan 31, 2022.

  1. UnityXizor21

    UnityXizor21

    Joined:
    Jan 14, 2021
    Posts:
    36
    What is the proper way to Lerp between 0 & 1 for an exposed Shader Graph property using Bolt?

    I have an exposed 'Lerp' property in my #Unity3d URP Shader Graph. I have a "Toggle Unit" & a "Material Set Float Unit" in my Flow Graph. They don't link up/communicate with each other properly.

    What am I doing incorrectly? Your experience, insight, and willingness to help are greatly appreciated; so thank you!

     
  2. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    The name you want to use is not the Name field in your shader, but is the Reference field.
    So instead of Lerp, you want _Lerp
    upload_2022-1-31_15-21-3.png
    upload_2022-1-31_15-19-44.png
     
  3. UnityXizor21

    UnityXizor21

    Joined:
    Jan 14, 2021
    Posts:
    36
    Thank you, ericb_unity,

    Funnily enough, I learned from a video tutorial to begin my references with an underscore. The video even clearly states the purpose of doing so is to gain access to the property from code. The very same video that taught me so well ... was the very same video that led me down the path of improperly using 'Lerp' in place of '_Lerp'. Oh cruel irony.

    I should have put two and two together; I simply did not.

    Can you point me to a good resource for learning to smoothly transition over time between the two floats?

    Tutorials have led me down the path of using a Bolt Lerp Unit combined with a Time.DeltaTime Unit + a Divide Unit, but this isn't working. The problem with Youtube, for every 1 working tutorial there are 19 that don't work or are immensely obsolete.

     
    MatNell likes this.
  4. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    Ok, the way I'm showing may not be the best, but it is understandable and it work with your current scenario. So, I made 3 examples. Using the Cooldown node, to make sure the action can't be achieve until it is completely done.


    1- Using a lerp function to do the interpolation. like what you are trying to use.
    upload_2022-2-3_13-34-41.png

    2- Using a curve to do the interpolation. I do prefer using curves, because it can be modified by users and saved. You can make fancy ease-in, ease-out with those.
    upload_2022-2-3_13-35-25.png

    3- And the final example with a curve and a toggle so your value can interpolate from 0 to 1 and from 1 to 0.
    upload_2022-2-3_14-43-41.png
    This is how it look like with a custom shader having my lerp value set on the alpha.
    ToggleInterpolation.gif
     
    MatNell likes this.