Size vertex buffer ignored in a Mode.Points mesh?


I am rendering a point cloud using vertex buffers in a mesh.

Mesh m = new Mesh();
m.setBuffer(VertexBuffer.Type.Position, 3, pointCoordinates3d);
m.setBuffer(VertexBuffer.Type.Color, 4, colorsRGBA);
m.setBuffer(VertexBuffer.Type.Size, 1, sizes);

pointCoordinate3d contains the coordinates of the points, colorsRGBA the colors of points, and sizes the sizes of the points. I would expect that higher values in sizes would lead to the points being rendered larger, which isn’t the case.

Now a few questions:

  1. Is what I described what the size vertex buffer is supposed to do?
  2. If no, what is it supposed to do?
  3. If yes, what could be the cause of the size buffer apparently being ignored?

Thank you and best regards

  1. Not really.
  2. Each vertex buffer simply links the data, so that it is available to the shader.

It’s up to the shader to use the data in the way you’d like. As far as I know, the jME default Unshaded material’s vertex shader does not read and use attribute inSize.

Eg.: your vertex shader could contain the following to receive the input from vertex buffer size and set it to gl_PointSize.

attribute float inSize;
void main() {
	gl_PointSize = inSize;

Depending on your requirements, gl_PointSize is limited on some hardware. An alternative to draw points or varying sizes is to use quads - billboards with instancing.

Or point sprites.

JME’s point could shader will use the size buffer as I recall. Particle.j3md I think.

The particle shader seems to ignore sizes, that’s the one I am using.

Yes, for gl_points, size means nothing. You have to set the size at the material level once and even then it might not be supported.

Point SPRITES, as in images for the points, point images, point sprites, texture atlas with a sprite per point… should use size.

Note how the only size related code depends on point sprites:

…you will be disappointed with OpenGL point sizes for OpenGL points.