That’s good to know that they can’t be arrays. Your suggestion for using UBO, TBO or bindless graphics is able to assign each vertex a different value?
I wasn’t sure what you were referring to by LUT indexing scheme.
Apologize for the basic questions, but thanks for pointing me in the right direction.
Can this be used to pass in a list of integers specific for each vertex?
You can only pass at most a vec4 per vertex in one vertex attribute array. However you can set multiple vertex attribute arrays to set multiple attributes per vertex.
You can also use TBO if your hardware supports it.
thank you so much for responding! I ran across a few of those links but wasn’t sure if TBO were the “norm” for passing data to vertices on a per vertex level.
If the attribute vec4 is a limitation my only option is store the data via a TBO and use that for pulling data?
Again, thanks for responding. For someone who is learning openGL and GLSL it really helps out.
I do not know if it is the norm but it is a quite sophisticated and easy way to access buffer objects from a shader. The problem is that it is for the moment only supported on high end graphic hardware and I am not sure whether it is implemented in ATI drivers yet.
Another option is to use regular 1D or 2D textures that you can fetch from the vertex shader (VTF). This one is more widely supported but need a little bit more setup on the application side.
What is vertattrib here? I assume it is equal to 6. I mean you set everywhere generic attribute index as 6 and just in the glBindAttribLocation you use a variable, that looks a bit suspicious.
All you have to do is:
Compile and link your shader program successfully
Bind generic vertex attribute to your custom names as declared in the vertex shader (glBindAttribLocation)
Beside your vbo and ibo bindings, enable generic vertex attribute arrays with glEnableVertexAttribArray and the attribute location.
Render the scene
In addition, I am not sure to understand why you call glVertexAttrib1f since you are apparently using vertex attribute arrays. Either you use vertex arrays and vertex attribute arrays or you use immediate mode and call glVertexAttrib* for each vertex declaration.
BindAttribLocation has no effect until the
program is linked. In particular, it doesn’t modify the bindings of active attribute variables in a program that has already been linked.
This means, after calling glBindAttribLocation you have to link your shader program once more. That’s why your sequence of commands looks suspicious to me. Usually, you’ll call glBindAttribLocation somewhere near the creation and linking of the shader program, not near where you actually load up attribute values.
Either you use vertex arrays and vertex attribute arrays or you use immediate mode and call glVertexAttrib* for each vertex declaration.
glVertexAttrib() is a nice way to provide default-values for attributes that have no VBO attached. They are called “dangling attributes”; used in earlier days to fake instancing, because they provided a very fast way to provide per-batch constants to the vertex shader. No glBegin()/glEnd() is needed to call glVertexAttrib. I’m glad they left it in for OGL3.0+
This means, after calling glBindAttribLocation you have to link your shader program once more
Thanks for that considerable precision.
glVertexAttrib() is a nice way to provide default-values for attributes that have no VBO attached. They are called “dangling attributes”; used in earlier days to fake instancing, because they provided a very fast way to provide per-batch constants to the vertex shader. No glBegin()/glEnd() is needed to call glVertexAttrib. I’m glad they left it in for OGL3.0+
That’s true but it’s a hack that relies on the state machine nature of OpenGL. IMHO, it is quite confusing to use an attribute as vertex constant, it is not its first purpose and in this case you should use a uniform.
Does the 3.0 spec clearly states about that? I must admit that’s a useful thing to make things quick or even for debugging.
because they provided a very fast way to provide per-batch constants to the vertex shader
I do not understand how this justify your suggestion… per-batch constants are uniforms and are very fast.
Got the attributes to work thanks to you guys! Looking back on my code I wasn’t sure why it was so sloppy, putting in 6 for two attribute calls but using ‘vertattrib’ for another.
Thanks for clarifying the usage of the vertex attributes.
I ran into attribute limit so I will have to be implementing textures for the data.
I’m posting on a new thread so hopefully, someone else can benefit from the knowledge of the group.