Hi folks,
I ran into a bit of head aching confusion while trying to pass an array of - let's say - integer values to a GLSL shader. I'd really appreciate if someone could explain me the proper way of doing this. What I tried right now was this:
First i write a neat little shader (I'll skip the vertex shader since it's not relevant):
Code: Select all
varying vec2 UV;
uniform int MYARRAY[64];
void main(void)
{
gl_FragColor = texture2D(MYARRAY[4], UV);
}
Code: Select all
material Test
{
technique
{
pass
{
lighting on
ambient 0 0 0 1
specular 0 0 0 1
diffuse 0 0 0 1
emissive 1 1 1
fragment_program_ref LightSourceCompositePreviewShaderF
{
param_named MYARRAY int64 0 # Tried, didn't work
param_named MYARRAY int[] 0 # Again, no luck with this
param_named MYARRAY int[64] 0 # Then i ran out of ideas...
}
vertex_program_ref LightSourceCompositePreviewShaderV
{
}
}
Code: Select all
int uMyArrayValues[64];
.... // Fill the array
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
params->setNamedConstant("MYARRAY", uMyArrayValues, 1, 64); // Didn't work
params->setNamedConstant("MYARRAY[0]", uMyArrayValues, 1, 64); // I also tried this...
// and even this:
for(int i=0;i<64;++i) {
params->setNamedConstant("MYARRAY[i]", uMyArrayValues[i]); // I know i need to do string formatting here, I just wrote it to make it more clear what i'm doing.
}
If someone could enlighten me here a bit I would be really, really grateful
Thank you very much in advance!