Calling GetGBufferData inside a custom node in a post-process material crashes the editor

Hi there,

I am trying to access some gbuffer data in a post process material. In particular i would like to access PerObjectGBufferData which is stored in GBufferA.a. We would like to use these two bits for some custom effects (overriding the default behaviour: cast contact shadow + capsule representation). To do that I used GetGBufferData(UV).PerObjectGBufferData inside a custom node in a post process material. Unfortunately, as soon as I compile the material the engine crashes with the error reported below.

Even if I try something like GetGBufferData(UV).WorldNormal, I still get the same error despite the fact that SceenTextureLookup basically does the same thing (GetScreenSpaceData -> GetGBufferData).

So the question is: how can I access PerObjectGBufferData in a post process material?

Thanks a lot

Assertion failed: false [File:D:\build\++UE5\Sync\Engine\Source\Runtime\RHICore\Private\RHICoreShader.cpp] [Line: 60] 
Shader attempted to bind uniform buffer 'FOpaqueBasePassUniformParameters' at slot [Name: SceneTextures, Slot: 9] with hash '158338568', but the shader expected 'LumenFrontLayerTranslucencyGBufferPass' with hash '441254321'.

Steps to Reproduce

  • Open the attached project
  • open `TestMap`
  • Open `M_PP`
  • Uncomment the code in the custom node
  • Click apply
  • Observe the crash

Hello,

Thank you for reaching out.

I’ve been assigned this issue, and we will be looking into this use of Custom Material Expressions for you.

I think i found how to make it work. Adding this #if before calling getgbufferdata fixes it

#if !SCENE_TEXTURES_DISABLED && !SUBSTRATE_ENABLED && PIXELSHADER && !RAYCALLABLESHADER

Hello,

“SceneTextureLookup(…)” handles various permutation cases, and not all of those use “GetGBufferData(…)”, because not all of the permutations use the GBuffer bindings.

If you want to use “GetGBufferData(…)” directly, you need to handle the same permutations. Here is some sample code showing that:

#if SHADING_PATH_DEFERRED
#if POST_PROCESS_MATERIAL
#if !SCENE_TEXTURES_DISABLED
#if !SUBSTRATE_ENABLED
 
float2 UV = GetDefaultSceneTextureUV(Parameters, PPI_WorldNormal);
FGBufferData GBData = GetGBufferData(UV);
return GBData.WorldNormal;
 
#endif //!SUBSTRATE_ENABLED
#endif //!SCENE_TEXTURES_DISABLED
#endif //POST_PROCESS_MATERIAL
#endif //SHADING_PATH_DEFERRED
 
return float3(0,0,0);

Keep in mind that Custom Material Expressions allow injection of any HLSL into a Material’s shader, even if that can lead to errors or crashes.

Please let us know if this helps.