[Bug] [UE5.8.1] "DistanceToNearestSurface" Material Node doesn't work if a [Blueprint] with a [Scene capture component 2D] and a [TextureTarget] is present in the level.

Summary

[Bug] [UE5.8.1] => “DistanceToNearestSurface” Material Node doesn’t work if a [Blueprint] with a [Scene capture
component 2D] and a [TextureTarget] is present in the level.

What Type of Bug are you experiencing?

Level Design & Art Tools

Steps to Reproduce

There’s a video below explaining everything but you have the steps here too:

  1. Create a new project “Third Person” without variant and a new level with the template “Basic”
  2. Create a Material M_DistanceField with the following Setup
    A “DistanceToNearestSurface” node into a “Divide” by 100 into the “BaseColor” output of the material
  3. Add a cube, disable “Affect distance field” on it and Able “Affect distance field” on the terrain
    then Put the material on the cube. A gradient from the ground should appear on the cube
  4. Create a [Blueprint Actor Class] named “BP_Capture”, add a [SceneCaptureComponent2D]
  5. Create a [Render Target] Texture named “RT_Capture” and add it in the blueprint’s SceneCaptureComponent2D “Texture Target”
  6. After compiling, the cube has now turn black, but appeared normally when RightClicking ; Moving a viewport Window or in Unlit Mode
    but not BaseColor

Expected Result

“DistanceToNearestSurface” Material Node should work weather or not a [Blueprint] with a [Scene capture component 2D] and a [TextureTarget] is present in the level.

In this example shown in the video, the distancefield gradient should appear on the cube

Observed Result

“DistanceToNearestSurface” Material Node doesn’t work if a [Blueprint] with a [Scene capture
component 2D] and a [TextureTarget] is present in the level.
The cube with a distancefield gradient is black instead unless when I RightClick ; Move a windows of the engine or go in Unlit Mode

Affects Versions

5.8

Platform(s)

Windows

Upload an image

Video

The bug is related to distance fields not being updated for the main view, when a scene capture runs before it. A possible workaround is to set “r.AOGlobalDistanceField.DetailedNecessityCheck 0”. This does have a drawback of forcing distance field updates for views that may not need it, although these should be cheap for views that don’t move.

--Jason Hoerner

UE-392609’s status has changed to ‘Ready for QA’. A member of the QA department is investigating the issue.