Accessing Vertex colors from a VBO inside a Shader

Hi OF !

Long time without posting !! I’m back :wink:

I’ve a doubt on how to access the vertex color for each vertex inside a shader. By the way I’m using “programable renderer” pipeline … GL version 3.3 (in main.cpp).

So far, what i’ve is : i’ve a VBO that I feed with vertices, colors, texCoords, and faces indices buffers …

When drawing I’m using a custom shader and I can’t find how to use the color that each vertex has asigned by the color buffer of the VBO.

Does my question makes sense to anyone ?

I tried to find it out for some hours in the forums, but I can’t find it …

Thanks a lot !

OF predefines some attributes in the shader you just need to define them if you are using a custom one

in vec4 position;
in vec4 color;
in vec3 normal;
in vec2 texcoord;

Great ! Arturo thanks a lot ! Is there a place where this predefined attributes get explained that I missed on my search ? OF Documentation or OF Book ? Would be nice to put a pointer to the place where this info in case someone else wants to search on something related.

I found on the web a custom solution that worked for me …

In the vertex shader:

layout(location = 1) in vec4 vertex_color;

and then i’ve been able to use vertex_color as the color for each vertex stored in the VBO …

Thanks a lot Arturo !