Accessing SceneColor in HLSL in Surface Material Domain

Hiii!!
For a shader I’m setting up, I need to sample SceneColor through HLSL in a Custom Expression. I am doing this in a translucent surface material, not in a post-process material. I am offsetting the UVs that are used to sample the SceneColor in a for-loop, so using a SceneColor node as an input variable is not an option.
However, I have been unable to find an HLSL function that samples SceneColor without using SceneTexture - which I can’t use as it’s not a post-process material.
I’ve tried using CalcSceneColor, but this function does not appear to be working - at least not in UE5.4.4.

I’d love to know if anybody knows of a way to access SceneColor at a given UV coordinate in HLSL.

This is what the SceneColor node outputs to HLSL:

float4 DecodeSC = DecodeSceneColorAndAlpharForMaterialNode(ScreenAlignedPosition(GetScreenPosition(Parameters)));
return lerp(DecodeSC.rgb,Material.PreshaderBuffer[0].yzw,Material.PreshaderBuffer[0].x);

I tested it in a custom node and it works. Similar to sampling SceneTexture in a custom node, you need to have SceneColor plugged into an input for this to work. (You do not need to actually use the input)

1 Like