Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by carterjiaojiao May 16, 2017 at 3:14 AM 4 replies 1.4k views
Original Post
carterjiaojiao
carterjiaojiao

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.
   ...
}
Hodgman
Hodgman

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.

carterjiaojiao
carterjiaojiao

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 ...

cgrant
cgrant

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

carterjiaojiao
carterjiaojiao

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

But G41 not :(

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.