Jump to content

Parallax scroller very much slows down on the phone


Recommended Posts

        const width = window.innerWidth;
        const height = window.innerHeight;
        const imgWidth = 3500;
        const imgHeight = 1589;
        const app = new PIXI.Application(
            transparent: true
        const u = new SpriteUtilities(PIXI);
        const bg = u.tilingSprite("./src/bg.png", imgWidth, imgHeight);
        imageScale({imgWidth, imgHeight}, bg);

        function parallaxFn() {
          bg.tilePosition.x -= 5;

        function imageScale({imgWidth, imgHeight}, sprite) {
          const widthRatio = width / imgWidth;
          const heightRation = height / imgHeight;
          sprite.scale.x = widthRatio;
          sprite.scale.y = heightRation;

i use 


And I have (see image file) after one minute, this only on mobile


Link to comment
Share on other sites

  • 1 month later...

TilingSprite uploads transformation matrix to GL uniform. The problem is that the precision of operations with floats on shader-side is low compared to our good old 32-bit floats. The biggest numbers are in matrix, the bigger quantifier of numbers that shader computes - you see this picture above. The fix is to trim the number before it becomes too big.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...