Hello babylon, I am trying to optimize our program recently. In order to optimize the picking performance of the grid with a very large number of vertices, I subdivide the grid according to the number of fixed points and open octree, which greatly improves the performance of ray picking. However, a new problem appears again, too many fine molecular nodes will increase the rendering times and lead to a decrease in frame rate. Can multiple subdivisions of a grid merge render channels?
If you have a repro in the Playground, it would help understanding better the problem.
If you have a lot of meshes, maybe using instances or even thin instances can help on the perf side?
I have reused geometry from the same mesh and converted the mesh with the same geometry and materials into instance objects to optimize rendering performance. However, for a single grid with very many faces (100000+ faces), the ray-picking performance was extremely poor, so I used mesh.subdivide to subdivide the grid and create an octree to optimize ray-picking performance.
const SUB_COUNT_FACE = 2000
let subCount = 1;
let indice = mesh.geometry.getTotalIndices()
if (indice) {
subCount = Math.ceil(indice / 3 / SUB_COUNT_FACE)
} else {
subCount = Math.ceil(item.geometry.getTotalVertices() / 3 / SUB_COUNT_FACE)
}
mesh.subdivide(subCount)
let octree = item.createOrUpdateSubmeshesOctree()
function updateOctree(mesh) {
let octree = mesh.createOrUpdateSubmeshesOctree()
setTimeout(() => {
mesh.onAfterWorldMatrixUpdateObservable.addOnce(updateOctree)
}, 1)
}
mesh.onAfterWorldMatrixUpdateObservable.addOnce(updateOctree)
Yes, by doing so you raise the number of draw calls because there is a draw call per sub-mesh… You should try to subdivide less, or maybe try using another picking method, like GPU picking:
(there are a lot of other threads about GPU picking in the forum)
This picking scheme is very good, combining fewer fine molecular nodes with octree, can improve more picking performance!