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

Enhancement: Render / Turntable #30

Closed
wants to merge 101 commits into from

Conversation

BigRoy
Copy link
Owner

@BigRoy BigRoy commented Nov 29, 2023

Feature

Implements a draft for playblasting/rendering using the USD api.


Opening this draft so I can comment on some code as we go

@BigRoy BigRoy added the enhancement New feature or request label Nov 29, 2023
@Sasbom
Copy link
Contributor

Sasbom commented Nov 29, 2023

Thank you for opening the draft!
Seems like a good idea.

Copy link
Owner Author

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

Some first remarks.

usd_qtpy/render_util/__init__.py Show resolved Hide resolved
usd_qtpy/render_util/playblast.py Show resolved Hide resolved
usd_qtpy/render_util/playblast.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/playblast.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/playblast.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/playblast.py Outdated Show resolved Hide resolved
# Render menu

render_menu = menubar.addMenu("Render")
render_labels = "Playblast" , "Snapshot"
Copy link
Owner Author

Choose a reason for hiding this comment

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

PEP8 - check your linter. :)

Suggested change
render_labels = "Playblast" , "Snapshot"
render_labels = "Playblast", "Snapshot"

Copy link
Contributor

Choose a reason for hiding this comment

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

PEP8 - check your linter. :)

I really should ; _ ;

On the topic of PEP8 on a different note, I know that snake_case is preferable for functions,
I just look at Qt and Usd and can't help but copy their style to maintain consistency.
That's my reasoning for naming functions the way I do. I will rename them all to be snake case, I will never more be tempted by the demons hiding in libraries.

usd_qtpy/editor.py Outdated Show resolved Hide resolved
usd_qtpy/editor.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/playblast.py Outdated Show resolved Hide resolved
@Sasbom
Copy link
Contributor

Sasbom commented Nov 29, 2023

Should be good to go. I implemented the majority of the suggestions!
Thank you for grading my homework!

Sasbom and others added 4 commits November 30, 2023 18:02
You can even set the aspect ratio. Amazing.
There is still some stuff to be done to make a turntable work, but this
is an important step on the road there.
@Sasbom
Copy link
Contributor

Sasbom commented Nov 30, 2023

framingcam_data
framingview01 00
snapshotframecam

framing cam logic is finally implemented with extensive commenting. I feel like table turning and turn tabling should just be a Xform prim or something on 0,0,0 doing a turn for some amount of frames, so I'll look into generating animation data.

The Kitchen scene is actually a hard scenario to test, because it is Z-up.

@Sasbom
Copy link
Contributor

Sasbom commented Dec 12, 2023

image

image

Implemented all 3 modes of turntabling:

  • Rotate camera:
    creates a temporary Xform with a camera in it that gets swiveled around the scene
  • Rotate subject:
    Rotates entire subject in a temporary file that stores a reference to a temporary export of the scene.
  • Turntable preset:
    It's the preset turntabler.

Copy link
Owner Author

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

UIs look good.

Some code remarks added. Let me know what makes sense and whether you need me to refactor things instead.

.gitignore Outdated Show resolved Hide resolved
usd_qtpy/editor.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/__init__.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/dialog.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/dialog.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/dialog.py Show resolved Hide resolved
usd_qtpy/render_util/dialog.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/playblast.py Show resolved Hide resolved
usd_qtpy/render_util/turntable.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/turntable.py Outdated Show resolved Hide resolved
usd_qtpy/render_util/dialog.py Outdated Show resolved Hide resolved
Comment on lines 352 to 358
if opt_index == 0:
return f"{start}"
elif opt_index == 1:
return playblast.get_frames_string(start,end,stride)
elif opt_index == 2:
if self._stageview:
return playblast.get_stageview_frame(self._stageview)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like setting up constants in classes, especially not for this particular element since this element doesn't
stay the same when inherited, so I'll comment on it.

Normally I'd define an enum, if something is common.

Comment on lines 391 to 400
elif "Framing" in box_text:
camera = framing_camera.create_framing_camera_in_stage(
self._stage,
name="Playblast_framingCam",
fit=self.spinbox_fit.value(),
width=width,
height=height
)
return camera, True
elif "Viewer" in box_text:
Copy link
Contributor

Choose a reason for hiding this comment

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

I will match the full label, I've done something similar in other sections.
This was written when I wasn't yet sure about what to call the label yet, but I knew that it was going to have the keywords "Framing" and "Viewer" in there.
Will change in next push.

Comment on lines 424 to 434
playblast.render_playblast(self._stage,
path,
frames,
self.spinbox_horresolution.value(),
camera,
self.cbox_complexity.currentText(),
self.cbox_renderer.currentText(),
"sRGB",
self._gather_purposes(),
self
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll seperate the getting of the arguments from their respective UI elements and store them,
and also name them, argname=argvariable

Comment on lines 438 to 440
# cleanup camera if needed
if should_destroy:
self._stage.RemovePrim(camera.GetPath())
Copy link
Contributor

Choose a reason for hiding this comment

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

I have been thinking about that, but there are cases where a camera for example is not supposed to be deleted, because it exists in the stage and is pulled from there. I could make the contextmanager accept an argument that would delete the camera, but that wouldn't make that much of a difference.
Let me know if you'd still like to see a context manager for camera's, specifically.

What I think could definitely benefit from a context manager, is temporary scene and associated file operations. I do plenty of that in the turntabling setup, and have been thinking about wrapping those in a context manager.

usd_qtpy/render_util/dialog.py Show resolved Hide resolved
usd_qtpy/render_util/turntable.py Outdated Show resolved Hide resolved
@BigRoy
Copy link
Owner Author

BigRoy commented Dec 22, 2023

I seemed to be unable to push into this branch - unfortunately. So I've opened a replacement branch with this PR included and some more cosmetic tweaks done on top of it. Closing this in favor of #43

@BigRoy BigRoy closed this Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants