whirl.gdshader 466 B

123456789101112131415
  1. shader_type canvas_item;
  2. uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
  3. uniform float rotation = 3.0;
  4. void fragment() {
  5. vec2 uv = SCREEN_UV;
  6. vec2 rel = uv - vec2(0.5, 0.5);
  7. float angle = length(rel) * rotation;
  8. mat2 rot = mat2(vec2(cos(angle), -sin(angle)), vec2(sin(angle), cos(angle)));
  9. rel = rot * rel;
  10. uv = clamp(rel + vec2(0.5,0.5), vec2(0.0, 0.0), vec2(1.0, 1.0));
  11. COLOR.rgb = textureLod(screen_texture, uv, 0.0).rgb;
  12. }