Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top