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

[VE] Usability and performance enhancement #123

Merged
merged 6 commits into from
Jan 26, 2025

Conversation

vea-sa
Copy link
Contributor

@vea-sa vea-sa commented Jan 25, 2025

This PR improves VE in 3 ways:

  1. Toggle for realigning timeline to 00:00. My previous PR restarted timeline unconditionally, which causes some jank with warmup/looping. Now: If enabled, restarts timeline and waits [fps] frames for the physics settle before starting the recording. If disabled, does nothing so that recording a looping animation can rely on the physics from the previous warmup run.
  2. Refactor Bitmap (renamed to Builtin) and enable Builtin for KK.
  3. Performance Improvements:
    2.1. Refactor the IScreenshotPlugin so that VE can receive the Texture2D instead of already encoded bytes (where possible).
    2.2. Use a ThreadPool to encode Texture2D and write to disk. This helps because ThreadPool is multi-processor.
    2.3. Activated by a toggle marked as BETA because of the nature of this change. I haven't had issues so far, but Unity objects like Texture2D are not thread-safe and I think it needs some testing on the field.

The biggest costs were the excessive GC calls and image encoding on the main thread.

This video shows the difference when recording using Builtin PNG (0:19 -> 0:13). This is much faster than the other test below because recording from this angle is less costly.

PR_VE.mp4

Other crude tests (all in 1440p):

KK, 180 frames (scene in demo video from camera object angle):
Builtin (BMP): 0:29 -> 0:11 *
Builtin (PNG): 0:49 -> 0:27 *
Manager (PNG): 1:04 -> 0:38

KK, 720 frames (timeline scene with 2 characters):
Builtin (BMP): 1:54 -> 0:41 *
Builtin (PNG): 4:04 -> 2:33 *
Manager (PNG): 5:25 -> 3:42

KK, 600 frames (ridiculous scene with 32 characters):
Builtin (BMP): 5:39 -> 4:09
Builtin (PNG): 6:43 -> 4:43
Manager (PNG): 7:41 -> 6:55

HS2, 1593 frames (timeline scene with 2 characters):
Builtin (BMP): 2:09 -> 1:46
Builtin (PNG): 7:14 -> 6:07
Manager (PNG): 9:12 -> 7:40

* Scenes with fast rendering times had the biggest gains because their main bottleneck was the encoding. Heavy scenes have to wait for their frame to render before offloading encoding and IO to the ThreadPool.

It's a small improvement for #89.

@ManlyMarco ManlyMarco merged commit 81d3140 into IllusionMods:main Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants