I have a large point cloud (~6-7 million points) that comes with a normal and a color for each point.
At the moment I am using a VBO and simply associating a color with each point. I would like to use the normals ti do some lighting calculations but AFAIK there is no equivalent of the glColorPointer(…) for materials, or is there?
I suppose the obvious solution would be to write a vertex shader.
I was just wondering if there is a simpler way.
My second question is regarding efficiency. I hear that the graphics hardware stores colors as floats no matter what format they are passed as. I am currently passing the colors as GLubyte, is this inefficient?
Any other advice regarding rendering large point clouds are obviously welcome as well!
Yes, there is a way to get colors into some material slots.
Try this for example (fixed function lighting only, not with shaders):
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
If you’re using Color4ub types, no it shouldn’t be slow.
There are some gotchas with VBOs, for example interleaved data is faster then individual attribute arrays due to cache locality, double is not supported, unsigned integer and shorts for attributes normally slow down, signed shorts work fast mostly.
Anyway, using 32-bit floating point attributes throughout is plenty fast for most usages.