Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLSL ES equivalent to OpenGL GLSL 'out' keyword?

I have a vertex shader which works fine on Windows with OpenGL. I want to use the same shader on an iPad which supports OpenGL ES2.0.

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. Is there an equivalent keyword to 'out' that I can use to pass the color into my fragment shader?

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.

like image 368
SparkyNZ Avatar asked Oct 19 '22 09:10

SparkyNZ


1 Answers

Solved! In GLSL ES 1.0 that I'm using, I need to use 'varying' instead of 'in' and '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;
}
like image 116
SparkyNZ Avatar answered Nov 15 '22 06:11

SparkyNZ