PDA

View Full Version : Lighting calculations for large point cloud



thinks
12-15-2006, 02:27 AM
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! :)

Thanks,

--thinks

Relic
12-15-2006, 03:42 AM
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);

thinks
12-15-2006, 05:46 AM
Thanks!

Does passing colors as GLubyte have an impact on performance?

Relic
12-17-2006, 09:20 AM
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.

thinks
12-19-2006, 12:32 AM
When you say interleaved data do you mean storing all the data in the same VBO? Or are you pointing to how the data is stored?

For instance the data could be stored:
Vec3_1, Color_1, Normal_1, Vec3_2, Color_2, Normal_2, etc...

or

Vec3_1, Vec3_2, Color_1, Color_2, Normal_1, Normal_2, etc...

As I understand it, Relic, you are saying the first alternative is better?