Custom Node in postprocessing

Hio. I’m trying to read a texture from the gbuffer (PostProcessInput0 in particular) from within a Custom Node.

I tried sampling directly with Texture2DSample(PostprocessInput0, uv) but PostprocessInput0 was not defined for my Custom Node. I also tried using a Custom Texture node in order to bring the sampler into my code, but the browser in that node only lets me pick texture assets, not buffers/textures from gbuffer.

I want to create (this part of) my shader/material with a Custom Node (instead of graphically with several nodes-wires) because I want to implement a complex loop and put my sampling inside of it.

How is the way to get this to work?

If I remember correctly the trick was to add a dummy SceneTexture node as an input to your Custom Node. You don’t have to use it, it’s just to get the PostProcessInputX samplers and textures included.

This works since the SceneTexture node sets the define NEEDS_SCENE_TEXTURES which makes this code work:

MaterialTemplate.usf line 854

#include "PostProcessCommon.usf"			// PostprocessInput0

Stumbled upon this thread when trying to do this task in 4.18 - plugging a scene texture node as a dummy input works but in order to sample from the Scene Textures you now have to use this function

SceneTextureLookup(UV, 14, false);

1: UV input
2: index of the scene texture you wish to lookup (14 corresponds to PostProcessInput0)
3: Filtered

Hope this helps someone else