Advertisement
KoctrX

Untitled

Oct 1st, 2021
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. fr = `uniform sampler2D aTex;
  2. uniform sampler2D bTex;
  3. uniform float mixVal;
  4. varying vec2 vTextureCoord;
  5.  
  6. vec4 getColorAtProgress(float progress) {
  7. float smoothedProgress = progress * progress * progress;
  8. float zoom = 1. + smoothedProgress * 3.;
  9. return texture2D(aTex, (vTextureCoord - vec2(0.5)) / zoom + vec2(0.5));
  10. }
  11.  
  12. const int sampleCount = 20;
  13. const float blurAmount = 0.2;
  14.  
  15. void main() {
  16. vec4 accumulatedColor = vec4(0.);
  17. float accumulateCount = 0.;
  18. for (int i = 0; i < sampleCount; i++) {
  19. float sampleIndex = float(i) / float(sampleCount);
  20. float progressNeg = sampleIndex * blurAmount;
  21. float progress = max(0., mixVal - progressNeg);
  22. float mult = max(0., 1. - abs(2. * sampleIndex - 1.));
  23. accumulatedColor += getColorAtProgress(progress) * mult;
  24. accumulateCount += mult;
  25. }
  26.  
  27. vec4 aColor = accumulatedColor / accumulateCount;
  28. vec4 bColor = texture2D(bTex, vTextureCoord);
  29.  
  30. float mixAmount = smoothstep(0.8, 1., mixVal);
  31. gl_FragColor = mix(aColor, bColor, mixAmount);
  32. }`;
  33.  
  34. ff = new PIXI.Filter(null, fr, {
  35. aText: cr.sprites[0].texture.baseTexture,
  36. mixVal: .5,
  37. bText: cr.sprites[0].texture.baseTexture,
  38. })
  39.  
  40. cr.container.filters = [ff];
  41. cr.updateCanvas();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement