Imagination PowerVR SDK Blog

uniform array of structures


Hi all
to implement lighting I have an uniform array of structures which is


uniform struct lightStruct{
    int enabled;
    vec2 attenuation;
    vec3 color;
    vec3 pos;

(NUM_LIGHTS is eight)
And to get the locations i use this code:


The locations seem to be correct as they form a contiguous set of integers.
However, when I set for example the value of u_lightEnabled_loc[5] using glUniform1i(u_lightEnabled_loc[5],x), the "enabled" field of all lights is set to x. What am I doing wrong?
Thanks in advance.


This could be a driver bug. Which platform are you using?

If it really is a driver bug, a simple workaround would be to drop the struct and use four plain arrays.


 I use a Sony Ericsson Satio (TI Omap 3430 with SGX530) , OS is Symbian. I’ll try out the simple array version, thanks Smile

3DGamer wrote:
Hi all
to implement lighting I have an uniform array of structures which is

this bothers me. POwerVR seems not to follow the lights exported from a 3ds MAx design. Is this a known limitation ? What was 3DGamer talking about with his struct ?

Thank you


The use of a struct in this case is purely to make the shader code a little cleaner and easier to read. It does not affect the functionality that is available in the shader.

This appears to be a bug on this particular device, but other devices with SGX cores and different drivers may not have the same issue.