原图
效果图
VS
attribute vec4 aPos;
attribute vec2 aTexCoord;
varying vec2 vTexCoord;void main() {gl_Position = vec4(aPos.xyz, 1.0);vTexCoord = aTexCoord;
}
FS
precision highp float;varying vec2 vTexCoord;
uniform sampler2D uTexture;
uniform vec2 uSize;
uniform float uWidth;
uniform float uPercent;
uniform float uDirect; void main() {float offset = uPercent;float unitWidth = uWidth;float alpha = uDirect + M_PI_2;vec4 color = texture2D(uTexture, vTexCoord);vec2 loc_tex = vTexCoord * uSize - uSize * 0.5; float dist = (sin(alpha) * loc_tex.x - cos(alpha) * loc_tex.y);float modPixel = mod(dist , unitWidth);float showPixel = offset * unitWidth;if (modPixel < showPixel)color = vec4(.0);gl_FragColor =color;
}