How to apply User overrides selected in UMovieJobVariableAssignmentContainer to render in custom Tool?

Hi Unreal Team,

We are currently investigating the capabilities of the new Movie Render Graph and we really liked the dynamic UI of the UMovieJobVariableAssignmentContainer, which is way we wanted to explore to option to include it our tool when we use MRG.

We managed to display every user variable defined in the MRG, however the overrides that are selected in the UI is not applied to our renders.

As an example we have 3 user variables:

  • bool bBeauty
  • bool bCharacter
  • bool bEnvironment

These control which render layers should be rendered. In our case all of them are enabled by default, but when I try to only select one of them, our tool still renders all of them.

I took the part from UMovieGraphQuickRenderSubsystem::GenerateAndPopulateQueue() that is should be responsible to overwrite the settings in the Graph in the Job level.

`// Update the job to use the quick render graph (either the default, or the one specified in the settings)
TMap<TObjectPtr, TObjectPtr> OriginalGraphToDupeMap;
const UMovieGraphConfig* RenderGraph = RenderSettings->GraphConfig;
if (!RenderGraph)
{
// GetQuickRenderGraph() will output an error to the log if a graph was not returned
return;
}
Job->SetGraphPreset(RenderGraph);

// Apply any job-level variable overrides, if they were specified
for (const TObjectPtr& IncomingVariableAssignment : RenderSettings->GraphVariableAssignments)
{
// Map the setting’s graph to the duplicate graph
const UMovieGraphConfig* AssignmentGraph = IncomingVariableAssignment->GetGraphConfig().LoadSynchronous();
const TObjectPtr* DuplicateGraph = OriginalGraphToDupeMap.Find(AssignmentGraph);
if (!DuplicateGraph)
{
UE_LOG(LogMovieRenderPipeline, Warning, TEXT(“Quick Render: Unable to properly set variable overrides for graph [%s].”), *AssignmentGraph->GetName());
continue;
}

UMovieJobVariableAssignmentContainer* NewVariableAssignments = Job->GetOrCreateJobVariableAssignmentsForGraph(*DuplicateGraph);

for (const UMovieGraphVariable* GraphVariable : (*DuplicateGraph)->GetVariables())
{
bool bIsVariableAssignmentEnabled = false;
IncomingVariableAssignment->GetVariableAssignmentEnableState(GraphVariable, bIsVariableAssignmentEnabled);

// Copying values by serialized string isn’t ideal, but it’s the easiest way to transfer values between the variable assignments
NewVariableAssignments->SetValueSerializedString(GraphVariable, IncomingVariableAssignment->GetValueSerializedString(GraphVariable));
NewVariableAssignments->SetVariableAssignmentEnableState(GraphVariable, bIsVariableAssignmentEnabled);
}
}`

However it doesn’t seems to work for some reason. Could you perhaps confirm if this is the only part that needs to be done in order to apply the job level user variable overrides? If not could you let me know what else shall be done?

Thanks in advance!

Zoltán