flattenStrong with position

This requires CPU only load. However, this allows you to offload the GPU later.

The problem is that you don’t quite understand how it works, I demonstrate it in the video. Without flattening, I have ~8 frames and with flattening ~27.

Flattening is more beneficial to the graphics card, I think: it reduces the number of nodes, and thus the number of batches sent to the graphics card. (Ideally.)

That said, note that there can be factors extraneous to flattening that may affect how a given scene performs, and even result in more nodes running faster. (Within limits.)

So, the flattening did not work. We only have to find out why not. Do you have a unique texture, render state or material attached to each individual Panda that prevents flattening?

As an aside, Panda 1.11 will ship with a hardware instancing feature that should make it significantly easier to render many instances efficiently.

It would be strange if the geometry was flattened.

from panda3d.core import NodePath
from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        all_node = NodePath('all')

        for i in range(0, 10):
            for j in range(0, 10):
                model = loader.load_model("panda")
                model.clear_model_nodes()
                model.set_pos(i*10, j*10, 0)
                model.reparent_to(all_node)

        all_node.flatten_strong()
        all_node.reparent_to(render)

        print(all_node.ls())

app = MyApp()
app.run()

@Pignon publish the output of this program.

@rdb I used the exact code as flattenStrong with position - #6 by serega-kkz except change the loop to generate 200 pandas so…

@serega-kkz :smiley: Im not doing anything wrong.

Known pipe types:
  glxGraphicsPipe
(1 aux display modules not yet loaded.)
PandaNode all
  Character panda.egg
    GeomNode  (800 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
None

But there are not so many Geoms… There are 115.
@Pignon either way it works, but it’s unclear what you need in .

It works on your system. I find it strange that on W7/dx9 it kinda works but the performance is the same.
Also when I experimented with my tile. If I didnt set position it would flatten to 1 geom but the performance was worse. Tried it with the panda model but there was no difference (as same number of nodes).

This suggests to me that the problem may be something other than the number of nodes in the scene.

What results does PStats report for the scene?

image

Hmm, its all in Wait.

Hmm… I may be mistaken, but I think that this suggests that v-sync is on. If so, then the results produced by looking at the frame-rate are perhaps unreliable, as the actual frame-rate may be hidden by the time spent waiting for the next screen update.

Note that if you have disabled v-sync in your program, your graphics drivers and/or graphics-card control utility may be enabling it anyway. (I recall encountering that under Windows, I believe.)

1 Like

So I did more testing.
W7/dx9 - flatten reduces number of nodes, no perf. gain
W7/ogl - flatten reduces number of nodes,
Ubuntu - flatten doesnt reduce number of nodes, no perf. gain
edit: I was wrong there is no perf. gain on W7/ogl

@Thaumaturge with Vsync off on Ubuntu it did the same thing.

Did you check any driver/graphics-utility settings that you may have in Ubuntu?

Or, if a quick-and-dirty check is called for, what frame-rate do you get if you just run an empty scene in a small window? (In order to produce a very high frame-rate, hopefully well above the monitor’s refresh-rate.)

[edit] Although it’s odd that the number of nodes produced differed under Ubuntu, and that switching to OpenGL under Windows helped. In the latter, again I wonder whether it’s not a driver forcing v-sync under DirectX…

It looks like you’re doing what most British scientists do. You are in what an illusory view of the work of flatten Strong.

What you tested has nothing to do with the graphics library.

  1. Don’t do flattening.
  1. Make the number of pandas bigger until you have ~ 10 frames
  1. After that, try to make a flattening, and only then you will see the result. And don’t forget to capture all the objects in the camera.

I was wrong about it working on W7/ogl.
Tried the thing with no setPos on W7 with Vsync off and it does the same thing.

Okay, fair, that clears up one oddity at least!

But again, was that “v-sync off” as set by the program, or with v-sync disabled in the graphics-card utility/driver? The latter can override the former, I do believe.

Tried both and same.

Ah, fair enough! Odd, then, and I don’t know for my part!

Hm, another test. Used very simple hexagon mesh with just color, no texture and flatten works very well with that. 130fps no flatten to 600fps with flatten
So maybe there is some problem with textures. Will try to export the tile mesh without texture later.

Turns out it has something to do with the number of vertices/triangles or something. When model has more vertices the flatten reduces the number of nodes less and less.
Btw I noticed overlapping models kills perfomance, I guess its the reason why it performed so badly when I stacked all the models in one place and flattened them into 1 geom.

I tried the same code on other pc and I get the same result as

so it must be the GPU not supporting something .