Incorrect Lumen Scene direct lighting when objects behind/beneath masked landscape.

When objects are placed behind/beneath a masked landscape and r.Lumen.HardwareRayTracing.SurfaceCacheAlphaMasking is enabled, the direct light evaluation is incorrect.

Setting Context.bAcceptFirstHitAndEndSearch to false in LumenSceneDirectLightingHardwareRayTracing.usf:318 fixes the issue.

From what I’ve found this happens because sometimes the raytracing ends up evaluating the landscapes anyhit shader first, then aborting the trace. This leads to a retrace from the hit location on the landscape, which in turn causes the incorrect lighting. Note that this probably only needs to be disabled when r.Lumen.HardwareRayTracing.SurfaceCacheAlphaMasking is enabled.

Steps to Reproduce

  • Open repro project
  • Open Lumen visualization
  • Notice incorrect Lumen Scene direct lighting on shadowed cube.

Hi,

thanks for reporting this issue and sharing a fix. Unfortunately I was unable to open the repro project as it shows a message that Level.umap appears to be an asset file.

Would it be possible to repackage the repro project again (or provide more detailed repro steps)? Can you also tell me what engine version you are using?

Thanks in advance,

Sam

Hi Sam!

The first repro project was made in ue5-main, I’ve made another in 5.6.

I noticed while creating it that there is a new CVar that also fixes this issue: r.RayTracing.Geometry.Landscape.VertexMask.

We are on 5.5 right now so we will use my proposed fix for now.

But might be worth looking at as it might cause issues with other masked materials.

Thanks!

Hi,

thanks for the new repro scene, I could replicate the issue and tried both your fixes. I confirmed that setting r.RayTracing.Geometry.Landscape.VertexMask to 1 fixes the issue in 5.6 (the CVar was introduced with this commit), but setting Context.bAcceptFirstHitAndEndSearch to false in LumenSceneDirectLightingHardwareRayTracing.usf and recompiling the shader did not make a difference for me in 5.5 or 5.6 (I remade the scene in 5.5). Can you please confirm that this fix works for both engine versions?

Thanks,

Sam

Hi!

It works on both engine versions for me. Did you set the one on line 318 to false? There are two in the file, one is on line 206, which is for the stochastic path, and the other one is on line 318, for the non stochastic path.

Thanks!

That was it, thanks (I had only changed the one at line 206)!

I will file a bug report for this issue and post a link here to the public issue tracker once it becomes available, so you can track its progress.

Thanks again,

Sam

Hi again,

this is the link to the issue on the public issue tracker: https://issues.unrealengine.com/issue/UE-347428

If you have further questions, please let me know.

Thanks again,

Sam