1.效果
2.原理
利用噪声纹理对需要一个色值对需要扭曲的图片进行添加uv差值。利用effect的内置函数cc_time当时间线,来达到动态的效果。
3.代码
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
alphaThreshold: { value: 0.5 }
noisetex: { value: white }
warpSpeed: {
value: 0.1,
editor: {
tooltip: '扭曲动画的速度',
range: [0.0,1.0]
}
}
warpStrength: {
value: 0.03,
editor: {
tooltip: '扭曲的强度',
range: [0.0,0.5]
}
}
}%
CCProgram vs %{
precision highp float;
#include <cc-global>
#includ