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 alpha decode bug #792

Open
attilaz opened this issue May 17, 2016 · 3 comments
Open

pvrtc alpha decode bug #792

attilaz opened this issue May 17, 2016 · 3 comments
Labels

Comments

@attilaz
Copy link
Contributor

attilaz commented May 17, 2016

I have a problem when using pvrtc decompression in bgfx. When I am using pvrtc textures with gles2 extension the texture alpha looks fine, but when it is decompressed with decodeBlockPtc14A it is wrong.
RGB channels are ok.
See attached image:

decals

The right picture shows my attempt to fix it with modifying
https://github.com/bkaradzic/bgfx/blob/master/src/image.cpp#L2250
and https://github.com/bkaradzic/bgfx/blob/master/src/image.cpp#L2268 to
*_a += 255 * _factor;
The results seems better but far from perfect...

Here is our pvr with alpha. ( the images above only shows a circle/star part of the whole decal)
decals.zip

@bkaradzic bkaradzic added the bug label May 17, 2016
@bkaradzic
Copy link
Owner

Are you using PVRTexTool?

Also can you try with this texture:
https://github.com/bkaradzic/bgfx/blob/master/examples/assets/textures/alphatest.png

bkaradzic added a commit that referenced this issue May 19, 2016
@attilaz
Copy link
Contributor Author

attilaz commented May 20, 2016

I am using PVRTexTool for compression.

Thanks for the fix. It is much better, but there are still slight differences.
I have checked the rgb channels more thoroughly to see if this is some kind of precision issue, but I haven't found any difference. So rgb looks exactly the same.

diff

@attilaz
Copy link
Contributor Author

attilaz commented May 26, 2016

I think I found the solution. It seems the punchtrough value was incorrect.
This https://github.com/bkaradzic/bgfx/blob/master/src/image.cpp#L2298
should be this: const bool punchthrough = !!(bc[4] & 1);

And the change (ea67fa4)

at this line (https://github.com/bkaradzic/bgfx/blob/master/src/image.cpp#L2115) should be reverted.
The original 0,0 for alpha was good. It caused problem because of the invalid punchtrough values.

I compared multiple image with this fix. I have only found slight intensity differences. In rgb it is hardly noticable, In alpha it is more visible. It seems like the rounding or something like this is done differently? I have attached the result of conversion from ptc1a -> rgba8 with pvrtextool and bgfx.

decomp.ZIP

@bkaradzic bkaradzic changed the title pvrtc alpa decode bug pvrtc alpha decode bug Nov 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants