美文网首页
Godot Shader特效:UV旋转动画

Godot Shader特效:UV旋转动画

作者: 吃烧烤的老王 | 来源:发表于2019-07-25 18:15 被阅读0次

    实现这个效果,用GDScript的话只要一行代码就可以解决;用Shader做的话需要一些线性代数知识,扩展性相对差一些,不过如果像逻辑和表现解耦合或者减少CPU运算的话可以考虑这个实现方式

    效果图
    UV旋转动画
    代码如下
    shader_type canvas_item;
    render_mode unshaded;
    uniform float pivot_x : hint_range(0.01,0.99) = 0.5;
    uniform float pivot_y : hint_range(0.01,0.99) = 0.5;
    uniform float angular_speed  = 1.0;
    void vertex(){
        vec2 pivot = vec2(pivot_x, pivot_y);
        float rot = TIME * angular_speed; 
        UV -= pivot;
        UV *= mat2(vec2(sin(rot), -cos(rot)),
                   vec2(cos(rot), sin(rot)));
        UV += pivot;
    }
    

    相关文章

      网友评论

          本文标题:Godot Shader特效:UV旋转动画

          本文链接:https://www.haomeiwen.com/subject/vxfkrctx.html