Godot Version
4.3
Question
I am trying to make a wave shader on the player sprite, where If (UV.x < 0.5), then it switches between two colors. I want the UV to not rotate when the player rotates. Is there anyway to do this?
4.3
I am trying to make a wave shader on the player sprite, where If (UV.x < 0.5), then it switches between two colors. I want the UV to not rotate when the player rotates. Is there anyway to do this?
Do you have some shader code you are already trying that I can see?
I hope I am understanding your ask and I am not the best with shaders but here it goes. I THINK the screen space won’t be affected by the Player’s movement/rotation and I THINK you can do something like this to get what you need in the shader:
// Transform the UVs to avoid rotation with the player sprite
vec2 screen_uv = (FRAGCOORD.xy / SCREEN_PIXEL_SIZE) / SCREEN_SIZE;
// Apply conditional logic based on the x-coordinate of the screen space UV
if (screen_uv.x < 0.5) {
// Switch between two colors, for example red and blue
COLOR = vec4(1.0, 0.0, 0.0, 1.0); // Red color
} else {
COLOR = vec4(0.0, 0.0, 1.0, 1.0); // Blue color
}
I have not tested this and some of my Godot shader code may be a little outdated since I haven’t dealt with Shaders in a good while and I really don’t like messing with them LOL but hope this may help get you in the right direction.