Animating a 2D drop shadow

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

Hi everyone!
I recently began to look into Godot’s shading language, and I’m having quite a hard time understanding how to actually code in it (I’m new to programming).

I want my sprites to have a drop shadow (as in example 8 of the demo project “2D shaders for sprites”) and I want the radius of the shadow to change with time. To be more specific, I want it to grow bigger and smaller in loop. Can someone help me in achieving this?

Also, since I’m working on a mobile game, I was wondering: achieving glow and shadow effects with shaders instead of sprites is much more convenient for me, but is it efficent for the device? Is it better to rely on RAM instead of GPU?

Have you managed to implement this with the help of eons answer?
If so, could you imagine to show how you did this?
Cause I’m trying to do something like that and it would help a lot as a starting point.
Thank you!

TobiLa | 2018-02-17 09:28

:bust_in_silhouette: Reply From: eons

Shaders can be complex even if you are old on programming.
http://thebookofshaders.com/ is a really good lecture+practice to start with them, even if is not the same as Godot 2 syntax (maybe more similar to 3) it can be translated easily when you know what happens.


You can use AnimationPlayer on the shader parameter (uniform) using the demo shaders and play a bit with the code and check other shaders code to alter some effects.

Look here:
https://twitter.com/_eons/status/776824140573601792

By code can be using Tween or get the material and change the shader parameter with set_shader_param


Shaders are better than textures, they don’t use ram as resources do and are processed on GPU.

But don’t think on performance when starting, do the thing that can give you results faster, later you can make it better.

Thank you sooooo much! Great links. You’ve been very clear!

Pyr | 2017-04-15 10:52