Animating shader uniforms
Asked Answered
B

3

0

Is there a way to directly animate a shader uniform via AnimationPlayer or in some other way? If not, this is something to consider for the future versions as it'd be very useful. I know it can be done indirectly by animating a node property and manually sending it's value to the shader.

Benedetta answered 24/9, 2021 at 10:41 Comment(0)
M
0

You can create keyframes for shader params. Just have the animation tab selected and click the key button next to the uniform you want to create a keyframe for.

Merous answered 4/10, 2021 at 3:54 Comment(0)
T
0

Depends what kind of animation you need. For simple stuff, just use the TIME built-in and some logic. For example, I made this video using only shaders (the scene had two non-moving flat planes). https://www.reddit.com/r/godot/comments/fb2tmh/experiment_with_vertex_shader_animation/

Torras answered 4/10, 2021 at 4:31 Comment(0)
B
0

Oh, so it's possible. Godot keeps surprising me in pleasant ways :) I was trying to animate via tweens but didn't know there's a catch with path syntax. Now that I looked how AnimationPlayer specifies the path, all is clear. I tried:

:material_override:shader_param:uniform_name

Which didn't work. Proper syntax then is:

:material_override:shader_param/uniform_name

And it works with tweens too. Cool!

@cybereality it's not looped. Only one-shot eased transition that gets triggered sporadically and has different duration each time it happens. I do use TIME for looping stuff.

Thanks for the hints guys!

Benedetta answered 4/10, 2021 at 7:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.