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

(WIP) glTF export: improve material export #5762

Merged
merged 8 commits into from Nov 10, 2023

Conversation

querielo
Copy link
Contributor

@querielo querielo commented Oct 18, 2023

This pull request improves the material export in the glTF exporter.

  • added support for exporting normal maps, metalness maps, and emissive maps.
  • added support for exporting textures with texture transforms (tiling, offset, and rotation).
  • added support for exporting alpha test and alpha cutoff values for materials that use the "none" blend mode.

Please review. Thank you!

Screenshot 2023-11-10 at 14 18 22

Copy link
Contributor

@willeastcott willeastcott left a comment

Choose a reason for hiding this comment

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

This is a great contribution! It's great to see the glTF exporter get some love. Hey, @marklundin, got any idea how we can better make use of the glTF exporter in the Editor? Maybe a context menu option when right clicking on entities in the Hierarchy view?

@mvaligursky
Copy link
Contributor

related to #5001

@mvaligursky
Copy link
Contributor

The code assumes the textures have their channels matching the glTF specification here. We should test for that (materials in PlayCanvas specify which channel is used) and only export the textures if the channels match.

Ideal solution in the future would be that if the channels do not match, we build the required textures from source textures.

Also, the normal map can have this format, which we should probably warn about and not export either, till we have code to convert it:

/**
* Texture stores normalmap data swizzled in GGGR format. This is used for tangent space normal
* maps. The R component is stored in alpha and G is stored in RGB. This packing can result in
* higher quality when the texture data is compressed.
*
* @type {string}
*/
export const TEXTURETYPE_SWIZZLEGGGR = 'swizzleGGGR';

The goal here being that we can only export valid glTF and print a warning otherwise.

@marklundin
Copy link
Member

Yep great point @willeastcott, would love to surface this in a more intuitive way for users. It's a great piece of functionality and adds a lot of value. I'll have a think about this.

Great PR too @querielo 🔥

@querielo
Copy link
Contributor Author

querielo commented Oct 18, 2023

Ideal solution in the future would be that if the channels do not match, we build the required textures from source textures.

I'll fix it later when I have free time (our content is usually loaded from .glb-files).

@querielo querielo changed the title glTF export: improve material export (WIP) glTF export: improve material export Oct 19, 2023
@mvaligursky
Copy link
Contributor

Please try to avoid make this PR larger and keep it focused on the material export improvements this PR is about, as this is getting hard to review now. Follow up work is awesome, but a separate PR please.

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

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

Approving, tested and works well, well done and thanks!

@mvaligursky mvaligursky merged commit 290a7f8 into playcanvas:main Nov 10, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants