Shader; set time to 0 on "start"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By David Krause
:warning: Old Version Published before Godot 3 was released.

I’ve played around with shaders (never done shaders before, so i’m total noob).
I’ve build a “hyperjump” shader, that i want to assign to as sprite, when the starship sprite leaves my scene.

Inside the (graphical) shader i use “time”.
Now i have the effect that, even if the material is not assigned to the sprite yet, the time seems to go on.

So when i finally assign the material, the shader “does not start at the beginning”.
So my question is now: Can i somehow set the shader time to 0 on assignment?

:bust_in_silhouette: Reply From: eons

Use a float uniform instead of TIME and, with a script or AnimationPlayer, modify the value on process.

Is really easy to animate shaders with animationplayer, via code you can change shader parameters getting the material and using set_shader_param

Thanks! Totally missed this!

David Krause | 2017-04-01 11:17