I found the scene proxies used for drawing the built-in debug shapes, so I almost found a way to do it:
#include "PrimitiveSceneProxy.h"
#include "Components/LineBatchComponent.h"
#include "Engine/World.h"
// call the below once somewhere
GetWorld()->LineBatcher->SceneProxy->SetCustomDepthStencilValue_GameThread(stencilValue);
// also call on world->PersistentLineBatcher and world->ForegroundLineBatcher if necessary
Unfortunately, this causes an external link error because the SetCustomDepthStencilValue_GameThread function is missing the “ENGINE_API” specifier and thus can’t be accessed externally.
Any ideas?