SceneCaptureComponent2D not applying CineCamera's focal settings correctly

JoostDev
Mon, 27 Jun 2022 14:11:55 +0000
Rendering

I have a SceneCaptureComponent2D that I want to have depth of field blur. So I figured I could use this bit of Blueprint code to get the CineCamera’s type of depth of field blur:

And indeed that works, except that the focal distance isn’t actually applied in rendering. When I pause the game and look at the CineCamera’s settings, then I can see that the “current focus distance” is being calculated correctly, but the object being focused is nevertheless completely out of focus (the actual focal distance in the rendered image is much closer).

If I then create an additional CineCameraActor and copy all of the original CineCamera’s settings, the object is in focus, so it seems like the settings are set correctly, but somehow aren’t being applied in the SceneCaptureComponent2D. However, I can see that the CineCamera’s other settings are being applied: if I change the min/max FStop, I indeed get a different amount of depth-of-field blur in the SceneCaptureComponent2D’s render. But the focal distance doesn’t work.

I’ve also tried using Manual Focus Method instead of Tracking, but that had the exact same broken result.

This is a snapshot of the CineCamera’s settings during gameplay:

As a cherry on top, I’ve found that if I pause gameplay in the editor, select the CineCamera and then unpause, then suddenly the focal distance in the render jumps to the correct amount. So apparently a ‘fix’ is to select the CineCamera in the editor. Which makes extremely little sense to me…

I’ve also tried running this project in UE4.27.2 and UE5.0.2, but there the call to CopyCameraSettingsToSceneCapture doesn’t work at all. UE5.0.2 prints an endless list of this error: “LogUnrealMath: Error: TMatrix::InverseFast(), trying to invert a NIL matrix, this results in NaNs! Use Inverse() instead.” The normal SceneCaptureComponent2D (without that copy) works fine.

Am I doing something wrong here, or is this a bug in Unreal? Is there a workaround or solution?

2 posts - 2 participants