Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fr = `uniform sampler2D aTex;
- uniform sampler2D bTex;
- uniform float mixVal;
- varying vec2 vTextureCoord;
- vec4 getColorAtProgress(float progress) {
- float smoothedProgress = progress * progress * progress;
- float zoom = 1. + smoothedProgress * 3.;
- return texture2D(aTex, (vTextureCoord - vec2(0.5)) / zoom + vec2(0.5));
- }
- const int sampleCount = 20;
- const float blurAmount = 0.2;
- void main() {
- vec4 accumulatedColor = vec4(0.);
- float accumulateCount = 0.;
- for (int i = 0; i < sampleCount; i++) {
- float sampleIndex = float(i) / float(sampleCount);
- float progressNeg = sampleIndex * blurAmount;
- float progress = max(0., mixVal - progressNeg);
- float mult = max(0., 1. - abs(2. * sampleIndex - 1.));
- accumulatedColor += getColorAtProgress(progress) * mult;
- accumulateCount += mult;
- }
- vec4 aColor = accumulatedColor / accumulateCount;
- vec4 bColor = texture2D(bTex, vTextureCoord);
- float mixAmount = smoothstep(0.8, 1., mixVal);
- gl_FragColor = mix(aColor, bColor, mixAmount);
- }`;
- ff = new PIXI.Filter(null, fr, {
- aText: cr.sprites[0].texture.baseTexture,
- mixVal: .5,
- bText: cr.sprites[0].texture.baseTexture,
- })
- cr.container.filters = [ff];
- cr.updateCanvas();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement