donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.38k stars 149 forks source link

Creating texture atlases #230

Open tiivik opened 3 years ago

tiivik commented 3 years ago

I'm looking for a module that can help create texture atlases for gltf assets by merging textures per channel (diffuse, normal ..) and therefore reducing the number of draw calls required to render a model.

I've come across the module @gltf-transform/atlas that seems to have been moved to this repository, however, I was unable to find references to atlas generation functionality from the documentation.

Is atlas generation still part of glTF-Transform or are there any alternatives that I could look at?

Thanks!

donmccurdy commented 3 years ago

Hi @tiivik! The @gltf-transform/atlas package was part of a much earlier version of this library, but never developed enough that it was particularly useful. It was eventually removed in https://github.com/donmccurdy/glTF-Transform/commit/e7d28152a3997b7cbbbb3dcb6cd4f3985f76148c, see https://github.com/donmccurdy/glTF-Transform/issues/8 for a little more information. I'd be glad to see the feature back in the library, but I don't have plans to work on it.

Libraries like TextureMerger seem promising for the mechanical bits of packing textures, and could be applied in userland code, but turning that into a tool that makes good choices about arbitrary glTF files requires non-trivial design and testing. For example, most users probably don't want their textures to exceed some size limit (2K or 4K), and ideally textures sharing the same UV channel (i.e. texCoord) on the same texture material would receive the same UV transform after packing (this is important for three.js, at least).

If this did come back in would become part of the @gltf-transform/lib package; I've moved away from having individual packages for specific functions, for easier maintenance.

tiivik commented 3 years ago

@donmccurdy Thanks a lot for the details! I briefly checked TextureMerger which might be adaptable to my use case, thanks for sharing.