Any way to access the SceneTexturesStruct from inside a PostProcess shader?

I’m currently modifying the engine source to make some additions/alterations to the renderer. One thing I’d like to be able to do is alter certain aspects of the Post Processing part of the rendering. Specifically, I’m trying to figure out if I can access the SceneTexturesStruct (containing GBuffer data etc.) during one of the Post Processing global shaders.

For example, I’m trying to include a line like this inside PostProcessTonemap.usf:


float3 Mask = Texture2DSample(SceneTexturesStruct.SceneDepthTexture, SceneTexturesStruct.SceneDepthTextureSampler, SceneUV).rgb;

However, when I run this, I get the following error:


Fatal error: [File:C:\Users\X\Documents\GitHub\UnrealEngine\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11Commands.cpp] [Line: 1508] 
Shader expected a uniform buffer of struct type SceneTexturesStruct at slot 2 but got null instead.  Rendering code needs to set a valid uniform buffer for this slot.

I’m in a bit over my head here, but it seems like the SceneTexturesStruct isn’t available to this shader, so I’m wondering whether its actually possible to make it accessible? Or am I way off base here?!

It’s been awhile, but did you ever figure this out? I’m currently having the same issue and I’m trying to follow along how other FGlobalShaders do it.

Thanks,

One year later, one more sad guy looking for solution to this.

A month has passed and yet another sad guy looking for a solution once again

@Meigetu it looks like this sad guy has solved the riddle, here is what I did:

First I included the structure holding all those guys:



SHADER_PARAMETER_STRUCT_REF(FSceneTexturesUniformParameters, SceneTexturesUniform)


Then inside the Pass code you can bind them like this:



//~ Bind SceneTexturesStruct thingy
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(GraphBuilder.RHICmdList);
PassParameters->RimParams.SceneTexturesUniform = CreateSceneTextureUniformBuffer(SceneContext, View.FeatureLevel, ESceneTextureSetupMode::All,EUniformBufferUsage::UniformBuffer_SingleFrame);


Inside my shader I was able to access the AO texture, so it is safe to assume is working:



FScreenSpaceData ScreenSpaceData = GetScreenSpaceData(Input.UV, false);
float AO = ScreenSpaceData.AmbientOcclusion;
OutColor =  float4(AO,AO,AO,1.0);


:smiley: time to rock guys, cheers

Another sad guy wondering how you did those things. Where did you include this and does this also work in material functions?