#Texture2DArray in custom function hlsl

1 messages · Page 1 of 1 (latest)

ancient lichen
#

Hello, I send a Texture2DArray into a custom function used by the shader graph on HDRP (Unity 6). And I don't find the correct way to sample it 🥲
Can someone share the code with me ?

Thanks a lot !

icy prairie
#

Should be something like SAMPLE_TEXTURE2D_ARRAY(texName, texName.samplerstate, uv, index)

ancient lichen
ancient lichen
#

I'll had a code sample just in case :

void Test_float(
    Texture2DArray textureArray,
    float2 uv,
    out float4 result)
{
    result = SAMPLE_TEXTURE2D_ARRAY(textureArray, sampler_tex, uv, 0);
}
icy prairie
#

The intention being that while Texture2DArray is the usual hlsl-type, Unity added a bunch of UnityX texture structs so that the texture and SamplerState object associated with it can be passed around in shadergraph together

ancient lichen
#

Ohoh, I tried and looks like texName.samplerState does exist with the no Bar Texture 2D Array.
Thanks !
I'll do a few more test later to be sure.

icy prairie
#

Yeah, should be that
"Bare Texture 2D Array" = Texture2DArray
"Texture 2D Array" = UnityTexture2DArray which stores .tex & .samplerstate

In older versions you had to always pass a SamplerState as a separate parameter and could only use the Sampler State node in graph (what we'd call an "inline sampler state" in code)