So I've been trying for a while now, to pass a vertex attribute array into the geometry shader. It is an array of float (where the attribute per vertex is just a float value)
Now, when I put this in the geometry shader:
attribute float nodesizes;
The shader compiler complains:
OpenGL requires geometry inputs to be arrays
How do I exactly pass it along?
Also, here's my code for putting the vertex attrib:
glBindAttribLocation(programid, 1, "nodesizes");
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, array);
glEnableVertexAttribArray(1);
Am I doing something wrong?
The geometry shader doesn't get attributes. The vertex shader gets attribute
s and puts out varying
s (speaking in the old syntax). These can then be read in the geometry shader, but as an array, as one geometry shader invocation follows multiple vertex shader invocations. Something like this:
vertex shader:
attribute float nodesize;
varying float vNodesize;
void main() {
...
vNodesize = nodesize;
...
}
geometry shader:
varying float vNodesize[];
void main() {
...vNodesize[i]...
}
The names are arbitrary, but of course the names of the varyings have to match in both shaders. I hope you didn't just mess up the terms vertex shader and geometry shader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With