Scene Capture Depth Source Ignores Sphere Mask

To be more clear…

Scene Capture Depth Source Ignores Sphere Mask when it is used for Opacity Mask Calculations in the material.
At least this seems to be the case to me.

Attempt to check the scene’s depth with a scene capture component and you’ll see any opacity mask set by a sphere mask is ignored, but if you set the opacity mask via other means like just plugging in a texture sample with some varying alpha and depth capture picks it up.

See below screenshots.
Not working using sphere mask

Working no sphere mask

EDIT: More tests indicate it might be the use of Camera Position rather than sphere mask that is the real issue here.
EDIT: It isn’t sphere mask it is most certainly the use of Camera Position node preventing depth capture from updating when opacity is tweaked with any math using Camera Position node.

When rendering with capture components, Camera Position seems to return an unexpected value rather than the actual camera position (Possibly the position of the main viewport camera, but here it looks like they’re the same?) Instead of doing that, you could TransformPosition 0,0,0 from Camera Relative World Space to World Space, like so:

304832-ue4editor-2020-06-18-14-13-42.png

And use that instead of the CameraPosition node. For all cases except this strange one, this should behave identically.

Yup! That did the trick! This was a head scratcher, thanks for this neat trick though.