1.代码
#define PI 3.1415926
vec2 Twist(vec2 uv){
vec2 center = vec2(0.0,0.0);
float dist = distance(uv, center);
float theta = atan(uv.y, uv.x);
float strength = 1.0 - smoothstep(0.0, 1.0, dist);
vec2 offset = vec2(sin(theta), cos(theta)) * strength;
return uv + offset;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
// 定义贴图坐标
vec2 uv = fragCoord / iResolution.xy;
uv -= 0.5;
uv = Twist(uv);
vec3 c = texture(iChannel0, uv).rgb;
fragColor = vec4(vec3(c), 1.0);
}
正常的图片
扭曲后的: