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

Material color changes slightly during export #680

Open
markus-senger opened this issue Feb 19, 2024 · 0 comments
Open

Material color changes slightly during export #680

markus-senger opened this issue Feb 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@markus-senger
Copy link

markus-senger commented Feb 19, 2024

When a model is exported from Unity to the glb format, it seems that the material color is automatically slightly lightened.

Example:
The following model is being exported from Unity to the .glb format:

image

the following shader with the following material color is used:

image

In the next step, the model just exported is imported back into Unity, but the material color is slightly altered:

image
image

The issue occurs regardless of import during runtime or design-time.

  • glTFast version: 6.2.0
  • Unity Editor version: 2021.3.4f1
  • Render Pipeline and version: Built-in
  • Platform: Editor

export code:

          var exportSettings = new ExportSettings
          {
              Format = GltfFormat.Binary,
              FileConflictResolution = FileConflictResolution.Overwrite
          };
          var gameObjectExportSettings = new GameObjectExportSettings
          {
              OnlyActiveInHierarchy = false,
              DisabledComponents = true,
          };
          var export = new GameObjectExport(exportSettings, gameObjectExportSettings);
          export.AddScene(new GameObject[] { exportObject });

          bool success = await export.SaveToFileAndDispose(metaDataHandler.pathCAD.Replace("_cad.json", ".glb"));

import code (during runtime):

        try
        {
            success = await gltf.LoadGltfBinary(
                                            data,
                                            // The URI of the original data is important for resolving relative URIs within the glTF
                                            new Uri(orgPath),
                                            new ImportSettings()
                                        );
        } catch(Exception e)
        {
            success = false;
            UnityEngine.Debug.Log("LoadGltfBinary failed: " + e.Message);
        }

        if (success)
        {         
            GameObject model = new GameObject("ImportModel");
            model.transform.parent = cadRoot.transform;
            await gltf.InstantiateMainSceneAsync(model.transform);
            ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant