# Accessing SceneColor in HLSL in Surface Material Domain

**URL:** <https://forums.unrealengine.com/t/accessing-scenecolor-in-hlsl-in-surface-material-domain/2010683>\
**Category:** Rendering\
**Tags:** unreal-engine, Shaders, hlsl, question\
**Created:** [September 7, 2024, 10:09pm UTC](https://forums.unrealengine.com/t/accessing-scenecolor-in-hlsl-in-surface-material-domain/2010683 "2024-09-07T22:09:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlueBendyPencils](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BlueBendyPencils](https://forums.unrealengine.com/u/BlueBendyPencils)\
**Post date:** [September 7, 2024, 10:09pm UTC](https://forums.unrealengine.com/t/accessing-scenecolor-in-hlsl-in-surface-material-domain/2010683/1 "2024-09-07T22:09:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Arkiras](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkiras/32/1008648_2.png) [@Arkiras](https://forums.unrealengine.com/u/Arkiras)\
**Post date:** [September 8, 2024, 1:21pm UTC](https://forums.unrealengine.com/t/accessing-scenecolor-in-hlsl-in-surface-material-domain/2010683/2 "2024-09-08T13:21:22Z")

</div>

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)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/e/7bead35c76a302b4da10739262fa744eee9c6c8c.png)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [October 8, 2024, 1:22pm UTC](https://forums.unrealengine.com/t/accessing-scenecolor-in-hlsl-in-surface-material-domain/2010683/3 "2024-10-08T13:22:16Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
