[英]GLSL ES equivalent to OpenGL GLSL 'out' keyword?
I have a vertex shader which works fine on Windows with OpenGL. 我有一个顶点着色器,可以在Windows上使用OpenGL正常工作。 I want to use the same shader on an iPad which supports OpenGL ES2.0. 我想在支持OpenGL ES2.0的iPad上使用相同的着色器。
Compilation of the shader fails with: 着色器的编译失败了:
Invalid storage qualifiers 'out' in global variable context
From what I have read, the 'out' keyword required GLSL 1.5 which the iPad won't support. 根据我的阅读,'out'关键字需要GLSL 1.5,iPad不支持。 Is there an equivalent keyword to 'out' that I can use to pass the color into my fragment shader? 是否有一个等效的'out'关键字可用于将颜色传递给我的片段着色器?
attribute vec4 vPosition;
attribute vec4 vColor;
uniform mat4 MVP;
out vec4 pass_Color;
void main()
{
gl_Position = MVP * vPosition;
pass_Color = vColor;
}
This vertex shader is used by me to create gradient blends, so I'm assigning a color to each vertex of a triangle and then the fragment shader interpolates the color between each vertex. 我使用这个顶点着色器来创建渐变混合,因此我将颜色分配给三角形的每个顶点,然后片段着色器在每个顶点之间插入颜色。 That's why I'm not passing a straight color directly into the fragment shader. 这就是我没有直接将颜色直接传递到片段着色器的原因。
Solved! 解决了! In GLSL ES 1.0 that I'm using, I need to use 'varying' instead of 'in' and 'out'. 在我正在使用的GLSL ES 1.0中,我需要使用'vary'而不是'in'和'out'。 Here's the working shader: 这是工作着色器:
attribute vec4 vPosition;
attribute vec4 vColor;
uniform mat4 MVP;
varying vec4 pass_Color;
void main()
{
gl_Position = MVP * vPosition;
pass_Color = vColor;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.