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

Artifacts when Exporting Scenes with Objects Hidden from Viewport #2102

Open
Xaldew opened this issue Jan 8, 2024 · 3 comments · May be fixed by #2181
Open

Artifacts when Exporting Scenes with Objects Hidden from Viewport #2102

Xaldew opened this issue Jan 8, 2024 · 3 comments · May be fixed by #2181
Labels
bug Something isn't working

Comments

@Xaldew
Copy link

Xaldew commented Jan 8, 2024

Describe the bug
Hello!

I've noticed that attempting to export scenes which contains objects that have
hide_viewport == True yields some strange looking artifacts when re-imported
(see screenshots below).

I'm currently working around this by having a small export script that
essentially does this:

for obj in bpy.data.objects:
    if obj.hide_viewport:
        obj.hide_viewport = False
bpy.ops.export_scene.gltf(filepath=f'{output}.gltf',
                          export_cameras=True,
                          export_lights=True,
                          export_format='GLTF_SEPARATE')

This works, but for large scenes (e.g., San Miguel from issue #2101) this can take
a full day to complete.

To Reproduce
Steps to reproduce the behavior:

  1. Open included "arcsphere-50.blend" file.
  2. Export the scene to glb or glTF.
  3. Open a new instance of Blender
  4. Import the previously exported scene.

Expected behavior
The exported scene should match the "arsphere_expected.glb" file.
(i.e., all objects, including the ones marked with hide_viewport = True,
should be included, and at their correct position).

Screenshots
Scene with the artifact, presumably from the "hidden" instances:
blender-artifact
Scene exported with no objects with hide_viewport == True.
blender-no-artifact

.blend file/ .gltf (mandatory)
The zipped file includes a .blend file with half of all objects/instances "hidden" with hide_viewport = True,
as well as a zip with the expected export result and the received result.
arcsphere-50.zip

Version

  • OS: Linux
  • Blender Versions 3.6, 4.0
@julienduroure
Copy link
Collaborator

Confirmed.
Investigation in progress. (and I will try to get a small file that show this issue, as this one is not very easy to handle for debugging)

@Xaldew
Copy link
Author

Xaldew commented Jan 19, 2024

Ah yes sorry, I should really have done that from the beginning. Here's a much simpler .blend + .glb file that still exhibits this issue:
instances.zip

@julienduroure julienduroure added the bug Something isn't working label Feb 6, 2024
@julienduroure
Copy link
Collaborator

Hello,
Problem comes from object that are hidden in viewport have not the real world matrix stored. Because they are hidden in viewport, matrix is not set.
I will push a PR in a few minutes, where I do the following: For these objects, I un-hide them, update the depsgraph, get the matrix, and hide again. Not sure about impact on performance, but this is the only way to get the right matrices

@julienduroure julienduroure linked a pull request Mar 27, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants