# No Mipmap for Basis Universal texture

**URL:** <https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403>\
**Category:** Bugs\
**Created:** [November 18, 2021, 4:30pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403 "2021-11-18T16:30:06Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mickael\_PASTOR](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mickael_pastor/32/35388_2.png) [@Mickael\_PASTOR](https://forum.babylonjs.com/u/Mickael_PASTOR)\
**Post date:** [November 18, 2021, 4:30pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/1 "2021-11-18T16:30:06Z")

</div>

Hello !

It’s been a while since my last post 😉

I come today with a question, and depending on the answer, a possible bug for the support of .basis files (I did not test .ktx2 yet).

Is mipmap supposed to be supported with .basis texture ?  
According to the [documentation](https://doc.babylonjs.com/advanced_topics/mutliPlatTextures#basis-file-format):

> The compressor is able to exploit color and pattern correlations across the entire file, so multiple images with mipmaps can be stored very efficiently in a single file.

I would say it is supposed to be supported, but according to my experimentations, it is not…  
The aliasing is clearly visible in [the example playground](https://playground.babylonjs.com/#E4VDDW), but if you go check the parameters of the texture in the inspector (which breaks the basis image by the way), you can see “has Mipmap Yes”…

I tested using both babylon 4.2 and 5.0-alpha, but both seems to have the same issue.

Thanks for your answers 🙂

---

<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 18, 2021, 4:57pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/2 "2021-11-18T16:57:35Z")

</div>

Adding @bghgary who knows a lot about basis and ktx

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [November 18, 2021, 9:25pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/3 "2021-11-18T21:25:44Z")

</div>

@DarraghBurke Can you look into the texture inspector problem? Somehow, just selecting the basis texture causes it to turn colors.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [November 18, 2021, 9:27pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/4 "2021-11-18T21:27:30Z")

</div>

> [@Mickael\_PASTOR](#):
>
> The aliasing is clearly visible in [the example playground](https://playground.babylonjs.com/#E4VDDW)

@Mickael_PASTOR Can you send some screenshots or elaborate on what you mean by this? I don’t see any big differences on my machine between the cubes.

---

<div class="post-metadata">

**Author:** ![Mickael\_PASTOR](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mickael_pastor/32/35388_2.png) [@Mickael\_PASTOR](https://forum.babylonjs.com/u/Mickael_PASTOR)\
**Post date:** [November 19, 2021, 9:21am UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/5 "2021-11-19T09:21:02Z")

</div>

Thanks for your answer!

Here is the slightly modified demo playground [https://playground.babylonjs.com/#E4VDDW#8](https://playground.babylonjs.com/#E4VDDW#8).  
(I just changed the camera and the material for the floor)

You can see the aliasing from an angle like this one:  
 ![alias3](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/2/12386340f463e785db35f558d740dcfecb824e77.gif)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 19, 2021, 12:23pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/6 "2021-11-19T12:23:03Z")

</div>

There is no mipmaps in the .basis file according to basisu.exe:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/1/e1ed99eb14fac97d37df9640ce5bacddfeb7dcb5.png)

Mipmaps must be contained inside the file, they can’t be generated at runtime for compressed formats.

---

<div class="post-metadata">

**Author:** ![Mickael\_PASTOR](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mickael_pastor/32/35388_2.png) [@Mickael\_PASTOR](https://forum.babylonjs.com/u/Mickael_PASTOR)\
**Post date:** [November 19, 2021, 1:41pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/7 "2021-11-19T13:41:11Z")

</div>

Following your post, I did my research with a colleague, and there is an option when generating a .basis image to include a mipmap [GitHub - BinomialLLC/basis\_universal: Basis Universal GPU Texture Codec](https://github.com/BinomialLLC/basis_universal) (-mipmap).

And it just works!! So it is not a bug! Maybe I am the bug…

As I read the documentation again, it clearly says:

> so multiple images with mipmaps can be stored very efficiently in a single file.

“stored” it is, it was right there, beneath my eyes from the beginning!

Thank you very much @Evgeni_Popov \<3

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [November 19, 2021, 4:36pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/8 "2021-11-19T16:36:02Z")

</div>

Maybe the sample playground should be updated with a basis file that has mips since that would match the behavior of loading the PNG.

---

<div class="post-metadata">

**Author:** ![Mickael\_PASTOR](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mickael_pastor/32/35388_2.png) [@Mickael\_PASTOR](https://forum.babylonjs.com/u/Mickael_PASTOR)\
**Post date:** [November 19, 2021, 5:43pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/9 "2021-11-19T17:43:53Z")

</div>

I might have been mislead by the playground, as there are two distinct visual aspects…

The inspector bug when inspecting the gpu compressed texture does not occur for .ktx2 images, in my case, and the `-mipmap` option has to be enabled for this format as well.

Thanks again for your answers, it’s really great to work with the engine!!

---

<div class="post-metadata">

**Author:** ![DarraghBurke](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darraghburke/32/10621_2.png) [@DarraghBurke](https://forum.babylonjs.com/u/DarraghBurke)\
**Post date:** [November 19, 2021, 8:23pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/10 "2021-11-19T20:23:05Z")

</div>

When we render a preview image in the inspector, we briefly set the texture sampling mode to nearest neighbor, before setting it back to the original sampling mode. Calling updateSamplingMode() on this texture for any sampling mode with a mips setting (eg. LINEAR\_LINEAR\_MIPLINEAR, NEAREST\_NEAREST\_MIPNEAREST) will break the texture. Other sampling modes (NEAREST\_NEAREST) are fine.

Simple repro of this here: [Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#E4VDDW#9)

This is particularly strange, because in theory, the texture already should have that sampling mode set. Why is not broken on initial load? I’m not sure. @bghgary any thoughts?

Note that it can be “unbroken” simply by setting the sampling mode to any of the functional models.

---

<div class="post-metadata">

**Author:** ![DarraghBurke](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darraghburke/32/10621_2.png) [@DarraghBurke](https://forum.babylonjs.com/u/DarraghBurke)\
**Post date:** [November 20, 2021, 1:10am UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/11 "2021-11-20T01:10:31Z")

</div>

I am trying to create a simple repro in the playground to file an issue for this, but having a hard time getting it to repro. It seems to only break when used in a PBR material, but not as diffuse for a standard material. Not sure why yet.

Also, even with a working sampling mode, the inspector preview view still doesn’t work. That may be an inspector bug.

I’ll keep looking into this next week. Thanks for bringing it to our attention!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [November 29, 2021, 3:57pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/12 "2021-11-29T15:57:53Z")

</div>

Any update?

---

<div class="post-metadata">

**Author:** ![DarraghBurke](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darraghburke/32/10621_2.png) [@DarraghBurke](https://forum.babylonjs.com/u/DarraghBurke)\
**Post date:** [November 29, 2021, 7:01pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/13 "2021-11-29T19:01:57Z")

</div>

Sorry @Mickael_PASTOR, with Thanksgiving happening last week I let this fall by the wayside for a bit. I’m looking into it right now and I’ll have issues open by the end of the day 🙂

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [November 29, 2021, 7:37pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/14 "2021-11-29T19:37:49Z")

</div>

Assigned @DarraghBurke on November 29, 2021, 7:37pm UTC



---

<div class="post-metadata">

**Author:** ![DarraghBurke](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darraghburke/32/10621_2.png) [@DarraghBurke](https://forum.babylonjs.com/u/DarraghBurke)\
**Post date:** [November 29, 2021, 11:02pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/15 "2021-11-29T23:02:02Z")

</div>

I have opened an issue here with PG repro: [Sampling modes with Mipmaps do not work correctly for basis textures · Issue #11549 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/issues/11549)

I will ask around and see if anyone is available to investigate this. Thank you for your patience!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [November 30, 2021, 4:19pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/16 "2021-11-30T16:19:21Z")

</div>

Maybe @Evgeni_Popov can have a look?

---

<div class="post-metadata">

**Author:** ![DarraghBurke](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darraghburke/32/10621_2.png) [@DarraghBurke](https://forum.babylonjs.com/u/DarraghBurke)\
**Post date:** [December 1, 2021, 10:43pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/17 "2021-12-01T22:43:26Z")

</div>

This is now resolved! Thanks @Evgeni_Popov🙂

---

<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:** [December 1, 2021, 10:47pm UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/18 "2021-12-01T22:47:16Z")

</div>

Unassigned @DarraghBurke on December 1, 2021, 10:47pm UTC



---

<div class="post-metadata">

**Author:** ![Mickael\_PASTOR](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mickael_pastor/32/35388_2.png) [@Mickael\_PASTOR](https://forum.babylonjs.com/u/Mickael_PASTOR)\
**Post date:** [December 2, 2021, 7:43am UTC](https://forum.babylonjs.com/t/no-mipmap-for-basis-universal-texture/25403/19 "2021-12-02T07:43:25Z")

</div>

Thanks guys! You guys are great!

I solved the topic with @Evgeni_Popov’s first answer because it’s the solution to the original question 🙂
