0
\$\begingroup\$

I was trying to use a texture as a variable in my shader (DX11 VS/PS 5.0). Can't get it. I have recently find this piece of code here where a texture is passed as a function parameter. Is that compatible with DX11 VS/PS 5.0 and can I transform this to have in a ps shader a texture as variable that I can modify on demand in a loop (for or while).

kernel void kernel_createHiZ(texture2d<float, access::read> depth [[ texture(0) ]],
                     texture2d<float, access::write> outDepth [[ texture(1) ]],
                            uint2 tid [[thread_position_in_grid]])
\$\endgroup\$
2
  • \$\begingroup\$ Would you be able to stack the textures you want to switch between into a texture array, and then vary the index into that array? \$\endgroup\$ Commented Apr 19, 2023 at 13:37
  • \$\begingroup\$ Yes surely but I noticed a slow down when using texture arrays. I have finally decided to have 4 textures instead of texture[4] or texturearray with 4 slices. So I'm using a test to select the texture to work with. This was fine with one call in my ps shader with 4 layers to have a minimum depth and the corresponding color. But I was limited in my HiZ search to the main depth buffer with limited results and wants now to make HiZ on the 4 layers. So being able to have a global variable with the selected textures could be nice. \$\endgroup\$ Commented Apr 19, 2023 at 13:54

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.