Closed zoni527 closed 2 years ago
@echadwick-wayfair I think this is referring to this image. I'm sure I've seen a PPT slide where KTX artifacts were shown magnified, but in this copy of the image they appear absent. Can you check?
Thanks for the post!
The image is genuine. Though perhaps the zoomed-in parts should be using nearest-neighbor upscaling instead of bilinear to make the differences more obvious.
The artifacts are indeed pronounced IF you're using default compression settings and only using ETC1S.
However we fine-tuned the settings after some experimentation, and shared them here: https://github.com/KhronosGroup/3D-Formats-Guidelines/blob/main/KTXArtistGuide.md#stainedglasslamp
_The textures were compressed from PNG source files using toktx via a combination of compression settings that favored high quality. UASTC was used for packed textures (ORM, Normal, etc.) and ETCS1 for Base Color and Emissive textures, however exceptions were made based on analyzing results... the glass_basecolor-alpha and glassemissive textures were changed from ETC1S to UASTC since these were prominently displayed on the model and contained a lot of color variation.
toktx compression settings: ...
Here's a live demo comparing JPG+PNG vs. KTX2, so you can zoom in and compare any area. https://playground.babylonjs.com/full.html#YD2TXP#23
I'll see about updating the image with nearest-neighbor interpolation for the zoom, I hope that's less misleading.
If you strip out full.html from the URL, it will bring you to the Babylon.js code which shows the URLs for the models.
loadModel("JPG / PNG", mask.left, "https://raw.githubusercontent.com/KhronosGroup/3D-Formats-Guidelines/main/samples/StainedGlassLamp/StainedGlassLamp-JPG-PNG-Volume.glb"),
loadModel("KTX: UASTC + ETC1S", mask.right, "https://raw.githubusercontent.com/KhronosGroup/3D-Formats-Guidelines/main/samples/StainedGlassLamp/StainedGlassLamp-KTX-BasisU-Volume.glb")
You can download the models here to check them out: https://github.com/KhronosGroup/3D-Formats-Guidelines/tree/main/samples/StainedGlassLamp
glTF.report is one nice way to see the contents of the GLBs, to check that one is using JPGs and PNGs, and the other only KTX2s.
Here's a recreation of the image, with nearest neighbor resampling. The differences are still subtle, but perhaps easier to discern.
Screenshots were made from the glTF Sample Viewer, using the "studio" IBL from the Babylon.js Sandbox, and unscaled. The zooms we scaled in Photoshop using nearest neighbor (point sampling), and the whole thing saved as a PNG to avoid JPG compression errors.
Please let us know if this resolves the issue for you, or if we can provide any further information.
Frankly we were also surprised at the results, as our initial tests showed strong block compression artifacts with a lot of bleeding between color channels. Once we fine-tuned the compression settings we were able to solve the majority of the artifacts.
It seems like the normal map is rendering a bit more pronounced in KTX2, perhaps because it's not being completely renormalized?
Big thanks to @rsahlin for his work on fine-tuning the compression settings for this asset!
I saw this demo again today, and thought of you! https://playground.babylonjs.com/full.html#YD2TXP#22\
This shows the kind of blocky KTX2 artifacts you might have seen in your compression tests. The lamp on the right was compressed using only ETC1S. It shows the importance of fine-tuning compression codecs and settings. You can pretty much eliminate these artifacts with the settings in the tutorial. I hope this helps!
Thanks so much for these detailed clarifications @echadwick-wayfair!
Thank you for these clarifications. Now I understand the asset in question a lot better, the live demo helped a bunch! I have been getting blocky artefacts also with uastc compression, but this might be due to the particular colors and scales of the textures I've been using for my assets. I'll look into the optimization possibilities further.
I have experience with ktx2 compression and was wondering about the comparison image in this document. To my surprise the two assets are identical. I find this extremely misleading and unethical as in my experience ktx2 compression creates artefacts and it would be better to be upfront about this.