# Exported glb reduces the texture resolution

**URL:** <https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112>\
**Category:** Questions\
**Tags:** material\
**Created:** [April 28, 2025, 10:56am UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112 "2025-04-28T10:56:38Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_East](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christopher_east/32/46301_2.png) [@Christopher\_East](https://forum.babylonjs.com/u/Christopher_East)\
**Post date:** [April 28, 2025, 10:56am UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/1 "2025-04-28T10:56:38Z")

</div>

Hi BabylonJS forumers. Thank you for creating such an incredible platform and community!

I am having a challenges with exporting a glb and maintaining the original texture resolution.

My glb has a texture of 12288 x 12288. When I load to [glb.babylonpress.org](http://glb.babylonpress.org) and exporta WebP version, the texture is always downsized to 5760.

Is there any way that I can control this and keep the maximum resolution?

I look forward to hearing from someone shortly. Many thanks!!

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 28, 2025, 12:08pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/2 "2025-04-28T12:08:02Z")

</div>

Hello and welcome!

[glb.babylonpress.org](http://glb.babylonpress.org/) is my creation 🙂

Could you share your model to check what is happening?  
Do you have the same problems if transform your model at [https://gltf.report/](https://gltf.report/) ?

---

<div class="post-metadata">

**Author:** ![Christopher\_East](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christopher_east/32/46301_2.png) [@Christopher\_East](https://forum.babylonjs.com/u/Christopher_East)\
**Post date:** [April 28, 2025, 12:26pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/3 "2025-04-28T12:26:54Z")

</div>

Hi Labris - thank you very much for your kind reply. It’s happening with all my glbs that have a 12288x12288 texture.

When I export from gltf.report, though, it keeps the high resolution. However, the texture isn’t converting to WebP in gltf.report - it’s staying as a jpeg texture.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 28, 2025, 12:31pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/4 "2025-04-28T12:31:50Z")

</div>

I will have a look, probably there is some browser limitation for conversion.  
Meahwhile you may do the same transforms in Node.js environment wiith the help of [GLTF-Transform CLI](https://gltf-transform.dev/cli) which doesn’t depend on browser, may use lossless codec and shouldn’t have such limitations.  
Also, be aware that such big textures may lead to crash on non-high-end machines.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 28, 2025, 3:58pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/5 "2025-04-28T15:58:16Z")

</div>

I wasn’t able to reproduce this issue with PNG texture 12188x8122 resolution at [https://glb.babylonpress.org/](https://glb.babylonpress.org/) - after optimization I have the same width and height of WEBP texture. How do you export your GLB from there - is it the main export button at the bottom menu bar or Inspector export button?

But I was able to reproduce this issue when exporting from [Sandbox](https://sandbox.babylonjs.com/) with the help of Inspector. In this case the texture becomes 7055x4702.  
@alexchuber , what do you think about it?

Here is my test file - [Babylon.js Playground](https://playground.babylonjs.com/#J9ZQBJ)  
To reproduce the Sandbox issue, open the Inspector

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/9/99e6ae0f050f2a37e5599c58619779d5d4501a26.png)

and export GLB.  
Texture will lose some resolution when you check the exported file in the Sandbox.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/7/972647ae32bc39f5adceddb44433c3141a4274b0.png)

---

<div class="post-metadata">

**Author:** ![alexchuber](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alexchuber/32/52000_2.png) [@alexchuber](https://forum.babylonjs.com/u/alexchuber)\
**Post date:** [April 29, 2025, 4:15am UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/6 "2025-04-29T04:15:55Z")

</div>

I am away right now, so I can’t double check this, but it might be because we use the default quality level (something like 1/2? 127/255?) when re-encoding the image. Check the parameters of ‘DumpData()’ for more info.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 29, 2025, 3:14pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/7 "2025-04-29T15:14:50Z")

</div>

Here is the small test plane mesh with 12188\*12188 texture resolution - [Babylon.js Sandbox - View glTF, glb, obj and babylon files](https://sandbox.babylonjs.com/?assetUrl=https://raw.githubusercontent.com/eldinor/ForBJS/master/12188.glb)

When exported from the Inspector, it reduces to 5760x5760.  
Still, when exporting after conversion to WEBP at [https://glb.babylonpress.org/](https://glb.babylonpress.org/), it has the same dimensions 12188x12188.  
@Christopher_East Did you solve your issue or there are any other related questions?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [April 29, 2025, 7:54pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/8 "2025-04-29T19:54:46Z")

</div>

Let me assign to @alexchuber if not urgent so she can have a look when she ll be back next Monday as it sounds like a potential bug. I can have a look if it is urgent.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [April 29, 2025, 7:54pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/9 "2025-04-29T19:54:51Z")

</div>

Assigned @alexchuber on April 29, 2025, 7:54pm UTC



---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 29, 2025, 8:24pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/10 "2025-04-29T20:24:17Z")

</div>

I don’t think it is urgent since it exists at least from Babylon 5 🙂  
Still it is strange behavior which a user shouldn’t experience with default settings.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [April 29, 2025, 8:40pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/11 "2025-04-29T20:40:43Z")

</div>

> [@labris](#):
>
> Babylon 5

The only real one 🙂

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/4/24665100b2281b689a4156e5450a35af2314b2a1.jpeg)

---

<div class="post-metadata">

**Author:** ![alexchuber](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alexchuber/32/52000_2.png) [@alexchuber](https://forum.babylonjs.com/u/alexchuber)\
**Post date:** [May 19, 2025, 6:41pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/12 "2025-05-19T18:41:26Z")

</div>

This looks like a hardware limitation related to the offscreen canvas used in `DumpData`. Even though we set the canvas size to 12188×12188, the actual `gl.drawingBufferWidth` is being limited to 5760×5760.

From the WebGL spec:

> If the requested width or height cannot be satisfied, either when the drawing buffer is first created or when the `width` and `height` attributes of the `HTMLCanvasElement` or `OffscreenCanvas` are changed, a drawing buffer with smaller dimensions shall be created. The dimensions actually used are implementation dependent and there is no guarantee that a buffer with the same aspect ratio will be created. The actual drawing buffer size can be obtained from the `drawingBufferWidth` and `drawingBufferHeight` attributes.

So when exporting via the Sandbox Inspector, the texture gets resized to fit within some hardware limits, which explains the unexpected dimensions.

Now I’m curious, though – @labris how are you converting images to WebP in your app?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [May 19, 2025, 11:49pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/13 "2025-05-19T23:49:30Z")

</div>

> [@alexchuber](#):
>
> Now I’m curious, though – @labris how are you converting images to WebP in your app?

Texture resizing and format conversion in [https://glb.babylonpress.org/](https://glb.babylonpress.org/) is performed at array level (without any offscreen canvas) and based on GLTF-Transform `compressTexture` function.

> <https://github.com/donmccurdy/glTF-Transform/blob/e35da366f1135481a154803d2ca3f3e4fd1a7d86/packages/functions/src/texture-compress.ts#L229>

Which, in turn, uses [https://www.npmjs.com/package/ndarray](https://www.npmjs.com/package/ndarray) and some of it’s [functions](https://github.com/scijs/ndarray/wiki/ndarray-module-list#file-inputoutput).

---

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [May 23, 2025, 5:41am UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/14 "2025-05-23T05:41:02Z")

</div>

The actual underlying lib used for image r/w is [ndarray-pixels](https://github.com/donmccurdy/ndarray-pixels), which uses [sharp](https://github.com/lovell/sharp) for node.js, and OffscreenCanvas for browsers.

> <https://github.com/donmccurdy/ndarray-pixels/blob/d586bbeccb2ac0736303478e5d76beb36b67883b/src/browser-get-pixels.ts#L23>

[ImageDecoder](https://developer.mozilla.org/en-US/docs/Web/API/ImageDecoder) might worth a try since it does not define a size limit in spec.

```auto

          // Create an ImageDecoder instance.
          const decoder = new ImageDecoder({
            data: file.stream(),
            type: file.type,
          });

          // Make sure decoder tracks are ready.
          await decoder.tracks.ready;

          // Decode the first available image frame.
          const frame = (await decoder.decode()).image;

          // Set canvas dimensions based on the decoded image.
          canvas.width = frame.displayWidth;
          canvas.height = frame.displayHeight;

          // Prepare an output buffer.
          const pixelCount = frame.displayWidth * frame.displayHeight;
          // RGBA pixels: each pixel uses 4 bytes.
          const outputBuffer = new Uint8ClampedArray(pixelCount * 4);

          // Use the copyTo() method to copy the frame's pixels into our output buffer.
          // We specify the desired pixel format ("RGBA").
          await frame.copyTo(outputBuffer, { format: "RGBA" });

```

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [May 23, 2025, 1:17pm UTC](https://forum.babylonjs.com/t/exported-glb-reduces-the-texture-resolution/58112/15 "2025-05-23T13:17:20Z")

</div>

Nice catch!  
Anyway, the issue seems to be related to Babylon implementation only.
