How to translate "GLSL Sandbox" snippets into Godot Shading Language

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

Hi!

I am completely new to shader and shading language.
Searching the net I found http://glslsandbox.com , a GLSL gallery and realtime emulation tool.
I am trying to implement some of those effects in Godon but what I get is not exactly what I see in GLSL Sandbox.

ie: see this http://glslsandbox.com/e#42039.0

I translated into this:

As you can see the rotating figure center is at the (0,0) origin instead being centered to the screen. Do I make something wrong?

Please, help.
Thanks
Dave

:bust_in_silhouette: Reply From: mollusca

surfacePosition in the original shader has the origin at the middle of the screen with positive y-axis up. UV coordinates have it at the top left corner, positive y down. To center the effect change the second line to:

vec2 surfacePosition = vec2(UV.x - 0.5, 0.5 - UV.y);

Now it works.
Thank you!

DaveMS | 2018-01-18 17:15