Skip to content

Feature: TexturesΒ #2

@cszach

Description

@cszach

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:

  1. 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.
  2. Texture atlas: pack textures inside a large texture for lookup at runtime.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions