keywords: [UE4]Modify Post Process Settings at Run-time

keywords: change post process settings when game is running, manipulating post process on the fly, 运行时期间修改后处理设置

Modify properties of Post Process Settings of Camera at run-time

1,Get reference to Camera Component and drag out “Set members in PostProcessSettings” node.

2,Select Set members in PostProcessSettings node, then checked properties which want to be modified in Detail Panel. e.g. Brightness of Exposure.

3,Set Post Process Blend Weight to 1 in Camera Component, which means fully enable Post Process Settings of Camera. Fully disable Post Process Settings of Camera if set this value to 0, value between 0 and 1 means that using a more gradual blend between fully enabled and fully disabled.

4,Disable Post Process Volume in scene, because we would use Post Process Settings of Camera Component.

Example: when game start, modify Exposure Brightness of Post Process gradually.

Incipient UE4 version doesn’t support manipulate Post Process Volume using C++ or Blueprint, but now supported.

Old answer about why UE4 doesn’t support manipulating Post Process Volume at run-time. https://forums.unrealengine.com/development-discussion/c-gameplay-programming/6490-creating-a-postprocessvolume-from-c-anyone-done-that-yet

Create Dynamic Material Instance and pass Parameters for Post Process Materials at run-time

If just add material for Post Process Materials in Editor, Steps are follows:

If want to set parameter of materials of Post Process Volume, Steps are follows:

1,Add two variables in your Actor (e.g. PlayerController): Post Process Volume Reference and Material Instance Reference.

2,Make a Post Process Settings in BeginPlay

and Enable pin Post Process Materials

then drag out from Post Process Volume Ref and add Node Set Settings

Final BP Node:

The way above would override all the parameters of Settings of Post Process Volume!!!

If you want to change Post Process Materials only and keep other parameters unchanged, you need to try using the following way:

3,Open Level Blueprint:

then select the PostProcessVolume in Level Editor:

then right click in Level Blueprint, then select Create a Reference to PostProcessVolume

then set Post Process Volume Ref to the Reference:

4,Then add expression Constant3Vector in your material:

then convert it to Parameter

5, At last, you can pass parameter (e.g. Character’s Location) to Material Instance

Manipulate Post Process Volume using C++

Header

UPROPERTY(EditDefaultsOnly, Category = "Post Process")
    UMaterialInstance* TestMatIns = nullptr;

UPROPERTY()
    UMaterialInstanceDynamic* TestMatInsDyna = nullptr;

CPP

void AMyPlayerController::AddDynaMatForPostProcessVolume()
{
    TArray<AActor*> Actors;
    UGameplayStatics::GetAllActorsOfClass(this, APostProcessVolume::StaticClass(), Actors);
    if (Actors.Num() > 0)
    {
        APostProcessVolume* PPV = Cast<APostProcessVolume>(Actors[0]);
        if (PPV)
        {
            FPostProcessSettings& PostProcessSettings = PPV->Settings;
            if (TestMatIns)
            {
                TestMatInsDyna = UKismetMaterialLibrary::CreateDynamicMaterialInstance(this, TestMatIns);
                FWeightedBlendable WeightedBlendable;
                WeightedBlendable.Object = TestMatInsDyna;
                WeightedBlendable.Weight = 1;

                PostProcessSettings.WeightedBlendables.Array.Add(WeightedBlendable);
            }
        }
    }
}

void AMyPlayerController::UpdatePawnLocMaterial()
{
    if (TestMatInsDyna)
    {
        if (APawn* Pawn = GetPawn())
        {
            FVector Loc = Pawn->GetActorLocation();
            FLinearColor LocParam(Loc.X, Loc.Y, Loc.Z, 0.f);
            TestMatInsDyna->SetVectorParameterValue(TEXT("Location"), LocParam);
        }
    }
}
Reference

Dynamic Post Process Volume (Create Dynamic Material Instance for Post Process Materials)
https://www.parallelcube.com/2018/12/09/post-process-volume/

WTF Is? Post Process Blend Weight in Unreal Engine 4 ( UE4 )
https://www.youtube.com/watch?v=JbbZWayflto


以前觉得要在一堆人里脱颖而出,被别人注意到,这很难得,后来明白了,其实在一堆人之中,能够聪明而巧妙的把自己藏起来,这更难得。 —— 独木舟葛婉仪