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

Constant alpha = 255 and/or color is not reproduced using BC7 transparency modes #15

Open
alecazam opened this issue Jul 15, 2022 · 2 comments

Comments

@alecazam
Copy link

alecazam commented Jul 15, 2022

This is releated to this issue that still remains on BC7enc. I updated to BC7enc_rdo. This affects BC7 encoded textures.
richgel999/bc7enc#3

When pbit = 0 is chosen in the following call, the alpha reconstruct can only go to 254. This doesn't match the fully opaque textures that we are processing. We don't have this issue with ETC/ASTC encoder. For now, we'll workaround at the shader level and assume 254/255.0 is opaque when BC7enc is used.

I tried forcing use of pbit = 1 for opaque textures. This results in correct fully opaque textures, but on a red-black checkerboard, the pbit of 1 results in 255,1,1,255 as the final color, when it should be 255,0,0,255. This transparent mode that is chosen seems to be incapable of reproducing the original texture accurately. The pbit limits the reproduced rgba components - even pbit results in even, and odd pbit results in odd values. So bc7enc probably needs to support one of the opaque mode, where the color bits don't affect the alpha.

static uint64_t find_optimal_solution(uint32_t mode, vec4F xl, vec4F xh, const color_cell_compressor_params *pParams, color_cell_compressor_results *pResults)
{
....
	  for (int p = pParams->m_has_alpha ? 0 : 1; p < 2; p++)
@alecazam alecazam changed the title Constant lpha = 255 is not reproduced with transparency modes Constant alpha = 255 and/or color is not reproduced using BC7 transparency modes Jul 15, 2022
@castano
Copy link

castano commented Aug 17, 2022

Alec, you may want to look at the changes in this branch:
CoriolisStorm@d651cfd
I think this does the "force pbit to 1" solution you suggest, but as you point out introduces error in other channels.

@richgel999
Copy link
Owner

Got it - it's clear I need to revisit this problem.

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

3 participants