// packages/dev/core/src/Rendering/renderingGroup.ts
public static PainterSortCompare(a: SubMesh, b: SubMesh): number {
const meshA = a.getMesh();
const meshB = b.getMesh();
if (meshA.material && meshB.material) {
return meshA.material.uniqueId - meshB.material.uniqueId;
}
return meshA.uniqueId - meshB.uniqueId;
}
I wonder why the list is sorted by material and geometry before rendering?
It is first sorted by material to limit the number of state changes at WebGL level.
If the two meshes have no materials, we simply sort them by their uniqueId, which corresponds to the order in which they were created.
2 Likes
@Evgeni_Popov then is passing in a noOp function for sorting fine? this method is taking too much time.
Frame time is a little better after doing this:
const noOp = () => {};
scene.setRenderingOrder(0, noOp, noOp, null);
scene.setRenderingOrder(1, noOp, noOp, null);
scene.setRenderingOrder(2, noOp, noOp, null);
scene.setRenderingOrder(3, noOp, noOp, null);
That’s entirely possible. If it’s quicker without sorting, go ahead!
1 Like