How to use Shader in Godot?

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

Hi,

I was thinking of making a scene transition using shader and the node animationplay, like this:

I gave a read in godot docs and I just understood how to use the “uniform”.
How to manipulate images?
How do I join a vector2 and join some function?
How do I add a white mask and scale it to fit the image on top?
(The visual editor of v2.1.4 beta is still bugging, when I add a new block, the other blocks that are already, they change places)
(and also do not want to stay depending on the visual editor).

The documentation could have more information on how to use this and also several examples to facilitate learning.
It has a 2 tutorial in Portuguese but they do not teach the sufficient one.
I already left several projects for not knowing how to do something, because for me it is important to have this in the game!

You do not know how frustrating and exhausting it is not to know how logic works and worse still you want to complete a project but in the midst of progress you start getting discouraged and banging with various bugs. :confused:

The first question here is, if you really need a shader for this effect.

Anyway if you use a shader, then here are some links for screen reading shaders.
Docs:
Screen-reading shaders — Godot Engine (stable) documentation in English
http://docs.godotengine.org/en/stable/learning/features/shading/shading_language.html

And an interesting Q&A post with example code for a screen reading shader:
https://forum.godotengine.org/13023/shaders-how-does-one-create-blackhole-effect-using-shaders

Personally, I prefer the text editor for creating shaders. Just keep in mind that the shader language is different from gdscript.
You’d probably need the uniforms to receive a background texture and some kind of scale factor which can then be updated by an animation.

But:
You could also generate such an effect with a sprite and a textureframe. Generate a png of your background color with a transparent oval in the middle (maybe leave some border).
Then assign your background image to the sprite and the transparent oval png to the texture frame.

But the sprite behind the textureframe. Set it centered and alter the region rect via an animation so it starts from picture center and finally sizes the region to the whole screen size. Now you should have the basic effect but rectangular.

Now scale the texture frame (stretch mode “scaled”) in the same animation from 0 in the center of the screen to some area bigger than the screen.

You should be able to achive this by playing a bit around.

wombatstampede | 2017-10-13 07:59

I wanted to do this with shader to better understand how they work, but it seems that most of us here do not know how to handle shader.
I just wanted a different look for my game.

I also wanted to add a shader type:
iStock

I think it was an illusion to try to create this game … I think I’ll abandon it just like the others. :confused:
thank you anyway, you are very nice with me :slight_smile:

ismaelgame7 | 2017-10-13 18:06

Hey man, don’t give up! If you want to create a game you can do it! I think you can create the effect you want but you need to be more specific about why you want that specific effect.

For example, I asked a similar question a few weeks ago. I wanted to make all of a certain color in my images transparent. People were saying intially to don’t do that. I explained that I wanted to do this because of XYZ reason. Then someone came by and gave me some hints. I did some reasearch and tried some code for shader which didnt work. Then later somoen came and helped me correct my code. Now I fixed it and I got my shader… I’m not a genius!

If you want to solve a problem, you can!

Good luck!

davidpgil | 2017-10-23 18:39