Why does Unity-Exporter re-encode all the textures to PNG/KTX2?

Hi there!

Babylon Unity Exporter re-encode all the textures and moreover only as PNG or KTX2.
I’m not sure to understand why.
Could we preserve the original format (like JPEG)?
Thank you!

Hi @metafred, pinging @MackeyK24 who is behind the Unity Exporter. Maybe he has some thoughts on this.

First of all… I re-encode ALL texture assets with a GLSL Shader… This allows me support pretty much any texture types including PSD.

I only make png, because i opted for the best source to go to KTX2…

I dont do jpeg because is way easier for my to take that png and go to KTX2
as well as the PACKED RGBD stuff i do for the all HDR to LDR stuff i do for stuff like lightmaps

So i dont do JPEG

Sorry… :frowning:

I hear the blender GLTF support has come a long way… If JPEG is a requirement… you might wanna check out the blender exporter

Hi @MackeyK24

Thanks for your reply. I use the babylon toolkit because of the great light baking of unity editor. So i don’t feel using Blender for now.
I tried to relink the png to the existing jpg but I failed. For example, the skybox turns all blue. Any tip?

Thank you!

What do you mean re link the png ?

What is your main problem, you absolutely have to have jpg or something?

As the exporter saves all the jpg to png, the total weight of my textures is more than doubled. So once the scene was exported, we tried to replace the png with the original jpg. Does that make sense?

Hi @MackeyK24, say I’d like to add support for Jpg texture, I’d like to make the exporter export the jpg file format is that possible ?
Right now I’have two ideas, whether it’s possible to support Jpg by adding that in the toolkit or manually modify the textures after the object is loaded [this one will be tedious but definitely] !
Do you have any suggestion ? Thanks again for the toolkit !

Alright… Best i can do for you is:

First, ALL TEXTURES still get re-encoded using the OpenGL Shader… NOT GOING TO CHANGE THAT.

But i changed the the PNG image option to DEFAULT.

So the default image type will be PNG. But if the source image for the texture is a RGB24/DXT1 texture type in unity (For example a JPEG image)… It will save as a JPEG… The jpeg size will be determined by the Texture Image Quality setting.

Here is a screen shot from upcoming toolkit with JPEG support…

Still it WONT be the same exact JPG file you specify on the texture because that file will get re-encoded by the shader… but you can control texture quality of your jpegs

That is the best i can do for you

This sound great, thank you very much !

looking forward to the new toolkit version!

OK… So i changed my mind about the default texture format.

DEFAULT will always export as RGB32 Lossless PNG

AUTO will check if the source image is RGB24/DXT1 and export as RGB24 Lossy JPEG

KTX2 will export with Basis Universal Super Compression

1 Like

Babylon Toolkit: V5.0.0-A43.1X1 now has support for JPEG Textures when using the AUTO Texture Format Type

Hi @MackeyK24
Thank for the new version.
I had no problem with the version you posted 1d ago, but with the latest version [V5.0.0-A43.1X1], I get this error. Any idea?

The newer babylon.js build are using TypeScript 4.4.2

You can update your GLOBAL install of typescript

npm install -g typescript

or the toolkit now supports LOCAL project typescript installs for the packaged babylon.d.ts
so now from your project root folder (there should now be auto generated package.json)

npm install

that will add the supported typescript compiler to the node_modules in your project root folder.

You can always in future update your package.json typescript version info and re run

npm install

Does the update with jpg support work for you ?

i finally succeeded to compile it today, and yes, my export folder is half size compared to before. big improvement ! thanks Mackey

the skybox is still in png though, quite heavy obviously. i tried skybox 6 sided / panoramic / cubemap, and same same

Final Skybox Updates - First, I ONLY SUPPORT THREE UNITY SKYBOX SHADERS:

  • Skybox/Cubemap - Formats textures using Texture Image Format (DEFAULT/AUTO)
  • Skybox/6 Sided - Formats textures as 32-Bit PNG
  • Mobile/Skybox - Formats textures as 24-Bit JPG

Note: If you PREBAKE your environment using the Babylon Toolkit: Cubemap Filter Tool

You can set more detailed options, like 512 high resolution reflections and more. It also cuts down export time for the scene because it does not have to split and encode 6 (six) skybox faces each and every time you export the scene. Huge time saver :slight_smile:

Will be available in my next Babylon Toolkit: V5.0.0-A44.1X1

it’s working like a charm, great update!
thanks Mackey!