Is there (or will there) be support for
non-constant array indices in shader programs?
For example, in my app code I want to do this:
int numItems = 10;
float * myArray = new float[numVecs];
… // Set some values in myArray
glUniform1iARB (glGetUniformLocationARB (progObj, “num”), numItems);
glUniform1fvARB (glGetUniformLocationARB (progObj, “inArray”), numItems, myArray);
And then in my vertex shader, I want to do this:
uniform int num;
uniform float inArray[num]; /// Will this work?
void main (void)
{
int i = 0;
int j = 0, k = 0;
for (i = 0; i < num-1; i++)
{
if (inArray[i] <= gl_Vertex.y && inArray[i+1] >= gl_Vertex.y)
{
j = i;
k = i+1;
}
}
/// Then use j & k for other stuff
...
}
I tried, with ATI’s 4.3 drivers on my 9600 card, hardcoding my uniform array in my
vertex shader since I knew in my app how
large my array is going to be:
uniform int num;
uniform float inArray[10];
But I get a compilation error saying that
some feature is not supported or something
like that.
What I’m trying to do is pass some fairly
large arrays (maybe 5 or 6 arrays with up
to 300+ items in each array) that have been
precomputed in my application, somehow pass
them to my vertex shader, and have my shader
use these arrays as lookups to do its
calculations.
[This message has been edited by Jixer (edited 03-18-2004).]