3

I want to implement some kind of lighting. And i'm making a struct, that contains light sourse properties in vertex shader:

struct Light
{
    vec4 color;
    vec4 pos;
    ...
};

In my app i want to have several light sources. So i put:

uniform Light[10];

How can i then load these uniforms from the app ? Is it a good approach or better to have:

uniform vec4 LightColor[10];
uniform vec4 LightPos[10];
...
Sergey K.
  • 24,894
  • 13
  • 106
  • 174
Andrew
  • 24,218
  • 13
  • 61
  • 90
  • possible duplicate of [Passing own struct into opengl es 2.0 shader](http://stackoverflow.com/questions/4110123/passing-own-struct-into-opengl-es-2-0-shader) – Sergey K. Jul 22 '13 at 09:33

1 Answers1

3

I think you can't pass structures to OpenGL ES shaders. Please check this SO discussion that seems to confirm it:

Passing own struct into opengl es 2.0 shader

I think it's safer to use your second proposal based on the arrays of vec4 uniforms.

Community
  • 1
  • 1
JimN
  • 713
  • 1
  • 6
  • 8