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

IndexOutOfRangeException during Scene Export #15

Closed
Skylion007 opened this issue Mar 30, 2021 · 8 comments
Closed

IndexOutOfRangeException during Scene Export #15

Skylion007 opened this issue Mar 30, 2021 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Skylion007
Copy link

Skylion007 commented Mar 30, 2021

I tried to update the GLTF Export Plugin. It did fix scenes that were broken due to empty meshes, but it broke scenes that worked perfectly before. I am trying to export GLBs of the all the scenes in AI2Thor for reproducibility.

IndexOutOfRangeException: Index was outside the bounds of the array.
UnityGLTF.GLTFSceneExporter.ExportPrimitive (UnityEngine.GameObject gameObject, GLTF.Schema.GLTFMesh mesh) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:1014)
UnityGLTF.GLTFSceneExporter.ExportMesh (System.String name, UnityEngine.GameObject[] primitives) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:947)
UnityGLTF.GLTFSceneExporter.ExportNode (UnityEngine.Transform nodeTransform) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:662)
UnityGLTF.GLTFSceneExporter.ExportNode (UnityEngine.Transform nodeTransform) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:687)
UnityGLTF.GLTFSceneExporter.ExportNode (UnityEngine.Transform nodeTransform) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:687)
UnityGLTF.GLTFSceneExporter.ExportScene (System.String name, UnityEngine.Transform[] rootObjTransforms) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:589)
UnityGLTF.GLTFSceneExporter.SaveGLBToStream (System.IO.Stream stream, System.String sceneName) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:259)
UnityGLTF.GLTFSceneExporter.SaveGLB (System.String path, System.String fileName) (at Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs:216)
GLTFExportMenu.exportSceneGLB (System.String sceneName, 
@Skylion007
Copy link
Author

I am not sure if this is correct, but I modified the sceneExporter like so to fix it:

				for (var i = 0; i < primVariations.Length; i++)
				{
					if (i < materialsObj.Length)
					{
						prims[i] = new MeshPrimitive(primVariations[i], _root)
						{
							Material = ExportMaterial(materialsObj[i])
						};
					}
                                        else
                                        {
						prims[i] = new MeshPrimitive(primVariations[i], _root);
					}

@hybridherbst
Copy link

Hi, thanks for the report!

That's an awesome dataset, I'll add that to the testing here for sure.
For fixing this issue faster, could you point me to a specific scene breaking?

Thank you!

@hybridherbst
Copy link

Found them I think. Let me know if you had issues with other ones as well.
Posting here for reference until fixed.
image

Thanks again for reporting!

@hybridherbst hybridherbst self-assigned this Apr 14, 2021
@hybridherbst hybridherbst added the bug Something isn't working label Apr 14, 2021
@Skylion007
Copy link
Author

Skylion007 commented Apr 14, 2021 via email

@hybridherbst
Copy link

@Skylion007 the scenes should export correctly right now. Would be great if you test as well and see if something doesn't work as expected.

This was a good bug, fixing it uncovered a number of other potential issues when multiple objects shared the same mesh, but their submeshes had different sets of materials. Thanks again!

@Skylion007
Copy link
Author

Awesome, I noticed another potential bug dealing with metallic textures. I did an export in October and the materials were fine, but when I pulled from master of development and re-exported it seemed to have issues.

I zipped an example of a broken object from AI2Thor. The original export from October seems to preserve the metallic materials.

Alarm_Clock_8_broken_new_export.zip

@Skylion007
Copy link
Author

@hybridherbst in case you didn't get a notification due to the issue being closed.

@hybridherbst
Copy link

hybridherbst commented Apr 15, 2021

@Skylion007 would you mind opening a separate issue for this, ideally with some screenshots? Thank you! I also noticed that some objects have incorrect metallicness, which might be a regression after fixing lots of colorspace and URP export issues.

Also when referencing that dataset, would be great if you could tell me the scene where that's from as well :) Thanks!

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

2 participants