1.利用的函数
当x>1时,让其变为0
2.代码
#define PI 3.1415926
float quadratic(float x) {
if(x > 1.0){
return 0.0;
}
return pow(1.0 - x,2.0);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
// 定义贴图坐标
vec2 uv = fragCoord / iResolution.xy;
float v = quadratic(iTime * 0.05);
vec3 color = texture(iChannel0, uv).rgb;
// 输出颜色
vec3 c = vec3(0.0,0.0,0.0);
//从1.0 变换到 0.0
if(uv.y > v){
c = color;
}
fragColor = vec4(vec3(c), 1.0);
}
效果: