-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Support for textures e.g. albedo maps, height maps, normal maps, etc. would be desirable for the MVP.
Important note: WebGPU does not support bindless textures. This means that drawing textured objects in one pass becomes non-trivial. Possible workarounds:
- Use generative WGSL code to have multiple bindings, one for each texture. Need to investigate the limit of bindings in a group and the performance.
- Texture atlas: pack textures inside a large texture for lookup at runtime.
- Use
texture_2d_array, but all textures must be the same size.
Texture atlas
The best out of all seems to be using a texture atlas, as it is a common software solution, a well-researched problem, and allows (conceptually) an arbitrary number of textures with arbitrary sizes.
The problem of generating a texture atlas is that of 2D rectangular bin packing. However, we would like to consider the dynamic version of it whenever possible, where a texture might be added or destroyed on the fly, and the texture atlas must react correspondingly. This variant of the problem is 2D rectangular bin packing with predefined gaps, or dynamic bin packing (?).
Helpful resources
- Texture atlas generator: https://github.com/oguzeroglu/TextureMerger
texture_2d_array: https://devcodef1.com/news/1193380/webgpu-textureview-and-2d-texture-array- WebGPU textures: https://webgpufundamentals.org/webgpu/lessons/webgpu-textures.html
- Dynamic texture packing question: https://gamedev.stackexchange.com/questions/114884/how-to-combine-dynamic-asset-reload-and-texture-atlases-rectangle-packing-with
- A Thousand Ways to Pack the Bin