How to move the UVs over slightly?
Asked Answered
H

2

0

I'd like to be able to move my UVs over a bit in the shader. I tried doing this in the fragment shader: UV.x += 0.0161333333333; UV.y += 0.0226472; But Godot tells me constants cant be modified. I'm trying to create an effect that if a player pushes a button then the texture of an object changes, but I dont want to load a whole new texture so I figured I'd just move the UVs over a bit.

Habilitate answered 28/5, 2022 at 17:31 Comment(0)
A
0

You need to use an intermediary variant since as the error warns you, you can't modify constants.

vec2 modified_uv = UV;

modified_uv.x += 0.0161333333333;
modified_uv.y += 0.0226472;

float color1 = texture(sometex, modified_uv);

ALBEDO = color1;

Something like that.

Appealing answered 28/5, 2022 at 21:26 Comment(0)
H
0

Thank you!

Habilitate answered 29/5, 2022 at 19:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.