如何找到 OpenGL es 2.0 顶点着色器专业版中所有制服的列表
我正在尝试学习如何对顶点着色器进行编程。在苹果的示例项目中,他们有一行来设置 a
glUniform1f(uniforms[UNIFORM_TRANSLATE], (Glfloat)transY);
然后这个值用于
// value passt in f
// glUniform1f(uniforms[UNIFORM_TRANSLATE](Glfloat)transY);
uniform float translate;
void main()
{
gl_Position.y+=sin( translate);
…
我无法找到所有制服的所有制服的列表。
有谁知道我在哪里可以找到所有制服的列表以及一本关于学习如何对顶点着色器进行编程的好书或教程。
I'm trying to learn how to program vertex shaders. In Apple's sample project they have a line to set a
glUniform1f(uniforms[UNIFORM_TRANSLATE], (Glfloat)transY);
Then this value is used in
// value passt in f
// glUniform1f(uniforms[UNIFORM_TRANSLATE](Glfloat)transY);
uniform float translate;
void main()
{
gl_Position.y+=sin( translate);
…
I was unable to find a list of all uniforms of all the uniforms.
Does any one know where I can find a list of all the uniforms and a good book or tutorial on learning how to program vertex shaders.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
统一参数是传递给GL着色器的数据,在绘制调用期间不会改变。
您可以使用以下代码查询链接的 GLSL 程序以获取活动制服列表:
此代码检索许多活动制服并迭代它们,提取名称、类型、值的数量和制服位置。
Uniform parameter is a data passed to GL shader, which doesn't change during the draw call.
You can query a linked GLSL program for a list of active uniforms with the following code:
This code retrieves a number of active uniforms and iterates though them, extracting name, type, number of values and uniform locations.
除了kvark的回答之外。您可以添加这些代码行来获得不错的结果
以及最常见制服的美观易读的格式:
In addition to kvark's answer. You can add these lines of code to get a nice
and beautiful readable format of the most common uniforms:
我认为在该示例代码中,UNIFORM_TRANSLATE 被定义为 0,然后有这样的代码:
因此所有制服都按其名称检索 - 在本例中为“位置”。
I think in that example code, UNIFORM_TRANSLATE is defined to 0, and then there's code like this:
so all the uniforms are retrieved by their names -- "position" in this case.