We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Geometry Buffers cleanup

Home Forums Programming Geometry Buffers cleanup

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #59598
    scatman2513
    Participant

    Im cloning and deleting a lot of objects and after too much operations my application drops significant in fps. I’ve looked into the performance info and saw that my “Geometry Buffers” grows constantly. Like having 1 group of objects shows me 17, but if I clone it 30 times and delete it 30 times it grows to over 400.

    I have a render function that should delete everything and draw it new. How do I delete everything before creating my structure again?

    #59600
    kdv
    Participant

    Show your code. And note that if you’re using the clone() function for a mesh its geometry is not cloned. The clone() function creates an instanced mesh sharing the original geomtry buffer.

    In this demo the scene contains 80+ objects and only 2 geometry buffers
    https://cdn.soft8soft.com/demo/blender/clone_object/clone_object.html

    A geometry buffered can be removed from memory this way
    object.geometry.dispose();

    #59611
    scatman2513
    Participant

    It took me a moment to create a demonstration application for my problem. I’ve attached the .zip into my post. I have to say that I’m working with a plugin from gliftek to duplicate my objects.
    The logic is built into the puzzle. If you take a look into the console output, then you can see how Gemoetry Buffers is growing while objects stay the same.

    • This reply was modified 1 week, 4 days ago by scatman2513.
    Attachments:
    You must be logged in to view attached files.
    #59618
    kdv
    Participant

    Your render() function creates 140+ new objects. I don’t see so many ones in the scene. That means there are a lot of unwanted duplicates.

    The initial amount of the scene’s children is 9.

    The cloned balls (expected) do not create additional geometry buffers but the matrix’s cubes do. Every time +16 buffers. If you remove a box creating from the render() function you’ll see that the geometry buffers amount doesn’t grow up. In fact, it’s not so much, the cube’s geometry contains only 8 points.

    The cloned balls (not expected) create a lot of additional materials every time instead of sharing the initial material.

    Finally, add this code to dispose of the old geometriy buffers

    #59823
    scatman2513
    Participant

    This worked perfect. Thanks. Now I can duplicate and delete objects and “Geometry Buffers” isn’t growing anymore.

    However, in my application (not the demo project I shared above) I still have performance issues and a look into the performance info shows me that “Textures & Render Buffers” is still growing. I also have these “N/A Textures” calculating up.

    I tried to change your code to delete materials first but it had no effect..

    VARS.allDupedObjects.forEach(function(name){
       const object = app.scene.getObjectByName(name);
       if (object && object.isMesh){
           object.material.dispose();
           object.geometry.dispose();
       }
    });
    

    Do you know what’s the problem here?
    If you need a demo application I could create one end of the week.

    best regards

    Attachments:
    You must be logged in to view attached files.
    #59833
    kdv
    Participant

    try this code

    app.scene.traverse(function(object) {
      if (object.isMesh) {
        v3d.MaterialUtils.disposeTextures(object.material);
        object.material.dispose();
        object.geometry.dispose();
      }
    });
    #59874
    scatman2513
    Participant

    Thank you a lot @kdv. The issue is fixed now. After calling the render function nearly 100 times I always get the same numbers now in the performance info and the fps-drops have stopped now. Fantastic! Made my day = )

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.