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

Blender integration improvements #3749

Merged
merged 17 commits into from
Oct 12, 2020
Merged

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Oct 6, 2020

This is a resurrection of my PR #3357, which had to be closed due to unresolvable merge conflicts. It makes the same improvements to the Animated Titles UI and processing as that PR, plus additional enhancements.

Fixes #3744, fixes #3740, fixes #3730, fixes #3389

As in the previous PR:

  1. Computing animation length (fixes Animated Title: "Dissolving Text" is not working properly when Animation Length != default #3356)

    • The animation_speed parameter is renamed to length_multiplier throughout, as the former name seems almost intentionally confusing.
    • length_multiplier is used to compute the progress slider end value and labeling (frame #/#) everywhere, to properly account for adjusted lengths
  2. Render selection is now done from the command line
    The blender .py files no longer trigger the actual rendering process. Instead, they merely set up the scene, and then stop. In addition, they don't limit the frame range for previewing. Blender wil be executed with a -a argument (or -f frame# in preview mode) to render all or one of the configured frames.
    This is primarily a debugging convenience, as it means that Blender can now be launched with one of the Python scripts applied. This allows us to examine the scene in its final configuration immediately before rendering.

    For example, this command loads dissolve.blend into the Blender GUI, with all of the dissolve.py parameters applied:

    blender dissolve.blend -y -P dissolve.py

    These commands render from a configured scene (since start_frame and end_frame are no longer set to the same frame, this even works from a preview script):

    # Render just one frame
    blender -b dissolve.blend -y -P dissolve.py -f 150
    # Render the entire animation
    blender -b dissolve.blend -y -P dissolve.py -a

In addition:

  1. Blender is launched with the --factory-defaults argument, preventing it from reading the user's preferences file. Significantly, if the user has customized the language used by Blender, this will ensure that our runs create and output all data in English. This allows us to parse the output successfully, and prevents customization of default object names from interfering with our code that makes assumptions about objects being labeled in their default English names.

  2. The previous change is also leveraged to enhance our parsing of the Blender output and display inter-frame progress updates. Now, instead of using only the frame slider as its progress display, whenever Blender is rendering a frame (preview or final), a progress bar and label will be displayed at the bottom of the window next to the dialog buttons.

    This label will progress through three steps:

    • "Generating" (when any line containing 'Syncing' is output)
    • "Rendering" (When a line of the form 'Rendering N / M' is output, N and M being integers)
    • "Saving" (when a 'Saving ...' line is output).

    The "Rendering" lines will also update the progress bar to reflect the N / M chunks completion status.

    This should make the rendering process a bit more informative, especially with some of the particle physics scenes where things can get really busy, at which point each frame takes foreeeeeever to render.

  3. My fixes for the particle physics Blends are also included. (Including an update to Dissolve that disables show_dead, an option that was causing the model to reset itself after the lifetime of the particles expired.

  4. I also reworked the version check so that it's now its own function, and tweaked the regular expression used to detect the version since Blender 2.83 changed the -v output format again, and our previous expression wasn't matching.

  5. Oh, yes, and the setup process no longer copies the original script into the output directory, then modifies it. Instead, it simply reads from the original script, and writes a modified version to the output directory.

Forgot one:

  1. I fixed the preview image display to preserve its aspect ratio correctly, by disabling scaledContents in the UI definition, as that option causes the image to fill the label completely even if it means distorting it.

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Oct 6, 2020

Two examples of the progress display in action, while rendering an "Exploding Text" animation:

Screenshot from 2020-10-06 18-58-42
Screenshot from 2020-10-06 18-58-45

(In practice, "Generating" is only shown very briefly at the start of each frame, and "Saving" is never shown long enough to be visible.)

- Add utility functions to avoid repeating common operations
- Use shorter names, and assign oft-repeated attribute chains to
  alias names
- Remove some redundant/ineffectual code
- Fix dissolve.py compatibility with Blender 2.90+ by removing
  deprecated apply_as named arg from modifier_apply() call
@ferdnyc ferdnyc mentioned this pull request Oct 7, 2020
@ferdnyc
Copy link
Contributor Author

ferdnyc commented Oct 7, 2020

I think I need to add one more progress bar state, "Initializing", for when it's starting a new render. Currently the progress bar is re-enabled showing "Saving", for however long it takes to get the first "Generating" log line — which can be a second or more on some of the particle-physics scenes.

(Edit: Done.)

- Each preview / animation render task will launch in its own
  thread, which shuts down immediately on completion so that
  the next one gets its own, fresh thread.
@ferdnyc
Copy link
Contributor Author

ferdnyc commented Oct 7, 2020

With the commit I just added, I was also able to achieve what FEELS to me like a noticeable (not large, but detectable) improvement in Blender's rendering speed, by re-working the background processing so that each Blender job runs in its own dedicated, short-lived thread. Now, no threads are launched until Blender needs to be run, at which point a thread is spawned that shuts down immediately on completion.

Someone will need to double-check me on that, it's possible I'm imagining it — but it seems to me like it's more responsive that way.

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Oct 7, 2020

(If nothing else, the thread impermanence makes it much less likely a Blender thread will be the source of any crashes at application exit.)

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Oct 12, 2020

I'm going to merge this, as it contains fixes for the issues multiple users have been experiencing with the most recent Blender versions (both 2.83 and 2.90). Hopefully it doesn't cause any new issues, but if it does we'll deal with them.

@ferdnyc ferdnyc merged commit a17a730 into OpenShot:develop Oct 12, 2020
@ferdnyc ferdnyc deleted the blender-rendering branch October 12, 2020 02:59
@ferdnyc ferdnyc restored the blender-rendering branch October 14, 2020 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment