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];
...
1 个解决方案
#1
3
I think you can't pass structures to OpenGL ES shaders. Please check this SO discussion that seems to confirm it:
我认为你不能将结构传递给OpenGL ES材质。请检查,所以讨论似乎证实:
Passing own struct into opengl es 2.0 shader
将自己的结构体传递给opengl es 2.0着色器
I think it's safer to use your second proposal based on the arrays of vec4 uniforms.
我认为你的第二个建议是基于vec4制服的阵列比较安全。
#1
3
I think you can't pass structures to OpenGL ES shaders. Please check this SO discussion that seems to confirm it:
我认为你不能将结构传递给OpenGL ES材质。请检查,所以讨论似乎证实:
Passing own struct into opengl es 2.0 shader
将自己的结构体传递给opengl es 2.0着色器
I think it's safer to use your second proposal based on the arrays of vec4 uniforms.
我认为你的第二个建议是基于vec4制服的阵列比较安全。