0 votes

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?

in Engine by (21 points)

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!

1 Answer

+2 votes
Best answer

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
http://docs.godotengine.org/en/stable/classes/class_canvasitemmaterial.html


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.

by (7,840 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.