question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visual Artifact on Odd Height

See original GitHub issue

Expected Behavior

Grid of sprites rendered the same way regardless of canvas dimensions

Current Behavior

Some sprites appear off by one pixel if the canvas has an odd height.

Even height (correct):

const app = new PIXI.Application({width: 640, height: 480, backgroundColor: 0xff0000, resolution: window.devicePixelRatio || 1,});

image

Odd height (incorrect):

const app = new PIXI.Application({width: 640, height: 481, backgroundColor: 0xff0000, resolution: window.devicePixelRatio || 1,});

image

Here you can see the red background is leaking through the grid of sprites because some of the sprites seem to be clipped by a pixel. My gut feeling is that this is some kind of coordinate system floating point rounding error?

Possible Solution

Currently my workaround is to just make sure the initial height is always an even number. The problem though is that this canvas normally has resizeTo set, and if the parent container has an odd height, this problem occurs. What’s interesting is that this problem occurs even after resizing to an even height, so long as the initial container was an odd height. If the initial container was an even height, I never see any problems, even when resizing to an odd height.

Steps to Reproduce

I will post a comment once I can get a jsfiddle working

Environment

  • pixi.js version: 5.3.3 and 5.3.7
  • Browser & Version: latest Chrome, Edge
  • OS & Version: Windows 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ivanpopelyshevcommented, Jun 2, 2021

or use linea filter filtering (scaleMode). As i said, Welcome To OpenGL.

1reaction
RPGillespie6commented, Mar 5, 2021

Understood. It’s just counterintuitive to me that a texture created from a base texture using integer dimensions:

let tex = new PIXI.Texture(base_texture, new PIXI.Rectangle(0, 0, 16, 16));

Can change or clip into adjacent pixels in the base texture later if app.stage.position x or y becomes non-integral.

If it’s not pixi.js’s fault, we can go ahead and close this issue. But it’s still a counterintuitive graphical quirk so I feel like it needs to be addressed somewhere in the stack, if not WebGL, then a note in the docs or something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Artifact on Odd Height · Issue #7252 · pixijs/pixijs
Some sprites appear off by one pixel if the canvas has an odd height. Even height (correct):. const app = new PIXI.Application({width: 640 ......
Read more >
Recognizing Artifacts in Visual Field Testing
Like any test, visual field tests can contain artifacts. The test subject is a human being, prone to being imperfect and influenced by ......
Read more >
Visual artifacts showing up on decimated model set to ...
A completely different solution would be to fake the 3 relief with a normal or height map. Share.
Read more >
Understanding Video Compression Artifacts - Component
Artifacts are first categorized by whether they're time/sequence-based (temporal) or location-based (spatial). If you can see the artifact when ...
Read more >
Visual artifacts for mesh with large coordinates in WebGL ...
Visually nothing should change as you increase x since the camera and persective are updated accordingly but as x goes above 1000 the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found