# Intel G41 Card can not index uniform array variables with a variablefragment shaders?

## Recommended Posts

Look this:

....
struct Light
{
...
}
uniform Light u_lights[4];
for(int i = 0 ; i<4 ;i++)
{
...
//Then use i index u_lights array.
totalSpecularColor += u_lights[i].specular *specular_bsdf;//Then GLSL can not get u_lights[i].specular vaule
When I write like this: u_lights[0].specular ,then I can get the value. why? Help me,please.
...
}


##### Share on other sites

The G41 is a very old OpenGL 2.0 era GPU, and there were many limitations in that era.
One common limitation is the inability to dynamically index arrays from within fragment shaders.

So array where i changes its value will not work...
but array[1] where 1 obviously always has the same value, will work.

There is no fix for this. On these old GPU's you will have to use a different kind of algorithm.

##### Share on other sites

The G41 is a very old OpenGL 2.0 era GPU, and there were many limitations in that era.
One common limitation is the inability to dynamically index arrays from within fragment shaders.

So array where i changes its value will not work...
but array[1] where 1 obviously always has the same value, will work.

There is no fix for this. On these old GPU's you will have to use a different kind of algorithm.

Thank you very much.So ,I have to make many shaders for multilight.My fucking boss wanted the app compatiale with this old hardwarw ...

##### Share on other sites

If the amount of light is fixed, then the static indexing for arrays shouldn't be that much of an issue.

##### Share on other sites

the problem is with intel gcards at all, i think nvidia should take control over the market :P

##### Share on other sites

If the amount of light is fixed, then the static indexing for arrays shouldn't be that much of an issue.

But G41 not :(

## Create an account

Register a new account