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

PVRTC: incorrect alpha decoding #62

Open
attilaz opened this issue Aug 5, 2021 · 0 comments
Open

PVRTC: incorrect alpha decoding #62

attilaz opened this issue Aug 5, 2021 · 0 comments

Comments

@attilaz
Copy link
Contributor

attilaz commented Aug 5, 2021

pipes.zip
This image clearly shows the artifacts.

One problem seems to be the incorrect punchthrough flag. According to the specs (table 173) it is at bit 32.
https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#_format_pvrtc1_4bpp

Current values are (bc[7]&1) which is bit 56.

const bool punchthrough = !!(bc[7] & 1);

const bool punchthrough = !!(bc[7] & 1);

Other problem is that with punchthrough:
"If punch-through mode is selected, and the modulation bits for a given pixel have a value of 0b10, the alpha value of the resulting color is 0x00. This is irrespective of the presence or values of any alpha channel in the input colors."

image decoder uses s_pvrtcWeights table for weights. Outputting 0 can be implemented by settings alpha weights to 0 when punchtrough is on and modulation is 0b10.

{ 4, 4, 4, 4 },

Alpha weights are the 3. and 4. values.
So this should look like
{ 4, 4, 0, 0 },

bkaradzic/bgfx#792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant