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

Still struggling with the batcher. At least, I’ve narrowed it down to an issue related to timing. Here, I made a small repro:
https://playcanvas.com/editor/project/1070373

Both triangle and box belong to the same batch group. There is a function init() that generates a triangle. If I call it immediately, then I can see both triangle and box. If I call it on delay, then triangle never appears. Any ideas?

VS

This seems like a bug to report, most likely a grouping issue with the batcher. If I call batcher.generate() in the console manually, I get a second duplicate box batch.

Made one for tracking:

1 Like