Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We lose one binary digit in UV's and its critical
This thing exists through all the life of pixi-v4, since 6 jan 2016, it leads to wrong rendering of sprites with LINEAR scaleMode (it is default!).
The thing is, for numbers like
1/1024
we always lose 1 digit, when we actually dont have to lose anything.For center pixel loss is the same for both algorithms:
Size of pixel 1/1024 is
1e-3
, one point of color is2e-2
, if we multiply it we'll get2e-5
, too close to our precision loss. Experiments show that 1 binary digit in the case is critical. We have to get rid of1.5e-5
.Lets put single pixel inside an atlas of size 1024 and render it: https://www.pixiplayground.com/#/edit/sr8e~10Ueu1aaaVlj~Rsd
We got alpha=247 and that number is even worse for size=2048. If we put the pixel to (1024,1024) instead of (1,1) we will get 251, which is still wrong!
We even lose on size=256!
You can also notice the shift in coords if we enlarge the pixel:
This is the bug we tried to fix with
PRECISION_FRAGMENT=HIGHP
. Docs say that on MEDIUMP we always have 16 binary digits which is exactly how much we use when we pack numbers in uint16.MEDIUMP (16 bits) is enough for sprite rendering, while 15 is not.