-
Notifications
You must be signed in to change notification settings - Fork 3
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
WIP, ENH: support frame bounds for movie renders #16
base: main
Are you sure you want to change the base?
Conversation
* Fixes yuxuanzhuang#15 * Add a new `frame_bounds` argument to `render()`, so that the start and end frame may be controlled conveniently by the user when producing a movie. I suppose the argument for why this should be available to the user vs. using raw `bpy` would be similar to the argument in favor of the original `frame` argument to render individual frames. * I can add some regression tests, but I'll wait to see if folks actually want this. The current testsuite still passes locally at least.
|
||
def render(self): | ||
# Render the movie | ||
if self.frame_bounds is not None: | ||
bpy.context.scene.frame_start = self.frame_bounds[0] | ||
bpy.context.scene.frame_end = self.frame_bounds[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is None
, we might also consider defaulting to the trajectory bounds, similar to the MN initialization approach Brady mentioned? (since a new user may not know about the kwarg)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree default / None
should default to trajectory bounds. If a user is going to be rendering a subset / outside of that they'll have to explicit anyway.
Should perhaps think about smoothing/averaging and their impacts on frame counts here too? Or at least how the API would play with those. |
I think the overall philosophy would be that the user doesn't even have to import For averaging then this won't affect start / end frame, but for adding in subframes, I think that should be left to the user to be explicit with requesting. If the input is default / |
Is there a straightforward adjustment a user should make when using subframes? For example, if you have 90 frames and normally set your range to something like I'll paste the diff for the render code I was playing with to adjust --- a/adk.yaml
+++ b/adk.yaml
@@ -25,3 +25,5 @@ background_color:
alpha: 1.0
# a larger focal length increases "zoom"
focal_length: 80
+# subframes can be increased for "smoothing" of animation
+subframes: 2
diff --git a/probe.py b/probe.py
index 3dad198..62cf9df 100644
--- a/probe.py
+++ b/probe.py
@@ -43,6 +43,7 @@ def main(p_config: dict):
mode = p_config["mode"]
background_color = p_config["background_color"]
focal_length = p_config["focal_length"]
+ subframes = p_config["subframes"]
if mode == "movie":
outfile_suffix = "mp4"
@@ -58,6 +59,7 @@ def main(p_config: dict):
u = mda.Universe(topology_path, trajectory_path)
system = u.select_atoms(sel_string)
all_mol = ggmv.molecule(system, lens=focal_length)
+ all_mol.subframes = subframes |
The number of subframes just inserts that many extra frames between one frame and the next. So if a trajectory has between Yes this does need to be documented better somewhere. |
The alternative to subframes (which just adds intermediate frames to move through) is the averaging, which doesn't add any extra frames but does calculate the mean across multiple frames to remove a lot of the jittering. Looks like support for that hasn't been implemented in ggmolvis directly though, but is upstream in MN. |
One can also add transformation in MDAnalysis https://docs.mdanalysis.org/1.1.0/documentation_pages/transformations/positionaveraging.html which also won't mess up the total number of frames. |
A limitation I ran into which is why I ended up implementing it myself is that once you add a transformation to a universe you can't undo it, which is why the UI / MN uses this. But yes you can always add arbitrary transformations to your universe before loading it (or after loading it) into Blender |
So averaging has the advantage of not rendering extra frames, but presumably paying the cost of the extra subframe renders could potentially get you something that looks a bit nicer if you can wait for it? |
Personally I think averaging looks nicer, because you get smoother movements overall whereas subframes just adds slower linear interpolation between positions (and lengthens the animation). Averaging can sometimes look weird though, if you have an AA side chain that spins 180 degrees from one frame to the next, then by averaging the positions they will all move through the midpoint and overlap with each other. Depends on what you are trying to show ultimately. |
* Expose frame averaging as an alternative to the usage of subframes, as discussed at: yuxuanzhuang#16 (comment). * This mostly involved mimicking the infrastructure currently used to set subframes, minus a few changes we don't seem to need since the frame count remains unchanged. * Although I usually try to keep PRs focused on one thing, I did take a stab at trying to improve the docs for `subframes` while adding in new docs for `average`. I believe the default value documented for `subframes` was also incorrect. These are a bit more verbose than the descriptions in the MN source at `molecularnodes/props.py`, just because I wanted a bit more detail for non-developer folks.
* Expose frame averaging as an alternative to the usage of subframes, as discussed at: yuxuanzhuang#16 (comment). * This mostly involved mimicking the infrastructure currently used to set subframes, minus a few changes we don't seem to need since the frame count remains unchanged. * Although I usually try to keep PRs focused on one thing, I did take a stab at trying to improve the docs for `subframes` while adding in new docs for `average`. I believe the default value documented for `subframes` was also incorrect. These are a bit more verbose than the descriptions in the MN source at `molecularnodes/props.py`, just because I wanted a bit more detail for non-developer folks.
* Expose frame averaging as an alternative to the usage of subframes, as discussed at: #16 (comment). * This mostly involved mimicking the infrastructure currently used to set subframes, minus a few changes we don't seem to need since the frame count remains unchanged. * Although I usually try to keep PRs focused on one thing, I did take a stab at trying to improve the docs for `subframes` while adding in new docs for `average`. I believe the default value documented for `subframes` was also incorrect. These are a bit more verbose than the descriptions in the MN source at `molecularnodes/props.py`, just because I wanted a bit more detail for non-developer folks.
Fixes ENH, MAINT: control "dead time" at end of mp4 movie renders? #15
Add a new
frame_bounds
argument torender()
, so that the start and end frame may be controlled conveniently by the user when producing a movie. I suppose the argument for why this should be available to the user vs. using rawbpy
would be similar to the argument in favor of the originalframe
argument to render individual frames.I can add some regression tests, but I'll wait to see if folks actually want this. The current testsuite still passes locally at least.
PR Checklist