Download

Blending in new PostProcess settings via script

I’m trying to blend in new PP settings (such as DOF). I have the current code I’m playing with:

function SetDOF(float dist, float maxBlur)
{
    local PostProcessSettings newPpSettings;

    newPpSettings = Worldinfo.DefaultPostProcessSettings;

    newPpSettings.DOF_FocusInnerRadius = dist;
    newPpSettings.DOF_MaxFarBlurAmount = maxBlur;

LocalPlayer(GetALocalPlayerController().Player).OverridePostProcessSettings(newPpSettings, 5.0);
}

It works fine to blend in the new settings, but once it’s blended in, it then blends out by itself.

Does anyone know how I can get it to stay on the new settings once blended in?

The method on LocalPlayer.uc I’m calling is defined as follows:

/**
 * Begins an override of the current post process settings.
 */
simulated native function OverridePostProcessSettings( PostProcessSettings OverrideSettings, optional float BlendInTime );

I never used OverridePostProcessSettings, for the DOF I use tick to modify parameters in the way you use. But for change other parameters perhaps is no valid.

you shouldn’t be trying to change the Default PostProcessSettings directly, but rather the already-initialized PP on the Player.

I actually don’t animate them so my process is more rudimentary. it’s probably not relevant to you but in case you do Material Effects it might be useful:

My Process

to do that I followed this method:

  • from the PlayerController’s LocalPlayer get PlayerPostProcess and Find the PP you want by name (the name is what you put in the PP node in the chain in the editor), typecasted
  • change the settings on it
// find them and cache them
	myUberPP = UberPostProcessEffect(LocalPlayer(myPlayerController.Player).PlayerPostProcess.FindPostProcessEffect('UberPP'));
	mySSAO = AmbientOcclusionEffect(LocalPlayer(myPlayerController.Player).PlayerPostProcess.FindPostProcessEffect('SSAO'));
	myCustomMatPP = MaterialEffect(LocalPlayer(myPlayerController.Player).PlayerPostProcess.FindPostProcessEffect('SomeMaterialPP'));
// and so on

// example of changing
	myUberPP.MotionBlurAmount = 0.0f;

for you it’s probably as simple as replacing one line, where you get newPpSettings:

newPpSettings = LocalPlayer(myPlayerController.Player).PlayerPostProcess;

if you modify the PP make sure you remove the PP chain on level change because references to the PP settings are especially prone to fail with garbage collection and cause crashes. I clear them like so:

// my playercontroller
simulated event Destroyed()
{
	if (Player != None)
	{
		LocalPlayer(Player).RemoveAllPostProcessingChains();
	}

	Super.Destroyed();
}

I put that not only on Destroyed() but also on ClientRestartMap(). there might be other places needed for you since your game is multiplayer

In Himeko Sutori, when I zoom the camera in and out, I change the DOF settings directly, without the OverridePostProcessSettings.

WorldInfo.DefaultPostProcessSettings.DOF_FocusDistance = ...
WorldInfo.DefaultPostProcessSettings.DOF_FocusInnerRadius = ...

This works just fine for me, and nothing undoes the settings that I change manually. I don’t know the downsides to how I do it. Maybe this approach could cause problems if I used more post process volumes, or if my game were multiplayer.

Maybe I should start doing as @Chosker says and start trying to access PlayerPostProcess instead.

One thing I was never able to do was fade in a color lookup table via UScript. If you set a new color lookup table in a post process volume, it fades in very nicely. If you try to change the color lookup table via UScript, it changes immediately, and I don’t see any way to fade into the change. Any idea how you could fade into that change?