Using Lighting functions with our ray tracing settings causes a constant assert loop over an incorrect number of bindings. BoundCBVMask is 29, missing the bit for the index 1 buffer across 5 bits, NumCBs is 4. Seems related either to GetUniformBufferParameter<FDeferredLightUniformStruct>() being unbound and not present in the compiled shader, or to RaytracingLightGridData being compiled in shader as StructuredBuffer<FRTLightingData> RaytracingLightGridData_SceneLights after being only referenced the one time as RaytracingLightGridData.SceneLights in the original code.
Setting r.RayTracing.LightFunction=0 or r.Lumen.HardwareRayTracing.LightingMode=0 prevents the assert.
Steps to Reproduce
Create default 3rd person project.
Add CVars to DefaultEngine.ini and run. Might not need every CVar, but this is the subsection for our I had in vanilla when I reproduced it.
Add lighting function material to the Directional Light. Material I used was just a constant white into the Emissive.
CVars:
r.RayTracing=True
r.RayTracing.UseTextureLod=False
r.RayTracing.NonBlockingPipelineCreation=True
r.RayTracing.Culling=3
r.RayTracing.Culling.Radius=20000
r.RayTracing.Culling.Angle=1
r.RayTracing.Culling.UseGroupIds=0
r.RayTracing.Geometry.NiagaraRibbons=0
r.RayTracing.Geometry.NiagaraSprites=0
r.RayTracing.Geometry.NiagaraMeshes=0
r.RayTracing.ExcludeTranslucent=True
r.RayTracing.ExcludeTranslucent=1
r.RayTracing.Shadows.AvoidSelfIntersectionTraceDistance=100
r.RayTracing.NormalBias=1
r.RayTracing.Geometry.InstancedStaticMeshes=1
r.RayTracing.Geometry.Landscape=0
r.RayTracing.Geometry.StaticMeshes.WPO=1
r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius=2000
r.RayTracing.ExcludeDecals=1
r.RayTracing.Shadows.AcceptFirstHit=1
r.RayTracing.Geometry.NaniteProxies=1
r.RayTracing.SceneCaptures=0
r.Lumen.Reflections.Allow=1
r.Lumen.Reflections.DownsampleFactor=1
r.Lumen.Reflections.RadianceCache=1
r.Lumen.HardwareRayTracing.LightingMode=3
Ah yeah that’s my bad, I thought 2 of the settings in my existing testbed were defaults but you also need to turn on raytracing for shadows. These are the settings I can toggle around to change it with the added 2 needed. I zipped this example project with raytracing light functions disabled, but then went and rezipped it with it enabled, so it should assert as soon as you run.
; Core Repro Settings
r.Lumen.HardwareRayTracing.LightingMode=3 ; Set to 0, 1, or 2 to run successfully
r.Lumen.HardwareRayTracing=1 ; Set To 0 to run successfully
r.RayTracing.Shadows=1 ; Comment out to run successfully
;r.RayTracing.LightFunction=0 ; Uncomment to run successfully
Curiously I was not able to replicate this on a launcher version of the engine, but I was able to replicate this using a source version of 5.4. The issue is that a light function ray tracing material shader can use primitive data, which is not bound anywhere.
The following code added to GetShaderBindings fixes the issue:
// LightFunctions can use primitive data, set identity so we do not crash on a missing binding
ShaderBindings.Add(GetUniformBufferParameter<FPrimitiveUniformShaderParameters>(), GIdentityPrimitiveUniformBuffer);
Here is the CL with the fix:
[[CL 36184369]](https://github.com/EpicGames/UnrealEngine/commit/a943043aeeb93c67e47d737701772337552e77a0)
Regards,
Lance Chaney
Hello there,
I’m not able to reproduce this on 5.4 or 5.6.
Would you mind if I ask for a minimal repro project?
Best regards,
Chris
Posed missed steps and minimal repro project below.
Thank you for the repo project.
Unfortunately, I’m not able to get an assert on this.
Would you mind if I ask what hardware and driver version this is occurring on?
Best regards,
Chris
My main is running the studio version of 576.02 on an RTX 3060 with 24GB VRam, CPU is a Threadripper Pro 5955WX 16 core, and have 128 GB of ram. Also put this project together on my laptop running a laptop 40900 16GB on 573.22, with an i9-13900H. We’ve had several people hitting this issue quite regularly, can’t speak to what drivers and exact systems everyone else has but the two of mine should be fairly indicative of most of us. I do know no one has an AMD GPU currently.
Updating to latest drivers I’m still able to go from assert/no assert toggling r.RayTracing.LightFunction on/off respectively.
Hi there,
I’ve picked up your case while Chris is away. I’ve also not had any luck reproducing this though. Do you have any engine code changes on your side that might be affecting this? Can you reproduce the issue in a launcher version of the engine?
I’ve tested your repro project in UE 5.4.4 (launcher version) on a laptop running an RTX 4080. From looking at the code, it looks like the main way this might happen is if one of the required uniform buffers is somehow null. But, without being able to reproduce the issue, it’s very hard to track down what might be causing this. Are there any other reproduction steps that need to be taken, other than just opening the repro project you sent?
Regards,
Lance Chaney
The above project and steps were done in Vanilla unreal from the launcher, 5.4.4.
The cause of this bug is most likely that inside FLightFunctionRayTracingShader::GetShaderBindings the add shader binding for GetUniformBufferParameter<FDeferredLightUniformStruct>() fails because it is unbound. The referenced structure does not appear in the compiled shader in any way. Give it’s position that is the most likely missing index 1 that the assert is complaining about when its final bits are 11101.
Second possibility is that the RaytracingLightGridData buffer has been compiled down to just a single member as RaytracingLightGridData_SceneLights, but I’d expect that is the final index not the second one and FMeshDrawSingleShaderBindings::Add is already managing that as a common optimization. Which leaves only the missing FDeferredLightUniformStruct that the Ray Tracing Miss Lighting Function Shader seem to be expecting as the culprit from my digging.
The repro project is the default 3rd person desktop c++ w/raytracing project with an added light material function on the Directional light that passes white into the emissive with the following settings added to the DefaultEngine.ini
r.RayTracing=True
r.RayTracing.UseTextureLod=False
r.RayTracing.NonBlockingPipelineCreation=True
r.RayTracing.Culling=3
r.RayTracing.Culling.Radius=20000
r.RayTracing.Culling.Angle=1
r.RayTracing.Culling.UseGroupIds=0
r.RayTracing.Geometry.NiagaraRibbons=0
r.RayTracing.Geometry.NiagaraSprites=0
r.RayTracing.Geometry.NiagaraMeshes=0
r.RayTracing.ExcludeTranslucent=True
r.RayTracing.ExcludeTranslucent=1
r.RayTracing.Shadows.AvoidSelfIntersectionTraceDistance=100
r.RayTracing.NormalBias=1
r.RayTracing.Geometry.InstancedStaticMeshes=1
r.RayTracing.Geometry.Landscape=0
r.RayTracing.Geometry.StaticMeshes.WPO=1
r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius=2000
r.RayTracing.ExcludeDecals=1
r.RayTracing.Shadows.AcceptFirstHit=1
r.RayTracing.Geometry.NaniteProxies=1
r.RayTracing.SceneCaptures=0
r.Lumen.Reflections.Allow=1
r.Lumen.Reflections.DownsampleFactor=1
r.Lumen.Reflections.RadianceCache=1
r.Lumen.HardwareRayTracing.LightingMode=3
; Core Repro Settings
r.Lumen.HardwareRayTracing.LightingMode=3 ; Set to 0, 1, or 2 to run successfully
r.Lumen.HardwareRayTracing=1 ; Set To 0 to run successfully
r.RayTracing.Shadows=1 ; Comment out to run successfully
;r.RayTracing.LightFunction=0 ; Uncomment to run successfully
After that lighting function is present with these settings I’m seeing this 100% of the time, in vanilla 5.4.4, across multiple machines.
Thanks will put that in and give it a try.
Great, let me know how you get on.