Skip to content

Conversation

roguesaloon
Copy link

@roguesaloon roguesaloon commented Aug 31, 2025

This is a small change that is useful for our workflow (and likely others), to allow the GLTF import Scale Factor to be axis independent.

This allows an easy way to fix any assumptions that the modelling application might have made about co-ordinate space in a non-destructive way on import without changing any of the core logic around how GLTF calculates the co-ordinate space (Y-Up, Z-Forward). It also allows for much rarer scenarios where you might want to scale any axis with differing scale factors.

Existing behaviour is maintained fully, with new independent scaling behaviour being exposed in the UI as a simple check box:

image

@CLAassistant
Copy link

CLAassistant commented Aug 31, 2025

CLA assistant check
All committers have signed the CLA.

@hybridherbst
Copy link
Collaborator

Thanks for the PR!

Can you share a file or files where this is necessary? Coordinate system changes should never be needed in a strict standard such as glTF, unless the exporting application does something wrong.

I believe for custom workflows this would be better to be in a plugin – shipping it as general feature has far to big risk for people messing up their pipeline.

@roguesaloon
Copy link
Author

roguesaloon commented Aug 31, 2025

Thanks for the PR!

Can you share a file or files where this is necessary? Coordinate system changes should never be needed in a strict standard such as glTF, unless the exporting application does something wrong.

I believe for custom workflows this would be better to be in a plugin – shipping it as general feature has far to big risk for people messing up their pipeline.

It's probably less about the application (blender in our case), and more about assumptions made when creating the model. We were previously using UniGLTF which likely doesn't conform to the glTF standard as "strictly", we switched over to UnityGLTF to make use of the richer feature set (but still use UniGLTF for VRM).

UniGLTF has a setting (in unity preferences), that is on by default, Default Invert axis: X, so when we changed over to use UnityGLTF some of our models were now facing backwards (like they had been rotated 180 degrees around the X-axis) because they were expecting a different Z-Forward direction. I looked into implementing a workaround to allow us to "fix" these models from the unity side on import (without needing to apply custom transforms directly to the game object in unity).

The more "correct" approach might have been to go into blender and apply the transforms there and then re-export with the strict glTF aligned co-ordinate system in mind, but we also found that a bit confusing to work with as blender uses a right handed co-ordinate system with Z-Up, Y-Forward. As we weren't even seeing entirely consistent results with the same model and different glTF importers (UniGLTF vs UnityGLTF), the implementation in this PR seemed like a fair solution to me (especially as it doesn't change existing default behaviour at all, and ultimately just adds flexibility).

As for creating this as an external import plugin for our workflow, that might be possible and I can take a look into it. However I'm not entirely sure that all the right hooks are exposed to be able to implement this cleanly as a plugin (Though I might be wrong on that).

@hybridherbst
Copy link
Collaborator

hybridherbst commented Aug 31, 2025

Thanks for providing the extra info here!

I think a plugin would make the most sense here, as a viable workaround for you not wanting to fix the actual models, which is understandable if there's many of them.

UniGLTF is sadly not very spec-compliant (I have opened issues there in the past about that). Especially 180° rotation around Y is something that, sadly, some exporters get wrong; mostly the issue comes from the fact that some exporters approximate the glTF X-flip with 180° rotation around Y, which is wrong.

@robertdorn83 could you make a mini example plugin for this kind of conversion on import, for demonstration?

@robertdorn83
Copy link
Collaborator

Hey! Here a very basic plugin for editing the transforms and mesh vertices on import. I'm not sure what exactly needs to be fixed with your models, so i'm sure you need to modify it for your needs :)

By default, this plugin is disabled. So you can enabled it in the Project Settings > UnityGltf > Import, or per Glb Asset like in this screenshot:
image

FlipXImportPlugin.zip

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.

4 participants