0 votes
shader_type canvas_item;
uniform sampler2D noise;
void fragment() {
    vec2 uv = vec2(UV.x + TIME, UV.y);
    COLOR.rgba = texture(TEXTURE, uv).rgba;

Here is some very simple shader code that causes the texture to scroll. But it does not work when I pass in my own texture unless I stop animation. Which makes me think it has something to do with texture repeating and sampler2D? Because repeating needs to be enabled to use time in shader? idk

Does anyone know how to make this work in 4? some kinda sampler2d repeat hint? or idk? Maybe a bug? But someone must have got this working by now?

Please and thanks.


enter image description here

Godot version v4.0.alpha2.official [79077e6c1]
in Engine by (1,869 points)

ViewportTexture repeat flag has no effect #36820

maybe related?

2 Answers

0 votes
Best answer

some kinda sampler2d repeat hint?

uniform sampler2D noise: filter_nearest, repeat_enable;

by (1,869 points)
+1 vote

i'm no expert of shader, but isnt the UV supposed to be between 1 and 0?
I suppose your code works in a repeated texture because somehow the UV.x>1 is going to look at the texture "on the right", but it a normal texture it caps the values at 1.

If you notice, for every UV.x>1, it consider UV.x=1. In fact the resulting picture became equivalent to the right border of the original picture

by (1,459 points)

thanks. ya i guess that is why repeat is needed.

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 Frequently asked questions and 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 [email protected] with your username.