# Create custom mipmap for custom GLSL shader

**URL:** <https://forum.babylonjs.com/t/create-custom-mipmap-for-custom-glsl-shader/50372>\
**Category:** Questions\
**Created:** [May 8, 2024, 4:36am UTC](https://forum.babylonjs.com/t/create-custom-mipmap-for-custom-glsl-shader/50372 "2024-05-08T04:36:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![J11](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/j11/32/3589_2.png) [@J11](https://forum.babylonjs.com/u/J11)\
**Post date:** [May 8, 2024, 4:36am UTC](https://forum.babylonjs.com/t/create-custom-mipmap-for-custom-glsl-shader/50372/1 "2024-05-08T04:36:23Z")

</div>

I am trying to create a mipmap texture load with my custom GLSL shader  
here is what I got:  
`new BABYLON.Texture` can provide the mipmap and I am able to load it with  
`vec4 cd= texture(myLoadTx, vec3(clamp_uv_inv, miplevel));`  
however I would like to replace the mipmap with certain levels, is there a way to handle it?  
for example: get the mipmap data with javascript and replace it with another image

or is there way around it? but be able to customize the mipmap is needed!  
I saw this one: [https://sbcode.net/threejs/custom-mipmaps/](https://sbcode.net/threejs/custom-mipmaps/)

can I do something like that?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 8, 2024, 10:24am UTC](https://forum.babylonjs.com/t/create-custom-mipmap-for-custom-glsl-shader/50372/2 "2024-05-08T10:24:25Z")

</div>

Babylon doesn’t directly allow providing custom mipmaps like three.js does. We mostly rely on GL’s generateMipmaps to create those. However, it is possible, though it requires calling internal functions:

[Custom mipmaps using engine internal functions | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#8WDXD8)

Zoom out to see the effect. I took the liberty to copy the texture creation function from the three.js demo 🙂

---

<div class="post-metadata">

**Author:** ![J11](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/j11/32/3589_2.png) [@J11](https://forum.babylonjs.com/u/J11)\
**Post date:** [May 9, 2024, 2:50am UTC](https://forum.babylonjs.com/t/create-custom-mipmap-for-custom-glsl-shader/50372/3 "2024-05-09T02:50:25Z")

</div>

Thank! I will check it out
