0
\$\begingroup\$

If I call tex1d from my pixel shader on a texture that has been initialized as a texture2d will it treat the data as a one dimensional array and then just take the element at whichever position you specify?

For instance if you have a 10 x 10 texture(that would be a one dimensional array 100 elements in length) and you call tex1d(mySampler, 0.95) will it give you back element 95?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

I think you will find this quote (regarding DirectX 9, which is what XNA is built on) relevant:

Because the runtime does not support 1D textures, the compiler will use a 2D texture with the knowledge that the y-coordinate is unimportant. Since tex1D(s, t) (DirectX HLSL) is implemented as a 2D texture lookup, the compiler is free to choose the y-component in an efficient manner.

In other words: you specify the X coordinate, and the Y coordinate is undefined.

From here.

So, no, it won't unwrap the indices. But you already got an answer about how to do that.

\$\endgroup\$
0
\$\begingroup\$

I haven't used XNA, but my guess is that calling tex1D on a 2D texture (or more generally any mismatch between the dimensionality of the sampling function and the actual texture being sampled) is an error, and will probably return some default value like black.

\$\endgroup\$
2
  • \$\begingroup\$ Do you know how I could access the Nth element of a texture2d? \$\endgroup\$
    – Mr Bell
    Commented Nov 16, 2011 at 22:38
  • \$\begingroup\$ @MrBell see my answer to your other question. \$\endgroup\$ Commented Nov 16, 2011 at 22:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .