shader_type canvas_item;
uniform float shake_intensity = 0.0;
uniform float shake_speed = 20.0;
void vertex() {
vec2 shake = vec2(0.0);
if (VERTEX.y < 0.0) {
shake.x = sin(TIME * shake_speed + VERTEX.y) * shake_intensity;
}
VERTEX.xy += shake;
}
I followed the upper code to create a shader. when I set shake_intensity >0, <0.5, the 2d viewport could shake tree correctly, but when I run it with the default shake_intensity (>0, <= 0.5) not working(The tree not shake by default). When I set default shake_intensity >0.5 , top of the sprite shaked, but bottom of the sprite does not shake. when increasing shake_intensity (0.6, 0.7, 0.8 ..) until 1.0, then more top of sprite shaked.
I dont know why it works on 2d viewport by not work when It’s running.