Missing BC7 support

I discovered that jMonkeyEngine 3.4 does not support the BC7 compression of DDS textures. This compression, introduced with DirectX11, provides the best quality.

If anybody is willing to take the (summer?) challenge, I’ll beta test it.
Here is the error that you get when you try to load a BC7 texture:

com.jme3.asset.AssetLoadException: An exception has occurred while loading asset: ...
Caused by: java.io.IOException: Unsupported DX10 format: 98

	at com.jme3.texture.plugins.DDSLoader.loadDX10Header(DDSLoader.java:149)
	at com.jme3.texture.plugins.DDSLoader.loadHeader(DDSLoader.java:231)
	at com.jme3.texture.plugins.DDSLoader.load(DDSLoader.java:121)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
	... 18 more

This is the reference C code from Microsoft, not sure if useful:

1 Like

Can you provide any file samples? Maybe it’ll ease up this task a bit…

Created an issue and added a zip file with a PNG and its BC7 equivalent:

4 Likes

Aside from texture flipping, BC7 is now fully supported in “master” branch, which means it will be included in JMonkeyEngine v3.5.

5 Likes

On JME 3.5 alpha1 I get

Uncaught exception thrown in Thread[jME3 Main,5,main]
IllegalArgumentException: No flip support for texture format BC7_UNORM

is it because Add support for texture flipping of BC4 and BC5 signed formats · Issue #1623 · jMonkeyEngine/jmonkeyengine · GitHub is not part of alpha1 but instead will be included in alpha2?

1 Like

Looks like flipping BC7 textures is not supported.

But I made my assets with Compressonator BC7 options, the same tool @tonihele used to try it out… What am I missing?

Afaik BC7 decoding is supported but flipping it is not supported.

Edit:
Maybe try setting the texture flag flipping to false and see if it works.

1 Like

Yep, Texture2D t = (Texture2D)assetManager.loadTexture(new TextureKey(“myTexture.dds”, false));

Unfortunately flipping those is rather complex so it is not implemented.

1 Like

My BC7 without flipping are drawn upside down. I’ve checked Compressonator but I can’t find an option to convert texture in “unflipped” form… any suggestion? Thanks!

You are converting PNGs, right? Flip, convert to BC7, open a beer and enjoy! This is either way a little faster. All flipping is done in Java code before uploading the data to GPU, so there is a small performance penalty with jME flip.

So I should flip vertically with GIMP or what? Anything that can be batched?

GIMP or some flipper. I’m sure there are plenty of these simple tools. Or even just use Windows’ own https://www.thewindowsclub.com/how-to-bulk-rotate-images-in-windows.

Please note that most of these tools are useless because they rotate, rather than flip, the image :wink:

Now, a bit of theory behind this code:

Texture2D t = (Texture2D)assetManager.loadTexture(new TextureKey(“myTexture.dds”, false));

If I understand correctly, I disable the flipping on the assetManager, meaning that by default all image are flipped at runtime? And by disabling this, I’m saving CPU/GPU cycles?

Edit->Transform->Flip Vertically

Thanks, actually I used GitHub - rkalla/imgscalr: Simple Java image-scaling library implementing Chris Campbell's incremental scaling algorithm as well as Java2D's "best-practices" image-scaling techniques. and rolled out my own mouseless utility.

But more importantly:

Yeah, code is fine… but I always like to drop the “free photoshop in a browser” link because it’s SUPER useful and most don’t seem to know about it.

Yeah, sorry, didn’t think too much :slight_smile: But glad you got your tool going.

I don’t know if there is a global flip switch. But that only concerns one texture, the code. Not the asset manager as a whole. I guess the flipping is default since many models are for DX by default, not OpenGL. And it has become a standard way anyhow?

What comes to any CPU savings, yes, you’ll save few cycles. I doubt it is noticeable. The flipping is just Java code, with those BCx formats it is a bit complicated. Eventually the data is sent to GPU. And asset manager by default caches so the impact is very minimal I’d say, without actually measuring.

In terms of NOT flipping, the gains:

  • GPU savings, 0
  • CPU savings, very little
  • using cool encoding, priceless (you probably already know the general benefits of using BC7)
1 Like