Skip to content

Support for exporting aoMaps and the second UV channels#8728

Open
tanaydimri wants to merge 2 commits into
playcanvas:mainfrom
tanaydimri:fix-issue-8727
Open

Support for exporting aoMaps and the second UV channels#8728
tanaydimri wants to merge 2 commits into
playcanvas:mainfrom
tanaydimri:fix-issue-8727

Conversation

@tanaydimri
Copy link
Copy Markdown

@tanaydimri tanaydimri commented May 14, 2026

Description

While testing out the GltfExporter with an asset that had maps in any other UV channel than 0, the exported GLB would not contain this map at all. Also noticed that the aoMap was not included in the textureSemantics (which seems to drive what will be exported), causing the AO maps to be ignored altogether.
Fixes Issue: #8727

Fixes

Fixes some bugs in GltfExporter where:

  1. any texture map assigned to a non-zero UV channel (e.g. aoMapUv = 1) would not export as expected.
  2. aoMap was missing from textureSemantics, causing it to not export at all. Was this by design? I couldn't anything mentioning why this was left out.
  3. TEXCOORD_1 is no longer incorrectly stripped when stripUnusedAttributes: true is used together with a map assigned to a non-zero UV channel.

You can try it out by exporting this glb with the existing playcanvas build vs the build from this PR
playcanvas_glb_export_test.zip

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

@Maksims
Copy link
Copy Markdown
Collaborator

Maksims commented May 14, 2026

Per specs, aoMap should be called occlusionTexture.

@tanaydimri
Copy link
Copy Markdown
Author

tanaydimri commented May 14, 2026

Per specs, aoMap should be called occlusionTexture.

Hi @Maksims
I believe that is already taken care of by this call? The parameters for what to check in the playcanvas scene vs what's written out to the GLB seem different here. From what I could tell, textureSemantics, which is what I added the aoMap entry for is only used for collecting resources from the scene.

Unless I misunderstood what you said...

@Maksims
Copy link
Copy Markdown
Collaborator

Maksims commented May 14, 2026

My appologies if I took it out of context, just saw in PR mention of aoMap, and do remember that in GLTF specs it was occlusionTexture. So commented just to make sure. And yes, the call you've mentioned - does what you say. So all seems great!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes glTF exporter bugs related to materials using non-zero UV channels and missing AO map export. Texture infos now emit a texCoord matching the material's <map>Uv setting, aoMap is added to the recognized texture semantics (so it gets collected and considered for stripping), and the stripUnusedAttributes logic now keeps a TEXCOORD_n whenever any material texture references that exact UV index.

Changes:

  • Add aoMap to textureSemantics so the AO texture is collected and not stripped.
  • In attachTexture, read <semantic>Uv from the material and write it to the texture info as texCoord.
  • Rewrite the TEXCOORD_n retention check in createPrimitive to compare the material's <semantic>Uv against the attribute's index instead of relying on Tiling.uv.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/extras/exporters/gltf-exporter.js Outdated
Comment on lines +358 to 361
index: textureIndex,
texCoord: textureTexCoord
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvaligursky I am not sure if this is necessary? I am guessing this would only save a single line per material. But I don't see any harm leaving it in there. Just in case a GLTF viewer doesn't set it to 0 by default.
I can definitely make the change if you think I should...

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants