Skip to content

Conversation

@tonihele
Copy link
Contributor

Resolves #1619

This PR adds support for BPTC compressed textures. Namely BC6 and BC7 compressed formats. Earlier, BC1-BC5 formats were already somewhat supported, that support is now enhanced a bit by making the DDS loader support them more widely. The file format varies widely, both DX9(?) style and the DX10 style files are supported for both BPTC and RGTC (BC4, BC5) compressed textures.

The BPTC was mainlined in OpenGL 4.2. I put the constants to the EXT instead and check the capability from both the OpenGL version and the extension. There wasn't a file for GL4.2, so I didn't create one as I was little unsure how to integrate that. Therefore the GLExt houses these new constants. The version + extension checking I hope to make sure we utilize the feature even if the graphics driver doesn't give out all capabilities properly. Doesn't cost a thing...

There are some caveats. Support for flipping textures is limited. Not implemented at all for BC6 nor BC7. This is said to be extremely difficult but maybe not impossible. I can create a ticket for these flip issues.

Here is a report of findings of these formats (I used Compressonator to create these, the file formats vary wildly it seems):

  • BC1 - Ok
  • BC2 - Ok
  • BC3 - Ok
  • BC4 - Image appears as red
  • BC4_S - Image appears as red, no flip support
  • BC5 - Image colors weird
  • BC5_S - Image colors weird, no flip support
  • BC6 - Ok, no flip support
  • BC6_SF - Ok, no flip support
  • BC7 - Ok, no flip support

@stephengold
Copy link
Member

Thanks for your contribution, Toni!

@tonihele
Copy link
Contributor Author

The BC4 and BC5 image colour issue is maybe expected. Since they store the colour info on the red or the red-green channel respectively. But I'm unsure that do we need to use some swizzle or handle this in a shader separately? I don't have enough knowledge on the use cases or whatnots on RGTC textures.

@stephengold stephengold changed the title Issue 1619 solve issue 1619 (add texture-compression formats) Oct 17, 2021
@stephengold
Copy link
Member

How about providing test app(s) for this feature?

@tonihele
Copy link
Contributor Author

How about providing test app(s) for this feature?

I can try to create similar to TestLoadKtx.java. Should be sufficient. Convert the monkey texture with Compressonator.

@tonihele
Copy link
Contributor Author

Pushed a similar (but slightly refined :D ) test that I used to test these files. It includes a sample from all the BCx formats that are loaded with DDS file format.

@stephengold stephengold added this to the v3.5.0 milestone Oct 23, 2021
@stephengold stephengold merged commit 5e2350c into jMonkeyEngine:master Nov 2, 2021
@tonihele tonihele deleted the issue-1619 branch November 3, 2021 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for BC7 texture compression

2 participants