0 votes

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;
asked Sep 13 in Engine by PerduGames (139 points)
edited Sep 13 by PerduGames

2 Answers

+2 votes

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:
https://github.com/godotengine/godot/issues

A user here posted a sample recently:
https://gist.github.com/RameshRavone/481e16c8b2afaf0a650f5fd4bb25821f?fref=gc

There is also a language reference someone started putting together:
https://docs.google.com/spreadsheets/d/1hBpkNor5-WUTKuiEP3Myo4wzleCWvqPqn1OLgOwFsmU/edit#gid=1226435562

answered Sep 13 by kidscancode (1,208 points)
0 votes

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://godotengine.org/article/making-shaders-more-accessible
https://www.khronos.org/files/opengles3-quick-reference-card.pdf
https://pbs.twimg.com/media/DDSb4DUXgAAbXzC.jpg:large

answered Sep 14 by PerduGames (139 points)
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.