Write shaders godot 3

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

How is this done in godot 3? I’m looking for some example script, but I’m not finding it.

uniform texture frame1;
uniform texture frame2;
uniform float speed = 1.0;

color col;
float time = fract(TIME*speed);

if (time < 0.2) {
    col = tex(frame1, UV);
} else {
    if (time < 0.4) {
        col = tex(frame2, UV);
}
COLOR = col;
:bust_in_silhouette: Reply From: kidscancode

3.0 is still not documented, so you’re not going to find that yet.

In the meantime, there are some examples & discussion posts here in QA, and you can find some additional discussion in the Godot issues:

A user here posted a sample recently:

There is also a language reference someone started putting together:

:bust_in_silhouette: Reply From: PerduGames

very simple too:

shader_type canvas_item; 

uniform sampler2D frame0;
uniform sampler2D frame1;
uniform float speed = 1.0;

void fragment() {
float time = fract(TIME*speed);
if (time < 0.4) {
    COLOR = texture(frame0, UV);
} else {
    COLOR = texture(frame1, UV);
}
}

some interesting links too:

https://www.khronos.org/files/opengles3-quick-reference-card.pdf