Non-Image Data Array Into GLSL

Sorry for the naive newbie question, but is it possible to get an array of data into a GLSL Vertex Shader in some form other than as a Sampler2D/Image? I ask because I’d like to be able to move vertices around using luminance information from an input image, but I understand the Sampler2D data-type is only supported in the Vertex Shader on certain hardware.

I’m therefore wondering if it would be possible to create an array of some descripton from, say, the pixels of a single line of an image, and then somehow pass that into a Vertex shader.
I’d ultimately like to be able to generate a line, composed of vertices displaced on, say the, the Y-Axis by the luminance of an input image, and textured with a single line of the input image. I’d then iterate over the same shaders with each line of the image.

This is all very sketchy at the moment, and I have almost no experience of GLSL or OpenGL. I’m really just testing the water at the moment, but wondering if anyone with more experience could give me some hints on whether my plan could be carried out, and on how I might go about achieving the effect I’m after.

Cheers guys,

alx

If the amount of data you pass is relatively small (fewer than 256 vec4) you can use an array of uniforms, which you can index into in the vertex shader. All SM2.0 level hardware supports that.

Hi Humus,

thanks for getting back to me on this.
Would I need to use more than one array of vec4s in order to pass more than 256 RGBA values, or is there another way of doing this? Also, I wonder if there is a performance hit in passing large multi-dimensional arrays into the Vertex shader?

Sorry for all the questions- as I said, I’m new to all this, and want to investigate the possibilities before getting down to the actual coding.

Thanks again,

alx

If you pass more than 256 vec4s you’ll run out of constant register space resulting in software rendering. Putting it into several arrays doesn’t help. The input size is simple limited on the hardware level.

DX10 level hardware would be able to do more though, but then you might as well use textures since that’s fast on DX10 hardware.