Submesh's 'indexCount' does not updating with shader material

Hi Everyone,

I have a dynamic lidar point cloud implementation(WebGL) where point counts change per frame.

For this implementation:

  • Point cloud is a simple custom mesh(using BABYLON.Mesh and BABYLON.VertexData). My geometry comprises vertex, color, and index buffers.
  • I allocated N vertices and initialized them with a linear arrangement.
  • I update N number of vertices per frame
  • For drawing dynamic point cloud, I use Submesh’s indexCount and set N vertices to control draw count dynamically.

This point cloud custom shape implementation has standard and shader materials.

  • Standard material uses BABYLON.StandardMaterial’s fillMode = BABYLON.Material.PointListDrawMode
  • Point cloud material uses BABYLON.ShaderMaterial pointsCloud set as true

The standard material point cloud shader works:-

But the shader material is not working at all. This is a BLOCKER for us.

Here is a playground example: Babylon.js Playground

  • You can use useShader variables to switch between two material types and observe the difference.
  • For controlling dynamic draw count, use dynamicCount variable.

How can I update the index count dynamically on the shader material-based mesh? Kindly assist.

When you set material.pointsCloud = true, the system sets fillMode to PointFillMode, assuming that the mesh to which you will apply the material is unindexed. If your mesh has indices, you must set material.fillMode = BABYLON.Material.PointListDrawMode yourself (as you did in the case of the standard material):

1 Like

Thanks, @Evgeni_Popov, for this quick help. It is interesting to know the PointFillMode logic behind the scene. Thanks again.