Easier way to use Texture2D array in shader

421 Views Asked by At

I want to use Texture2D array by easier way in PixelShader.

That is,

PS

Texture2D map[3] : register(0);

if (input.index == 0)
    color = map[input.index].Sample(samp, input.uv);
else if (input.index == 1)
    color = map[input.index].Sample(samp, input.uv);
else
    color = map[input.index].Sample(samp, input.uv);

But it brings me error, so I use instead like this.

PS

if (input.index == 0)
    color = map[0].Sample(samp, input.uv);
else if (input.index == 1)
    color = map[1].Sample(samp, input.uv);
else
    color = map[2].Sample(samp, input.uv);

Is it the best way to use texture2D in array like this?

0

There are 0 best solutions below