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

Added GFX Blender Replay Script #1041

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Added GFX Blender Replay Script #1041

wants to merge 4 commits into from

Conversation

ASzot
Copy link
Contributor

@ASzot ASzot commented Dec 15, 2022

Motivation and Context

Used for viewing the generated GFX replay files in Blender. This is @eundersander's PR here with additional small changes.

How Has This Been Tested

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Dec 15, 2022
Copy link
Contributor

@mathfac mathfac left a comment

Choose a reason for hiding this comment

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

Thank you, Andrew!
Several comments:

  • Let's add link to GFX as that's not clear what it is for users working with HabLab.
  • Let's add the scrip description to Argument parser as well.
  • is there an option to add some smoke test for the scrip to make sure it won't be outdated?

@ASzot
Copy link
Contributor Author

ASzot commented Dec 15, 2022

is there an option to add some smoke test for the scrip to make sure it won't be outdated?
Unfortunately I don't think so because this script runs through Blender.

Except for this, I addressed your comments.

Copy link
Contributor

@eundersander eundersander left a comment

Choose a reason for hiding this comment

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

I left a bunch of comments. Thanks for starting this PR! If you don't have time to tackle my suggested refactors, I suggest just leaving this PR open and we'll get to them soon. (Let's not merge stuff to main until it's bulletproof.)

if len(bpy.context.selected_objects) == 0:
raise ValueError("No objects found in scene")
bpy.context.view_layer.objects.active = bpy.context.selected_objects[0]
if "Stage" in item.filepath:
Copy link
Contributor

@eundersander eundersander Dec 16, 2022

Choose a reason for hiding this comment

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

Let's make this a command-line option for the script. Some people definitely will want the ceiling and they'll be super-confused that it is missing. You could even make it entirely command-line-driven (force the user to specify "Light" and "ceiling" on the command line).

At a high level, think of this as a general-purpose tool for getting Habitat scenes/episodes into Blender. Let's not overfit to your specific use case (visualizing trajectories with an overhead camera).

Copy link
Contributor

@eundersander eundersander Dec 16, 2022

Choose a reason for hiding this comment

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

For future reference: a more robust way to cull the ceiling would be the Bisect tool, with a user-specified height. See this tutorial for how it works: https://aihabitat.org/tutorial/editing_in_blender/ . I assume it could be scripted. But no need to add this feature in this PR.

m.show_transparent_back = False

add_lights = settings.get("lights", [])
for light in add_lights:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty messy. I hate introducing yet another JSON format file. @0mdc has already added light support to gfx-replay. Can we just use that? I.e. update the keyframe parsing here to parse the lights. And then your command line could parse multiple gfx-replay files. And one of them just specifies the lights.

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, I find that Blender area lights produce the prettiest results, and we can't currently represent them directly in gfx-replay (it only supports point lights). Not sure what to do about that. What about loading an additional Blender file as a kind of template?

Again, what I really don't like is introducing yet another proprietary JSON format file.

light_object.location = light["location"]

print("")
if len(keyframes) > 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update this message to include (1) if the ceiling or anything else was culled, and (2) what lights were spawned. This will help users troubleshoot when using this script.

filepath = filepath.replace(".dae", ".glb")
raw_filepath = raw_filepath.replace(".dae", ".glb")
if not os.path.exists(filepath):
os.system(f"assimp export {orig_filepath} {filepath}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make this more robust. Check if assimp is available. If not, print a warning message and instructions for installing Assimp (it's just pip install assimp, right?).

r"""
Script for loading a GFX replay file into Blender. This allows playing back a trajectory from Habitat in Blender.

See the following tutorial for more information on GFX: https://colab.research.google.com/github/facebookresearch/habitat-sim/blob/main/examples/tutorials/colabs/replay_tutorial.ipynb
Copy link
Contributor

Choose a reason for hiding this comment

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

Rewrite this to more information on gfx-replay. GFX is a generic abbreviation for graphics and is too vague.

# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
r"""
Script for loading a GFX replay file into Blender. This allows playing back a trajectory from Habitat in Blender.
Copy link
Contributor

Choose a reason for hiding this comment

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

Rewrite to loading a gfx-replay. I just want to be consistent.

@@ -0,0 +1,348 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename to PR from Added GFX Blender Replay Script to Added Blender Gfx-replay Script. I want to be consistent. GFX is just an abbreviation for graphics and is too vague.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants