# KTX Files and DDS Environment Files

**URL:** <https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261>\
**Category:** Questions\
**Created:** [November 27, 2019, 11:57pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261 "2019-11-27T23:57:32Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 27, 2019, 11:57pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/1 "2019-11-27T23:57:32Z")

</div>

I think there is a possible bug in the implementation of the compressed texture array, although I may just be missing something.

I have created compressed versions of my textures. However, when I set my engine to use them, I get an error finding the compressed version of the environment.dds file.

`babylon.js:16 BJS - [15:47:13]: e failed when trying to load https://www.babylonjs-playground.com/textures/environment.dds, falling back to the next supported loader`

It’s looking for this:  
[https://www.babylonjs-playground.com/textures/environment-dxt.ktx](https://www.babylonjs-playground.com/textures/environment-dxt.ktx)  
Instead of this:  
[https://www.babylonjs-playground.com/textures/environment.dds](https://www.babylonjs-playground.com/textures/environment.dds)

Is there a way to exclude certain files or file types from the `setTextureFormatToUse` method?

ETA: Here’s a Playground in which you can see the issue. Watch the network tab:

[https://www.babylonjs-playground.com/index.html#1SCH7H#31](https://www.babylonjs-playground.com/index.html#1SCH7H#31)

---

<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:** [November 28, 2019, 12:38pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/2 "2019-11-28T12:38:24Z")

</div>

Unfortunately you once you set the engine to use ktx it is expecting to use it for all textures at the moment.

@Deltakosh should we smthg to autorize excluding some format to be checked as ktx ???

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [November 28, 2019, 12:46pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/3 "2019-11-28T12:46:03Z")

</div>

Yeah, when I did ktx, I don’t think there even was an environment texture. Babylon.js is now a little too complicated for me to work directly in Engine.

Loading environment first should go through, blissfully unaware of what is to come.

---

<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:** [November 28, 2019, 12:50pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/4 "2019-11-28T12:50:19Z")

</div>

Oh yeah that is a nice one 🙂 just call setTextureFormat after creating the env 🙂 I love it !!!

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 28, 2019, 3:39pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/5 "2019-11-28T15:39:14Z")

</div>

I see! For some reason that wasn’t working for me but maybe I was just not paying close enough attention. But can you point me in the direction of where that code lives? I wonder if I can take a stab at it by adding an exclusion array?

---

<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:** [November 28, 2019, 3:53pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/6 "2019-11-28T15:53:49Z")

</div>

right here: [Babylon.js/thinEngine.ts at master · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/master/src/Engines/thinEngine.ts#L2663)

You could add a global exclusion list as well ?

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 28, 2019, 9:46pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/7 "2019-11-28T21:46:36Z")

</div>

Yeah, I’ve got it working. Just figuring out how to get all the linting and tests to pass. Hopefully I’ll have a PR ready this weekend 🙂

---

<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:** [November 28, 2019, 9:50pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/8 "2019-11-28T21:50:25Z")

</div>

Nice !!! The easiest to run tests and so on is to create a PR so that we could help you with your errors if needed 🙂

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 28, 2019, 10:11pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/9 "2019-11-28T22:11:06Z")

</div>

Thanks, it’s passing all tests now, but when I run it in the local test bed it doesn’t see a new method I’ve created. I assume that’s because the d.ts files aren’t being updated somehow?

---

<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:** [November 28, 2019, 10:13pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/10 "2019-11-28T22:13:22Z")

</div>

that is strange it should all work if you do npm run build from the tools/gulp folder as it updates the .d.ts before going through the tests.

If you do this, please do not add the dist/\* files as part of your PR 🙂

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 28, 2019, 10:14pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/11 "2019-11-28T22:14:37Z")

</div>

Yeah, this code works:

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

engine['setCompressedTextureExclusions'](['.dds']);

```

So the method is there, it just doesn’t see it in the editor.

---

<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:** [November 28, 2019, 10:16pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/12 "2019-11-28T22:16:09Z")

</div>

oh in the editor this is possible, you should try to create the PR and we ll be able to look into it

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 28, 2019, 10:18pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/13 "2019-11-28T22:18:14Z")

</div>

Will do. Thanksgiving cooking awaits for now…

---

<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:** [November 28, 2019, 10:18pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/14 "2019-11-28T22:18:50Z")

</div>

Have a wonderfull thanksgiving !!!

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 29, 2019, 5:16pm UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/15 "2019-11-29T17:16:17Z")

</div>

First pass at the PR. All suggestions for improvements are very welcome!

> <https://github.com/BabylonJS/Babylon.js/pull/7231>

Also, I’m not sure why there are formatting changes. Maybe my fork got outdated by a recent commit?

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 30, 2019, 12:29am UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/16 "2019-11-30T00:29:06Z")

</div>

@sebavan thanks for helping me! Now that we’ve merged, should I see that method on the Playground? It’s in the master branch but the editor throws an error when I try and use it.

---

<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:** [November 30, 2019, 1:52am UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/17 "2019-11-30T01:52:05Z")

</div>

It will be in the next nightly in a couple of hours

---

<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:** [November 30, 2019, 2:15am UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/18 "2019-11-30T02:15:55Z")

</div>

this will be up in 15 minutes, just pushed it 😉

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://forum.babylonjs.com/u/Alex_B)\
**Post date:** [November 30, 2019, 2:54am UTC](https://forum.babylonjs.com/t/ktx-files-and-dds-environment-files/7261/19 "2019-11-30T02:54:00Z")

</div>

And here it is working 🙂

[https://www.babylonjs-playground.com/index.html#1SCH7H#32](https://www.babylonjs-playground.com/index.html#1SCH7H#32)
