Debugging batch groups

I am adding 2 mesh instances that were generated using mesh API into a single batch group (2 render components, 1 mesh instance each, same batch group). However, they still draw in separate draw calls. What would be an approach to understand what is causing them not being drawn in a single call? Does batch manager have some additional logs that would indicate the reasons?

None at the moment. Are your mesh instances using the same material? Any different uniforms set up on the mesh instances?

1 Like

Is there a case their bounding box is larger than the max aabb size?

You can check here all the grouping rules applied:

1 Like

Made a little repro project. Except it doesn’t repro :confused: In the sample project it batches correctly:

https://playcanvas.com/editor/scene/1643083

The setup is same, so not sure what’s up. Going to debug more. Also, in the sample project the mesh has issue with shading (default standard material). Any idea what I missed? I don’t have that issue in the real project.

Shading looks fine?

The light falls directly onto them? You can see the shadows direction. I would expect them to be the same whitish color as the bottom plane. The material is a default standard material. Here, I put a box behind for reference:

@LeXXik are you generating normals too?

@Leonidas I don’t! Ok, that would be it then.
facepalm

Will continue debugging the original project for batching issue and will update this thread, if there is any finding.

2 Likes

Yes, seems to work then:

const indices = [0, 1, 2];
mesh.setPositions(positions);
mesh.setIndices(indices);
mesh.setNormals(pc.calculateNormals(positions, indices));
mesh.update();

3 Likes