Controlling Time In Shaders

Node-based Shader Editor

Controlling Time In Shaders

Postby Yoshinjo » Wed May 02, 2018 8:09 pm

Hello,

I'm trying to learn more about the power of what the Time node can do. My question is: If I wanted to create a shader that had two states, say for instance opacity change.

State A: Opacity: 100%
State B: Opacity: 0%

In the shader I want to lerp between these two states and I want to be able to have a property float value (let's call this Transition Duration). From there I can input a transition time value in secs to go from State A to State B. I've been able to do a ping-ping transition using time node with a sin function, but how do I accomplish just a ramp instead of reoccurring wave? I should probably also mention that I'm trying to accomplish this for a UI material shader. If this is possible, from there it would be nice to have a property float value that I can define for a time delay as well. Thanks in advance!
Yoshinjo
 
Posts: 11
Joined: Tue Mar 20, 2018 8:51 pm

Re: Controlling Time In Shaders

Postby Amplify_Borba » Thu May 03, 2018 10:41 am

Hello!

Ideally, you would set this up via script and feed the information to the shader through a property for more control over the effect. Nevertheless, I'm also sharing a sample that might serve as an example for what you need:

Image

Note: The node previews don't always represent the final output for the shader.

Please let me know if this helps, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Controlling Time In Shaders

Postby Yoshinjo » Mon May 07, 2018 9:22 pm

Hi Borba,

Thanks again for replying to my question. The example you provided works great for looping transitions. Is there a way you can have the transition go from A-B and not loop? Also wondering if you have any examples of adding a delay. For instance, it would be great to have a specified time delay.

-John
Yoshinjo
 
Posts: 11
Joined: Tue Mar 20, 2018 8:51 pm

Re: Controlling Time In Shaders

Postby Yoshinjo » Mon May 07, 2018 9:32 pm

Here's an example of the shader I'm trying to create. The idea is that you create a mask image with a black and white gradient to create a dissolve effect. In this case, I have snow layered on top of another image, the snow slowly fades in gradually and the gradient causes a gradual buildup of snow. As I mentioned before, I'm trying to figure out how to create a non-looping effect with a float input to define a timed delay before the transition begins. I was looking into smoothstep for the transition from State A to State B and basically have the value hit a ceiling, but I'm not sure that's the right approach.

Image
Yoshinjo
 
Posts: 11
Joined: Tue Mar 20, 2018 8:51 pm

Re: Controlling Time In Shaders

Postby Amplify_Borba » Tue May 08, 2018 10:13 am

In order to create a controlled transition over time, you'll need to feed values directly into your shader via scripting.

Our Smear sample provides an example on how to achieve the above, and I'm also sharing a sample that provides an animated value as a global property that is then used by the shader to apply a tint. Even though the effect is looped, you might set it as a delayed linear transition through the animator.

AnimSample.zip
(7.91 KiB) Downloaded 208 times


Please let me know if this helps, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Controlling Time In Shaders

Postby Yoshinjo » Tue May 08, 2018 5:24 pm

Awesome!

Hey thanks again Borba. I keep saying it, but the support for Amplify Shader is great. One of the many reasons I switched from Shader Forge to ASE. I wrote on the Shader Forge support community forum and haven't gotten a single response in months. Great to know that if I have a question I can get pointed in the right direction instead of spinning my wheels and shooting in the dark.
Yoshinjo
 
Posts: 11
Joined: Tue Mar 20, 2018 8:51 pm

Re: Controlling Time In Shaders

Postby Amplify_Borba » Wed May 09, 2018 9:06 am

No problem, always happy to help!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, the Unity Asset Store thrives on user interaction and direct feedback.
Every bit helps, your feedback is extremely valuable to us!

Feel free to get back in touch if you have further questions, or if you want to share your results with the community, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests