flattenStrong limits for optimal speed

Hello,

I’m a little confused about the flattenStrong cause it takes (a lot) more time to do the flattenStrong on small number of nodes with a lot of vertices than to do it on a lot of nodes with less vertices. I explain my case. I have a scene with 6 different textures. I have 20 buildings (procedural meshes) which use these textures.

If I use one node by texture , create all my sub-geometries in each node and then apply the flattenStrong on each of the 6 big node, it takes 28s to display the scene.

2 nodes have the following properties:

4413 total nodes (including 0 instances); 0 LODNodes.
4412 transforms; 0% of nodes have some render attribute.
4412 Geoms, with 4412 GeomVertexDatas and 1 GeomVertexFormats, appear on 4412 GeomNodes.
20729 vertices, 20729 normals, 0 colors, 20729 texture coordinates.
GeomVertexData arrays occupy 1134K memory.
GeomPrimitive arrays occupy 59K memory.
6286 GeomVertexArrayDatas are redundant, wasting 683K.
4265 GeomPrimitive arrays are redundant, wasting 52K.
9976 triangles:
  0 of these are on 0 tristrips.
  9976 of these are independent triangles.
3 textures, estimated minimum 2304K texture memory required.

and the 4 other nodes have this one:

644 total nodes (including 0 instances); 0 LODNodes.
643 transforms; 0% of nodes have some render attribute.
643 Geoms, with 643 GeomVertexDatas and 1 GeomVertexFormats, appear on 643 GeomNodes.
2572 vertices, 2572 normals, 0 colors, 2572 texture coordinates.
GeomVertexData arrays occupy 141K memory.
GeomPrimitive arrays occupy 8K memory.
783 GeomVertexArrayDatas are redundant, wasting 80K.
642 GeomPrimitive arrays are redundant, wasting 8K.
1286 triangles:
  0 of these are on 0 tristrips.
  1286 of these are independent triangles.
3 textures, estimated minimum 2304K texture memory required.

But If I use one node per building (ie 20 nodes), and for each of these node I have 6 sub-node (so a total of 120 node to flatten), it only takes 18s to display. The whole time difference is in the flattenStrong method. Each groupe of sub-node has the following properties :

37 total nodes (including 0 instances); 0 LODNodes.
36 transforms; 2% of nodes have some render attribute.
36 Geoms, with 36 GeomVertexDatas and 1 GeomVertexFormats, appear on 36 GeomNodes.
144 vertices, 144 normals, 0 colors, 144 texture coordinates.
GeomVertexData arrays occupy 8K memory.
GeomPrimitive arrays occupy 1K memory.
33 GeomVertexArrayDatas are redundant, wasting 4K.
35 GeomPrimitive arrays are redundant, wasting 1K.
72 triangles:
  0 of these are on 0 tristrips.
  72 of these are independent triangles.
3 textures, estimated minimum 2304K texture memory required.

172 total nodes (including 0 instances); 0 LODNodes.
171 transforms; 0% of nodes have some render attribute.
171 Geoms, with 171 GeomVertexDatas and 1 GeomVertexFormats, appear on 171 GeomNodes.
813 vertices, 813 normals, 0 colors, 813 texture coordinates.
GeomVertexData arrays occupy 45K memory.
GeomPrimitive arrays occupy 3K memory.
200 GeomVertexArrayDatas are redundant, wasting 21K.
164 GeomPrimitive arrays are redundant, wasting 2K.
384 triangles:
  0 of these are on 0 tristrips.
  384 of these are independent triangles.
1 textures, estimated minimum 768K texture memory required.

8 total nodes (including 0 instances); 0 LODNodes.
7 transforms; 12% of nodes have some render attribute.
7 Geoms, with 7 GeomVertexDatas and 1 GeomVertexFormats, appear on 7 GeomNodes.
28 vertices, 28 normals, 0 colors, 28 texture coordinates.
GeomVertexData arrays occupy 2K memory.
GeomPrimitive arrays occupy 1K memory.
5 GeomVertexArrayDatas are redundant, wasting 1K.
6 GeomPrimitive arrays are redundant, wasting 1K.
14 triangles:
  0 of these are on 0 tristrips.
  14 of these are independent triangles.
3 textures, estimated minimum 1152K texture memory required.

33 total nodes (including 0 instances); 0 LODNodes.
32 transforms; 3% of nodes have some render attribute.
32 Geoms, with 32 GeomVertexDatas and 1 GeomVertexFormats, appear on 32 GeomNodes.
128 vertices, 128 normals, 0 colors, 128 texture coordinates.
GeomVertexData arrays occupy 7K memory.
GeomPrimitive arrays occupy 1K memory.
27 GeomVertexArrayDatas are redundant, wasting 3K.
31 GeomPrimitive arrays are redundant, wasting 1K.
64 triangles:
  0 of these are on 0 tristrips.
  64 of these are independent triangles.
3 textures, estimated minimum 2304K texture memory required.

171 total nodes (including 0 instances); 0 LODNodes.
170 transforms; 0% of nodes have some render attribute.
170 Geoms, with 170 GeomVertexDatas and 1 GeomVertexFormats, appear on 170 GeomNodes.
803 vertices, 803 normals, 0 colors, 803 texture coordinates.
GeomVertexData arrays occupy 44K memory.
GeomPrimitive arrays occupy 3K memory.
195 GeomVertexArrayDatas are redundant, wasting 20K.
161 GeomPrimitive arrays are redundant, wasting 2K.
384 triangles:
  0 of these are on 0 tristrips.
  384 of these are independent triangles.
1 textures, estimated minimum 768K texture memory required.

3 total nodes (including 0 instances); 0 LODNodes.
2 transforms; 33% of nodes have some render attribute.
2 Geoms, with 2 GeomVertexDatas and 1 GeomVertexFormats, appear on 2 GeomNodes.
8 vertices, 8 normals, 0 colors, 8 texture coordinates.
GeomVertexData arrays occupy 1K memory.
GeomPrimitive arrays occupy 1K memory.
1 GeomVertexArrayDatas are redundant, wasting 1K.
1 GeomPrimitive arrays are redundant, wasting 1K.
4 triangles:
  0 of these are on 0 tristrips.
  4 of these are independent triangles.
3 textures, estimated minimum 1152K texture memory required.

My question is, is there a known limit in flattenStrong ? I mean, for example, if I have more than 1000 triangles, it is known to be a lot slower? What is the optimal number of triangles (or nodes, or…) for the flattenStrong ?

Cause I thaught doing a single node (batch) per texture would be a lot more efficient for speed, but it doesn’t seem to be the case. I’m aware it’s a lot better for the fps, but the 10s lost for initial rendering seems very strange, at least for me.

Thanks in advance.

it seems that flattenStrong has a worse-than-linear runtime-behavior. so flattening more simple objects is faster than flattening less complex objects.

i want to mention that flattenStrong was specifically designed to merge together many small nodes into fewer,bigger ones. so it’s not really surprising you’r experiencing long processing times.

Anyway you schouldnt always flatten all static parts of your scene to one node as this way you (or panda3d itself) cant hide them individually which could save performance too.

That’s what I want to do. I have a lots of small Node under one node and I want to merge them.
What surprise me is the big difference between doing it only 6 times or doing it 120 times.