[osg-users] problem using uniform arrays
Jean-Sébastien Guay
jean-sebastien.guay at cm-labs.com
Mon Feb 4 12:09:37 PST 2008
Hello Roni,
>> For example indexing an array like this:
>> arr[ind]
>> works fine for the vertex shader, but doesn't compile on the fragment
>> shader, saying that the index has to be constant, so that arr[ind] is
>> not
>> allowed, but arr[3] is ok.
>> However, since I'm using long arrays (70 elements), I don't know how
>>
> to
>
>> work
>> around this limitation.
>> Any ideas
Stupid suggestion, perhaps you can do this? (not sure you can pass an
array to a function, but worth a try...)
vec4 indexArray(vec4[n] array, int i)
{
if (i == 0) return array[0];
if (i == 1) return array[1];
// ...
// error add more indices to the function!
}
Then call
vec4 value = indexArray(arr, ind);
Just to work around the limitation...
Let me know if you try this, I'd be interested to know if it works.
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-sebastien.guay at cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
More information about the osg-users
mailing list