How to render a scene capture from a commandlet

Hello,

I’ve been trying to use the SceneCaptureComponent2D to generate a thumbnail (saving to png) from a static mesh given as input in a commandlet and so far cannot figure out how to get it to work.(I can get it to work fine in the editor or PIE).

What I’ve tried:

  • set up a blueprint which has the capture component, a background and references a static mesh directly.
  • put it in a small level
  • made the scene capture occur on construction
  • created a blutility to spawn from the commandlet (I couldn’t do this with an actor directly as CallFunctionByNameWithArguments fails for them in a commandlet, hence the extra step)
  • using the blutility functions load the level (which does scene capture on start - or begin play, tried both)
  • spawning the actor and trigger the scene capture instead of the above step produces the same result

The result: I get a png image, but it’s all black. When I run this in editor it works and I get a thumbnail I expected.

I start the commandlet with AllowCommandletRendering, there’s no errors or warnings and I didn’t spot any suspicious early exits in USceneCaptureComponent2D::CaptureScene while debugging.

Tried adding lights to the scene and blueprint, setting GI on scene capture component - case it was just complete darkness, but no change. Object positioning part most likely works fine as same input will work outside of the commandlet.

Attached some screengrabs (in 3rd screenshot there’s 2 different ways to start the thumbnail generation depending on where the exec pin goes) and the packed plugin to better illustrate setup.

I’ve been told trying to render on construction is unlikely to succeed as the world isn’t initialized yet (and this behaves differently in editor which lead me to believe it could work) so this could be the issue in this approach. It doesn’t appear that Begin Play happens in a commandlet though - finding a way to force finish load/initialize on-demand might solve it (but I’m neither certain on that nor know how to do it).
The ‘create object directly without the level’ approach still fails. Interestingly creating an object directly after loading a level crashes.

Did you ever find a solution for this?