A lot of memory with GLTF

Hi! Need other advice. Do you know a tools that I can convert my texture from .jpg to .ktx2 ?
When I use GLTF-transform say this :
error: • Texture compression failed.
error: spawnSync toktx ENOENT
Thank you!

Could you report an issue on https://github.com/donmccurdy/glTF-Transform and share the file (or texture) that you can’t convert? gltfpack is another option, but both use the same library to convert JPG to KTX2, so I think the JPG might be using a compression feature that the compressor doesn’t support yet.

Even with .png is the same error. Yes, I’ll report

I try to use Basis Universal I understood that exist encoding for Desktop and Mobile, I use basisu to convert to .basis but just convert file form mobile version, Do you know a tool tu convert to .basis with BC7 encoding of the file?
By the other hand I see the example of basis and I see that just use one file and works fine for mobile and desktop, do you know the encoding? Or maybe the user Mugen87 know something about, I see that is a collaborator in this basis example and I see that is an active user. @Mugen87 can you help us ?
Thank you so much guys!

Do you know a tool tu convert to .basis with BC7 encoding of the file?

I think you’ve misunderstood – there are only two versions of .basis files, ETC1S or UASTC. They have different quality/size tradeoffs, ETC1S is smaller and lower quality. You load the .basis file on the device, and then THREE.BasisTextureLoader transcodes to whatever format the hardware needs, which could be BC7 or many others.

Did you see this example? It should automatically convert to BC7 if that is the most appropriate format for the hardware. Or there are low-level transcoders available specifically for BC7, but they are more advanced to use.

I think you’ve misunderstood

:sweat_smile: Thank you!

THREE.BasisTextureLoader transcodes to whatever format the hardware needs, which could be BC7 or many others.

I see, but do you know why when load textures in desktop load in dark ?

Oh I see, hm. No, I can’t say without looking at the demo and the texture. Can you share a demo?

If you can embed the basis textures in your glTF file it should handle a lot of things for you, but otherwise it can take a bit of understanding of compressed GPU textures to load textures this way yourself and deal with mipmaps correctly, etc.

Can you share a demo?

Yes, can you see the project here ?

If you can embed the basis textures in your glTF file it should handle a lot of things for you

Yes I’m afraid by the textures, I tried to use with blender, but I guess blender don’t support .basis. Do you know how I can embed the textures ? Do I have to do manual in the .gltf?

It’s strange because in the desktop load the skin (most biggest texture) and the hair, but in the mobiles devices just load the eyes and hair

Thank you!

I’d suggest making sure all textures are power-of-two dimensions, no larger than 2048x2048. The skin is an 8K texture, which many mobile devices won’t be able to handle. There are errors like this in the JS console that are important:

RENDER WARNING: texture bound to texture unit 0 is not renderable. It might be non-power-of-2 or have incompatible texture filtering (maybe)?

Blender doesn’t support basis textures, no. The CLI mentioned earlier in this thread can take a glTF file exported from Blender and convert it to a glTF file containing Basis (.ktx2) textures.

The CLI mentioned earlier in this thread can take a glTF file exported from Blender and convert it to a glTF file containing Basis ( .ktx2 ) textures.

But dosen’t work in my computer :frowning: Can you help me please ? Maybe you can help me with convert the gtlf files, I will find a way to reward you

If you’re having trouble installing it could you post details? I’d rather fix that if possible.

You’d need to resize the images either way I’m afraid, there’s no way around that at the moment.

Hi @donmccurdy,

I am working on glTF loader to load multiple files.
However, I am stuck in how to free up memory of the render.

Follow up here (https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects), I tried to dispose all geometry, texture and material whenever I change to load another models, but still have problem in render memory.

According to the first pic (for the 1st model), the render.info.memory.geometries = 15
But when I load the 2nd model (the second pic), the render.info.memory.geometries = 32
Actually the 2nd model only has 17 geometries and the 1st model has 15 geometries.

Thanks,

Could you share the code you’re using to dispose the original model in a new thread? It sounds like it isn’t fully being disposed, perhaps.

EDIT: Oh, I see How to free up render memory?. Let’s continue discussion there in order to keep this thread on topic.

1 Like

If you’re having trouble installing it could you post details? I’d rather fix that if possible.

Thank you sou much, you made me thing about the installation, the problem was in the executable .toktx, I had in other directory, so I change to /usr/bin/lib and gltf-transform work fine, thank you so much

By the other hand, do you kwon I can fix this ?

RENDER WARNING: texture bound to texture unit 0 is not renderable. It might be non-power-of-2 or have incompatible texture filtering (maybe)?

The eyes are the only texture that show in black in Android devices and Chrome in Mac Os, in iOS devices and Safari Mac OS looks good

Thank you!

This sounds like the issue described in A lot of memory with GLTF — textures need to use power-of-two dimensions, like 512px/1024px/2048px, and they need to be small enough that mobile devices can support them. Try to make sure that no texture is any larger than 2048px. You’ll need to resize the textures before converting them to Basis.

2 Likes

Hi @donmccurdy,

I’m trying to load a gltf model has size around 150MB ~ 200MB, and launch a web app in mobile devices.
Sounds like impossible.
Any recommendations?

Thank you!

You’ll need to optimize the glTF model further until it is within the device’s limitations. There are a number of threads about this topic on the forums and elsewhere, one good example is this thread:

But as mugen87 mentions there, optimizing requires you to understand what parts of your model are not optimized to begin with. If you need help with that, I would recommend starting a new thread and sharing information about the model you’re trying to improve.

1 Like

Thank @donmccurdy,

I also found out another thread about how to reduce the file size of glTF model which use gltf-pipeline as mugen87 suggested in this thread.
However, I’m still stuck in reducing file size of my model.

My original file is 43.4MB, but when I do:
gltf-pipeline -i MyModel.glb -o modelDraco.gltf -d
and the new file is made with 51.3MB in size.

The other option to do is:
gltf-pipeline -i MyModel.glb -o model.gltf
But the new file is 57.9MB in size.

Am I doing anything wrong?
Thanks,

Before trying to reduce the size of the model, you’ll need to figure out why it’s large to begin with. Draco compression reduces geometry size, but a model could be large for other reasons: large textures, animations, node trees, etc. The quickest way I know of to debug is with the gltf-transform inspect input.glb CLI, which should print your mesh and texture sizes.

Aside, the reason the model’s size is actually increasing in your example is because it’s being converted from .glb (binary) to a .gltf (plaintext with embedded Data URI). A better set of options, if Draco is in fact necessary for this model, would be:

gltf-pipeline -i MyModel.glb -o ModelDraco.glb -d -b

If the model has large textures (this is usually the problem) then you’ll want to unpack them, resize or compress the textures, and repack the file:

gltf-pipeline -i input.glb -o tmp.gltf --separate

// ... resize textures in whatever tool, then ...

gltf-pipeline -i tmp.gltf -o output.glb -b
1 Like

Thanks, @donmccurdy

Now I got 38.4MB in size.
I probably need to resize the textures as you said. This could be a problem.
Anw, thanks a lot! :slight_smile:

1 Like

You rocks!! Thank you so much!
I’ve resized the eyes by 2048px to 512px and works fine
Again thank you!

1 Like