0

I need to pass an array of Vector3 or Vector4's to my pixel shader. Is there something like a one dimensional texture that I can set from the CPU and sample on the GPU?

Mr Bell
  • 9,228
  • 18
  • 84
  • 134
  • How about a 1 dimensional Texture2D? Texture2D SimpleTexture = new Texture2D(GraphicsDevice, 1, 100, false, SurfaceFormat.Color); – Elideb Nov 16 '11 at 17:29
  • Yeah, I was thinking that too, but it limits you to no more than 4096 in either dimension and i need something like 76,800 entries – Mr Bell Nov 16 '11 at 18:14
  • 1
    Was it really necessary to ask ***6*** questions in a row about how to do this? – Andrew Russell Nov 17 '11 at 01:58
  • possible duplicate of [What does the pixel shader function tex1D do with a Texture2d](http://stackoverflow.com/questions/8157722/what-does-the-pixel-shader-function-tex1d-do-with-a-texture2d) – Neil Knight Nov 17 '11 at 10:58
  • 1
    While my recent batch of questions are similar I think that individually they are asking about different things. For instance in Neil's call out I am asking about the functionality of tex1D and in this one I am asking if there is a 1d data structure. The way I figure someone might know if there is a 1d texture, but might not be familiar with the workings of hlsl function tex1d() – Mr Bell Nov 17 '11 at 15:12

1 Answers1

0

No there is no built-in class that you can use, but you can create your own one (untested):

public class Texture1D
{
    GraphicsDevice device;
    Vector4[] pixels;

    bool mipMap = false;
    SurfaceFormat Format;

    public Texture1D (GraphicsDevice Device, int Length)
    {
        pixels = new Vector4[Length];
        device = Device;
        Format = SurfaceFormat.Color;
    }

    public Texture1D (GraphicsDevice Device, int Length, bool mipMap, SurfaceFormat format)
    {
        pixels = new Vector4[Length];
        device = Device;
        this.mipMap = mipMap;
        Format = format;
    }
}
annonymously
  • 4,708
  • 6
  • 33
  • 47