in my fragment shader I have some uniform arrays like
this for my directional and positional light sources:
#define MAX_LIGHT_SOURCES 8
uniform vec4 LSAmbientGlobal;
uniform vec4 LSAmbient[MAX_LIGHT_SOURCES];
uniform vec4 LSDiffuse[MAX_LIGHT_SOURCES];
uniform vec4 LSSpecular[MAX_LIGHT_SOURCES];
uniform vec4 LSPosition[MAX_LIGHT_SOURCES];
uniform vec3 LSNearFarAttenuation[MAX_LIGHT_SOURCES];
uniform int LSCount;
uniform vec4 MatAmbient;
uniform vec4 MatDiffuse;
uniform vec4 MatSpecular;
uniform float MatShininess;
There should be at least 64 uniform floats available
and according to this statistics there are at least
two ATI Mobility cards with only 64 uniform floats.
Now my question:
The code above would exceed this limit of 64 floats.
I do not really care about these cards but a general
question raised up for me. If I want a lot of lights
(maybe even more than 8), how to bypass this limitation?
Anyone knows a good tutorial with some sample code
that targets this limitation?
Help is really appreciated!
Deffered lighting. you could store the light data into a texture and read from it.
multipass with additive blending rather than trying to do all the calculations in the shader.
There’s probably more but those are the ones that came to mind.
I ran into the same problem a few months back, although I hit the limit on varying parameters… Shadowmapping space limitations brought the forward approach to its knees.
In short, the (a) way to go is deferred rendering:
I’ve had great success with it:
I have only good things to say about how the deferred approach simplified my shader setup. I guess it has some achilles heels (transparency, for instace), but…
Yeah, also consider whether you need MSAA. Research carefully before you just decide to go Deferred Shading. Like everything, has it’s pros and cons.
Also consider whether Deferred Lighting (Light Pre-Pass) is what you’d rather have, or whether it might be more efficient for you.
Also consider whether you’ll really have 8 simultaneous lights, or whether that’s an extreme example you’ll almost never see, and can work around if you ever do.