wave with rotate item


Shader code
shader_type canvas_item;

uniform float speed = 2.0;
uniform float frequency_y = 5.0;
uniform float frequency_x = 5.0;
uniform float amplitude_y = 50.0;
uniform float amplitude_x = 25.0;
uniform float inclination = 50.0;
uniform float rotation_angle = 0.0; // Angle in degrees to be converted to radians.

void vertex() {
// Convert rotation angle from degrees to radians.
float rad = radians(rotation_angle);
// Create a rotation matrix.
mat2 rot = mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad)));

// Apply rotation to the vertex position.
vec2 rotated_vertex = rot * VERTEX.xy;

// Apply the wave effect.
rotated_vertex.y += sin((UV.x - TIME * speed) * frequency_y) * amplitude_y * UV.x;
rotated_vertex.x += cos((UV.y - TIME * speed) * frequency_x) * amplitude_x * UV.x;
rotated_vertex.x -= UV.y * inclination;

// Apply the inverse rotation to the vertex position to get the final position.
VERTEX.xy = rot * rotated_vertex;
2d, under water, wave
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

math – rotate uv

Back glow effect for item backgrounds

2D Item Highlight Shader

Notify of

Inline Feedbacks
View all comments