<blockquote>
<pre><code>in vec3 dataArray[2][]; // how to do this?
</code></pre>
</blockquote>
<p><a href="https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Arrays_of_arrays" rel="nofollow noreferrer">Arrays of arrays in GLSL</a> work differently than you might expect. The array indices are read left-to-right. For example, <code>vec2 var[2][3]</code> is a 2-element array of 3-element arrays of <code>vec2</code>s.</p>
<p>What you want is an &quot;unsized array of 2 element arrays of <code>vec3</code>&quot;. To do that, you need <code>in vec3 dataArray[][2];</code>.</p>
<p>Alternatively, you can declare the main type next to the type name and the array aggregation beside the variable name: <code>in vec3[2] dataArray[];</code>. GLSL allows this kind of split declaration style, where the array sizes on the type happen before the array sizes on the variable.</p>

CC BY-SA 4.0
2021-09-15T14:58:27.433Z
2021-09-15T14:58:27.433Z
Nicol Bolas
<p>Change the output of the vertex shader to</p>
<pre><code>out vec3[2] dataArray;
</code></pre>
<p>and the input to the tessellation control shader as</p>
<pre><code>in vec3[2] dataArray[];
</code></pre>
<p>That should work. Alternatively you could also define the type of dataArray as a struct.</p>

CC BY-SA 4.0
2021-09-15T14:33:12.297Z
2021-09-15T14:33:12.297Z
Reynolds
<p>I am trying to pass a vec3 array from vertex shader to tessellation shader.</p>
<p>passing just one value works fine, but how to pass an array?</p>
<p><strong>Vertex shader</strong></p>
<pre><code>#version 430
out vec3 data; //working!
out vec3 dataArray[2];
void main()
{
    gl_position = vec4(0,0,0,0);
    data = vec3(1,2,3);
    dataArray[0] = vec3(1,2,3);
    dataArray[1] = vec3(4,5,6);
}
</code></pre>
<p><strong>tessellation controll shader</strong></p>
<pre><code>#version 430
layout (vertices = 3) out;

in vec3 data[]; //working!
in vec3 dataArray[2][]; // how to do this?

void main()
{
    ...
}
</code></pre>
<p>The error message is: error C7618: OpenGL/ES does not allow input array declarations with size not equal to gl_MaxPatchVertices</p>
<p>I also tried</p>
<pre><code>in vec3 dataArray[2][gl_MaxPatchVertices]
</code></pre>
<p>But this also doesn't work.</p>

CC BY-SA 4.0
2021-09-15T08:47:59.827Z
how can I get the value of gl_MaxPatchVertices?
Thomas
<opengl><glsl>
glsl passing data array from vertex to tessellation control shader
Thomas
# glsl passing data array from vertex to tessellation control shader

(Asked by: username_0 on 2021-09-15)

I am trying to pass a vec3 array from vertex shader to tessellation shader.

passing just one value works fine, but how to pass an array?

**Vertex shader**

```
#version 430
out vec3 data; //working!
out vec3 dataArray[2];
void main()
{
    gl_position = vec4(0,0,0,0);
    data = vec3(1,2,3);
    dataArray[0] = vec3(1,2,3);
    dataArray[1] = vec3(4,5,6);
}

```

**tessellation controll shader**

```
#version 430
layout (vertices = 3) out;

in vec3 data[]; //working!
in vec3 dataArray[2][]; // how to do this?

void main()
{
    ...
}

```

The error message is: error C7618: OpenGL/ES does not allow input array declarations with size not equal to gl\_MaxPatchVertices

I also tried

```
in vec3 dataArray[2][gl_MaxPatchVertices]

```

But this also doesn't work.

**Tags:** opengl, glsl

> **Comments:**
> **username_0**: how can I get the value of gl_MaxPatchVertices?  

---

## 2 answers

### Answer by username_1 on 2021-09-15. Score: 2 | Accepted answer

> ```
> in vec3 dataArray[2][]; // how to do this?
>
> ```

[Arrays of arrays in GLSL](https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Arrays_of_arrays) work differently than you might expect. The array indices are read left-to-right. For example, `vec2 var[2][3]` is a 2-element array of 3-element arrays of `vec2`s.

What you want is an "unsized array of 2 element arrays of `vec3`". To do that, you need `in vec3 dataArray[][2];`.

Alternatively, you can declare the main type next to the type name and the array aggregation beside the variable name: `in vec3[2] dataArray[];`. GLSL allows this kind of split declaration style, where the array sizes on the type happen before the array sizes on the variable.


---

### Answer by username_2 on 2021-09-15. Score: 1

Change the output of the vertex shader to

```
out vec3[2] dataArray;

```

and the input to the tessellation control shader as

```
in vec3[2] dataArray[];

```

That should work. Alternatively you could also define the type of dataArray as a struct.


---

