Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utils.detectVideoAlphaMode #9321

Merged
merged 1 commit into from
Apr 7, 2023
Merged

Conversation

dev7355608
Copy link
Collaborator

Description of change

As you might know, for no good reason, under some circumstances video alpha is already premultiplied by whatever is responsible for uploading the pixels to the GPU. My suspicion is that it is a bug in ANGLE. If I set the ANGLE backend is set to OpenGL, then the video is uploaded as expected: unless the alpha mode is UNPACK, the video is not premultiplied on upload. If the ANGLE backend is set to D3D11 in Chrome, then (on my machine) the video is already premultiplied: so, if the alpha mode is UNPACK, if is premultiplied twice (but there is another bug: if the video dimensions are 1x1 pixels, then no extra premultiplication is applied in Chrome; in Firefox with the D3D11 backend 1x1 behaves like any other dimension). To workaround this issue I wrote a function that checks whether a video is premultiplied without premultiply on upload, in which case the alpha mode PMA is returned instead of UNPACK.

This has been a widespread issue for years. But I can't find a bug report for this in the Chrome and ANGLE issue tracker. I think, it might go unnoticed a lot of the times: the developers/artist machine might render it correctly and the user doesn't know what the asset is supposed to look like. For a long time I thought it the assets might have been generated with premultiplied alpha by mistake; that's also what the author of #7836 thought, but the asset is actually encoded with straight alpha as it should be.

I'd like to combine this with #9314, so that the video loader uses utils.detectVideoAlphaMode() by default if alphaMode isn't specifically requested.

  1. View test in Chrome.
  2. Go to chrome://flags.
  3. Search for Choose ANGLE graphics backend.
  4. Switch between D3D11 and OpenGL.
Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 1, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f65016d:

Sandbox Source
pixi.js-sandbox Configuration

@bigtimebuddy bigtimebuddy added this to the v7.3.0 milestone Apr 3, 2023
Copy link
Member

@GoodBoyDigital GoodBoyDigital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@GoodBoyDigital GoodBoyDigital added the 💞 Migrate to v8 This PR needs to be migrated to v8 label Apr 4, 2023
@bigtimebuddy bigtimebuddy added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Apr 7, 2023
@bigtimebuddy bigtimebuddy merged commit a348b85 into dev Apr 7, 2023
2 checks passed
@bigtimebuddy bigtimebuddy deleted the feature/detectVideoAlphaMode branch April 7, 2023 12:14
@Zyie Zyie removed the 💞 Migrate to v8 This PR needs to be migrated to v8 label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants