创建统一的GLSL数组? [英] Creating a GLSL Arrays of Uniforms?

查看:95
本文介绍了创建统一的GLSL数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想离开OpenGL的灯,自己做. 我希望我的着色器允许可变数量的灯光.

I would like to leave OpenGL's lights and make my own. I would like my shaders to allow for a variable number of lights.

我们可以在GLSL着色器中声明一个统一数组吗? 如果是这样,我们将如何设置这些制服的值?

Can we declare an array of uniforms in GLSL shaders? If so, how would we set the values of those uniforms?

推荐答案

是可以的.您声明的统一数组类似于在C中的方式,例如

Yes this is possible. You declare uniform arrays similar to how you'd do it in C, e.g.

uniform float v[10];

然后您可以使用glUniform{1,2,3,4}{f,i}v

GLfloat v[10] = {...};
glUniform1fv(glGetUniformLocation(program, "v"), 10, v);

这篇关于创建统一的GLSL数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆