user2767334
user2767334

Reputation: 31

Array attributes in GLSL 1.3

I'm trying to write a shader for skeletal animation. It compiles and runs fine on my desktop, which has a GeForce 560Ti. On my laptop (with a 650M), however, any shader with the line:

in vec4 boneWeight[4];

fails to compile, with the error: Vertex/perfragskel.vert: ERROR: 4:1: 'attribute 4-component vector of float' : cannot declare arrays of this qualifier

I have seen it written in different places that array attributes are and are not permitted. Should the code compile, or was my old compiler excessively permissive? Is there something I need to set up to make it work? I'm using an opengl 3.0 rendering context. A minimal example is below.

#version 130

in vec4 boneWeight[4];//MAX_BONES/4];    

void main(void)
{
    gl_Position = vec4(0,0,0,0);
}

Upvotes: 1

Views: 1667

Answers (1)

Andon M. Coleman
Andon M. Coleman

Reputation: 43379

I did some digging for you and found this handy bit of information...

Section 4.3.4 Inputs (GLSL 1.3)

Vertex shader input variables (or attributes) receive per-vertex data. They are declared in a vertex shader with the in qualifier or the deprecated attribute qualifier. It is an error to use centroid in in a vertex shader. The values copied in are established by the OpenGL API. It is an error to use attribute in a non- vertex shader. Vertex shader inputs can only be float, floating-point vectors, matrices, signed and unsigned integers and integer vectors. They cannot be arrays or structures.

Section 4.3.4 Inputs (GLSL 1.5)

Vertex shader input variables (or attributes) receive per-vertex data. They are declared in a vertex shader with the in qualifier or the deprecated attribute qualifier. It is an error to use centroid in or interpolation qualifiers in a vertex shader input. The values copied in are established by the OpenGL API. It is an error to use attribute in a non-vertex shader. Vertex shader inputs can only be float, floating-point vectors, matrices, signed and unsigned integers and integer vectors. Vertex shader inputs can also form arrays of these types, but not structures.

Your desktop's GLSL compiler needs to be shot. It is not adhering to the #version 130 directive properly. To fix this on your laptop, which appears to have a conforming compiler, all you need to do is promote the shader from 130 to #version 150

Upvotes: 3

Related Questions