Wgpu manually specify mipmap textures

I have worked through Textures and bind groups | Learn Wgpu , which works fine.

What I want to do next is: compute the LOD on my own, i.e. custom specify: 1024x1024, 512x512, 256x256, 128x128, ... textures.

Is there a simple way to do this in wgpu ? [Link to tutorial / sample code preferred.]

Thanks!

Are you looking for something like this? https://github.com/gfx-rs/wgpu/blob/trunk/examples/mipmap/src/main.rs though it seems a bit overachieving, honestly.

If you already have the mip levels (which is pretty common in "real" game engines), you should be able to directly upload them with Queue::write_texture with each mip_level.


Edit: this is a more reasonable looking WebGPU example: https://github.com/toji/web-texture-tool/blob/main/src/webgpu-mipmap-generator.js

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.