Texture compression formate for desktops, specifically osx?

I am trying to experiment with compressed textures as a means of improving performance, but I’m not sure which format I need to use for my app, which is osx/windows (and trying on osx first, as that is what I am developing on) – I made a script to compress my assets based on this library GitHub - TimvanScherpenzeel/texture-compressor: CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container. which lists S3TC as the correct format for OSX / win - But it does not seem to be working, and I can’t find anything about OSX on Babylon.js Documentation – Anyone know which format I should be using for OSX?

Ok so, I’m not sure about S3TC or whatever, but the script output the files as .dxt3.ktx - I was doing 2 things wrong, needed to change the file extension to .dxt.ktx, and needed to set:

    var available = ['-astc.ktx', '-dxt.ktx', '-pvrtc.ktx', '-etc2.ktx', '-etc1.ktx'];
    var formatUsed = engine.setTextureFormatToUse(available);

At which point it will make requests to the server for -dxt3.ktx files. HOWEVER:
It’s still broken in my app. Running electron / still stuck on babylon 3.1 alpha 7 release. – Does anyone know if something changed in babylon to add support or fix a bug with those texture files? I am getting a

[29365:0105/091850:ERROR:gles2_cmd_decoder.cc(8605)] [.Offscreen-For-WebGL-0x7f8e978fc200]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.

Error whenever I try to load a compressed texture. (And here is a working example of using one of the textures my script output in a playground)

https://www.babylonjs-playground.com/#1SCH7H#23

GL version in my app is
_glVersion:"WebGL 2.0 (OpenGL ES 3.0 Chromium)
So I assume I can safely rule out electron as the problem?

Also found an issue with older chromium regarding ktx, so I updated my electron app to most recent version, which uses Chrome/69.0.3497.106 – Still same issue. So I’m thinking it’s babylon, just not sure what would have changed or how to backport it.

There were a couple of fixes on ktx in the latest version and the previous. Could you try with latest ? or create a play ground using some of the broken textures ?

So that we could pin point the issue ?

@sebvan well I don’t think the issue can be recreated on PG now since it seems to be only in my local project (on 3.1.alpha6), I’m version locked by a really nasty bug ATM, so can’t upgrade for now. But that’s helpful to know that fixes happened, maybe I can backport the fixes into my version

Are you blocked by a BJs bug? Can we help?

@Deltakosh TBH, I’m still not sure, it’s Huge performance hit after upgrading from 3.1.0-alpha3.5 to 3.1.0-alpha3.7 - Questions & Answers - HTML5 Game Devs Forum

I THINK, it’s an issue with my app that surfaced due to changes to clone behavior (or rather the helper method used within the clone method), but not an issue with babylon itself. – I spent so much time trying to figure it out unsuccessfully that I promised myself I would finish game before attempting to upgrade again. Though I suppose I’ve refactored enough since then and fixed enough other issues, that maybe I should give it another try.

Ok let us know:)

1 Like

I’m running into the same issue. Just as a test, I downloaded this example normal map:

I ran it through the texture-compressor npm module and outputted a dxt file using all defaults, but when I try and use it I get the same error.

Looking at the playground above, it seems as though the issue is still present in v4.1:

https://www.babylonjs-playground.com/#1SCH7H#23

Well in your PG you are using ktx format but you are pointing to a jpg

I think that’s the way it’s supposed to work? You reference a png or jpg, and the createTexture method subs out the extension. So in this case, it’s subbing out myfile.jpg with myfile-dxt.ktx

The issue is that ktx files created with texture-compressor are not working with Babylon. If you look at the code for that library, it’s just a wrapper for the PVR Tex tool, and the same files work with ThreeJS.

EDIT: I just referenced this PG because the actual files I’m working with are IP and I can’t share them :slight_smile:

Ok so thats why :slight_smile:

Pinging @sebavan if he has a few cycles

Thanks :slight_smile:

I searched for this issue and found that someone had already discovered the same problem so I just piggybacked on this thread :slight_smile:

1 Like

it is because by default Babylon use mipmaps (opposite of three), and you need to disable them on this texture: https://www.babylonjs-playground.com/#1SCH7H#33

Most of the time they would be needed :slight_smile:

2 Likes

Yep, that solves the problem. So mipmaps won’t work with KTX? Or the KTX has to be created with mipmaps as a setting?

Answered my own question. In texture-compressor, there’s a flag for mipmaps. Set that to “true” and that also solves the problem.

2 Likes

yup you can not generate mip maps at runtime if the base level is compressed.

1 Like

Not a direct answer, but I’d recommend looking into using basis compression instead, as that’s what I ended up doing and it’s been great so far