Enable project setting programatically: Custom Depth-Stencil Pass

If it possible to set “Custom Depth-Stencil Pass” setting (in Project Settings > Rendering > Postprocessing) programmatically using either C++ or Blueprint at runtime?

Looks like the Console Command r.CustomDepth will do what you want. So you can run an Execute Console Command node with r.CustomDepth 0 it turns it off and r.CustomDepth 1 turns it on.

As an example, this will turn it on when you press ‘K’ and off when you release it

123901-customdepth.png

This works! Also to enable Custom-Depth Pass with Stencil use r.CustomDepth 3.

Apparently GetWorld()->Exec(…) doesn’t work to set above option from C++. You must instead do,

UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), FString("r.CustomDepth 3"));

You will need,

#include "Kismet/KismetSystemLibrary.h"