效果图
代码和注释
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D texture;
const vec2 sketchSize = vec2(512., 512.);
const float barrelPower = 0.4;
const int num_iter = 10;
const float reci_num_iter_f = 1.0 / float(num_iter); // 用于迭代时归一化
/// @note 随着迭代次数增加,像素偏移更大;距离图像中心越远,像素偏移更大。
vec2 barrelDistortion(vec2 coord, float amt)
{
vec2 cc = coord - 0.5;
float dist = dot(cc, cc);
return coord + cc * dist * amt;
}
/// @note 截断到 [0., 1.] 之间
float sat( float t )
{
return clamp(