Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] glTF: Support per-texture transforms in KHR_texture_transform #2929

Open
donmccurdy opened this issue Mar 25, 2024 · 2 comments
Open

Comments

@donmccurdy
Copy link
Collaborator

donmccurdy commented Mar 25, 2024

Currently the glTF KHR_texture_transform extension is only partially implemented by loaders.gl:

https://github.com/visgl/loaders.gl/blob/master/modules/gltf/src/lib/extensions/KHR_texture_transform.ts

Unless I've misread, the implementation assumes that UV vertex attribute has at most one UV transform applied to it. But the KHR_texture_transform extension is more flexible, and allows per-texture transforms. For example, a particular material may have 4 textures, all sharing TEXCOORD_0, but all transforming those UVs differently. The current implementation overwrites the (shared) UVs and cannot support this.

Ideally the texture transforms are passed to the material shader as uniforms, rather than overwriting the vertex attributes directly.

The following examples may be helpful in testing more complete support for the extension:

Archive.zip

Models in zip are sourced from:

@donmccurdy donmccurdy changed the title [Feature] Support per-texture transforms in KHR_texture_transform [Feature] glTF: Support per-texture transforms in KHR_texture_transform Mar 25, 2024
@donmccurdy
Copy link
Collaborator Author

For reference, the full implementation can get verbose, especially with support for the various KHR_materials_* extensions and their textures. three.js handles this by compiling shader variants:

https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js

@ibgreen
Copy link
Collaborator

ibgreen commented Mar 25, 2024

We may be able to detect reuse of buffers and clone them.

Loaders.gl offers a way to handle certain extensions on the CPU during loading.

Of course if we implement in luma.gl we don't need to rely on that and we can share buffers as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants