Cannot access Substrate GBuffer in Adaptive mode from Ray Gen Shaders.

We have an Raygen Shader that also needs to sample the GBuffer. This wasn’t a problem at all with the legacy GBuffer or Blendable, but the current design around the adaptive GBuffer appears to make this not possible within the same shader (and pass).

The issue is with FSubstrateMaterialContainer and FSubstrateTopLayerDataContainer being macros depending on SUBSTRATE_MATERIALCONTAINER_IS_VIEWRESOURCE, which in turn cause UnpackSubstrateHeaderIn() and UnpackSubstrateBSDF() to be compiled only with one type.

This design is really problematic. We basically cannot handle FSubstrateRaytracingPayload if we have viewresource enabled. If viewresource is disabled, then we can’t decode the GBuffer.

  • Are there any plans to address this in the future?
  • Maybe move this onto templated types instead?

I also noticed that the substrate data in FSubstrateRaytracingPayload is limited to the payload size. Does that mean we can’t really use complex materials if encoding them would exceed this size?

Thanks!

Ernesto.

[Attachment Removed]

Steps to Reproduce

  • Configure Unreal with Substrate Enabled and Adaptive GBuffer.
  • Build a RGS shader that both handles substrate payload decoding and tries to access the substrate GBuffer.
  • If SUBSTRATE_MATERIALCONTAINER_IS_VIEWRESOURCE is 1, we can’t unpack the data from FPackedMaterialClosestHitPayload SubstrateData.
  • If SUBSTRATE_MATERIALCONTAINER_IS_VIEWRESOURCE is 0, we can’t unpack the data from Substrate.MaterialTextureArray.
    [Attachment Removed]

Hello,

Apologies for the delay, unfortunately our experts on this topic are unavailable until after the summer break (July 13). From my analysis of the code in question it does appear that you are correct about the limitations, but we’ll need to wait for my colleagues to comment on future plans.

[Attachment Removed]