Triggered blueprint events sequencer, wait for finished blueprint operation before rendering?

Hello!

I’m trying to trigger blueprint events in sequencer, and yeah, it works. But what ends up happening is that the render and blueprint events are asynchronous operations and the BP event doesn’t do the changes to the scene until about halfway through the render.

*Simple example: *
For a camera angle a mesh needs to be moved, otherwise it blocks the camera.

Rendered at 128 samples the mesh doesn’t move until about sample 60. So the end result is a frame that is a mess. The blocking mesh will be translucent and the resulting frame looks like a blend between a render without the blocking mesh and a render with it.

And sadly, I can’t just do it all in the sequencer. If it was only a mesh moving then I could, but it’s way more complicated than that. Light channels needs to switch, lights moved, blockers placed, I can’t use hard references to objects, the works.

Is there a way to prevent this behavior? What I want is of course to wait for the blueprint event to do its thing before I start rendering. But what I’m doing here is clearly asynchronous and the blueprint and sequencer just does their things independently of each other at the same time.

Any help would be appreciated! It feels like something that would be solvable, but I have a feeling I am using the wrong search terms.

It sounds like you’re encountering a common issue where the Blueprint events and the Sequencer rendering process are running asynchronously, which causes your Blueprint changes (such as moving meshes, adjusting lights, etc.) to happen too late, after the rendering has already begun. This results in visual issues like meshes blocking the camera or objects appearing partially translucent during rendering.
I imagine everything I’m about to write to you is boring but I speak to you from personal experience, I invite you to follow a whole series of steps.

To solve this, you need a way to ensure that your Blueprint events are fully executed before the frame rendering begins. There are a few potential solutions you can try:

  1. Use the Sequencer to Trigger Blueprint Events Synchronously
    The simplest way to ensure that the Blueprint event finishes before rendering begins is to make sure it’s triggered at the right time in the Sequencer. You can do this by:

Adding Event Tracks: In the Sequencer, use Event Tracks to directly trigger Blueprint events. This ensures that the event is triggered at a specific frame and allows you to time the changes precisely with the rendering process.

Right-click on your Track in the Sequencer and add an Event Track.
Create an event in your Blueprint that contains the necessary changes (e.g., moving a mesh, adjusting lighting).
Ensure the event is timed to fire before the rendering of the frame that it affects. You might need to move the event slightly earlier in the timeline to account for the delay.
2. Force the Blueprint to Complete Before Rendering
If the above doesn’t work as expected (or if there’s some asynchronous behavior within the Blueprint itself), you can ensure that the changes happen in pre-render by using a function to block the rendering process until your changes are complete.

Two approaches:
Use a Delay node (or “Wait”) in Blueprints to ensure that the render waits for the necessary changes to occur. You can specify a short delay in your Blueprint script to allow the event to finish before rendering.

Event-driven synchronization: Consider setting up flags or signals that notify the Sequencer or the render pipeline when the Blueprint operations are complete. This can be achieved using a custom synchronization logic within your game loop, ensuring the rendering waits until everything has been moved/adjusted.

  1. Force a Frame Update
    Sometimes the issue happens because the Blueprint changes don’t immediately propagate. To address this, you can force the engine to update the frame after making changes. You can do this in Blueprint by using:

Flush Rendering Commands: This node ensures that any pending rendering commands in the pipeline are processed immediately. You can add this after your Blueprint logic that moves meshes or adjusts the scene.

blueprint code:

FlushRenderingCommands
This ensures that all rendering operations related to the changes are processed immediately, instead of being queued up after rendering has already started.

  1. Use Sequencer Bake Transform/Properties
    If your Blueprint is manipulating actor transforms, consider baking the transforms in the Sequencer instead of handling it purely in Blueprints. This way, the Sequencer directly controls the movement of the meshes, which will ensure everything is aligned during the render.

Right-click on the actor track in Sequencer, and choose Bake Transform.
This will bake the movement or changes into the Sequencer’s timeline, ensuring it’s handled in sync with the rendering process.
6. Sequencer Render Settings
Another approach would be to experiment with rendering settings:

In the Movie Render Queue, under Settings, try tweaking Anti-Aliasing settings, sample counts, or other parameters related to temporal processing. The issue you’re describing, where the blocking mesh becomes translucent during rendering, sounds like it may be related to temporal accumulation not syncing well with object transformations.

Ensure that “Temporal Sample Count” isn’t too high (or unnecessary) for the given task, as high values can cause artifacts if changes are happening during the rendering process.

  1. Break Down Your Operations
    If the operations you’re doing (e.g., moving a mesh, switching light channels, adjusting lights) are highly complex and can’t be done solely in Sequencer, consider breaking them down into smaller, more manageable events that are triggered over a few frames instead of all at once. This can reduce the chances of asynchrony affecting your render.

Summary of Steps:
Trigger Blueprint Events earlier in Sequencer via Event Tracks.
Use Flush Rendering Commands to ensure the scene is updated before rendering.
Consider Baking Transforms directly into the Sequencer for mesh movement.
Adjust Movie Render Queue settings to minimize artifacts from async operations.
Break down your Blueprint changes into smaller events to ensure they complete before the frame render.

Cheers and let me know

Thanks a ton for the suggestions, they didn’t entirely work for our setup given what demands we have on it, but they almost worked and with a final piece of the puzzle I got it working! :smiley:

Essentially what we do now is to forgo the UI movie render queue entirely and trigger it with Movie Render Queue in Runtime in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community

So now I can do blueprint setups like you suggested properly and implement checks to make sure I don’t render any unfinished frames!

Again, thanks a lot! :smiley: