Hi all,

I’m attempting to implement a brute force K-Nearest-Neighbors algorithm to help me compute normal vectors of a point cloud.

I compute the distances between points at the vertex shader and then i want to sort them to another shader program. So, i want to packed them into a texture buffer object (Transform Feedback extension).

I didn’t find any tutorial/post on how to accomplish this, so i need your help.

At the “GLSL Language Specification 1.5” says for the vertex shader output variables:

They can only be float, floating-point vectors, matrices, signed or unsigned integers or integer vectors, or arrays or

structures of any these.

Until now i haven’t managed to output an array with integers…Some parts of my testing code(with no compilation errors):

OPENGL SETUP CODE:

```
int att_computeNormals[] =
{glGetVaryingLocationNV(program, "neighbors"),};
glTransformFeedbackVaryingsNV(
program, 1, att_computeNormals, GL_SEPARATE_ATTRIBS_NV);
.
.
.
glGenTextures(1,&tex_Neighbors_computed);
glGenBuffers (1,&tbo_Neighbors_computed);
glBindBuffer (GL_TEXTURE_BUFFER_EXT, tbo_Neighbors_computed);
glBufferData (GL_TEXTURE_BUFFER_EXT, sizeof(GLint)*mesh->vertices.size()*N, 0, GL_STATIC_DRAW);
```

OPENGL NORMAL ESTIMATION CODE:

```
glUseProgram(program);
glBindBufferBaseNV(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tbo_Neighbors_computed);
.
.
.
glBindTexture (GL_TEXTURE_BUFFER_EXT, tex_Neighbors_computed);
glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_LUMINANCE32I_EXT, tbo_Neighbors_computed);
```

GLSL VERTEX SHADER

```
#version 140
#extension GL_EXT_gpu_shader4 : enable
#define N 16
out int neighbors[N];
int main(void)
{
for(int i=0; i<N; i++) neighbors[i] = i;
}
```

thanks for your time…