Home › Forums › Programming › Geometry Buffers cleanup
- This topic has 6 replies, 2 voices, and was last updated 2 days, 2 hours ago by
scatman2513.
-
AuthorPosts
-
2023-01-16 at 8:41 am #59598
scatman2513
ParticipantIm 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?
2023-01-16 at 8:47 am #59600kdv
ParticipantShow your code. And note that if you’re using the
clone()
function for a mesh its geometry is not cloned. Theclone()
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.htmlA geometry buffered can be removed from memory this way
object.geometry.dispose();
2023-01-16 at 2:14 pm #59611scatman2513
ParticipantIt 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.2023-01-16 at 6:27 pm #59618kdv
ParticipantYour
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
2023-01-24 at 5:52 pm #59823scatman2513
ParticipantThis 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.2023-01-25 at 3:04 am #59833kdv
Participanttry this code
app.scene.traverse(function(object) { if (object.isMesh) { v3d.MaterialUtils.disposeTextures(object.material); object.material.dispose(); object.geometry.dispose(); } });
2023-01-25 at 3:17 pm #59874scatman2513
ParticipantThank 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 = )
-
This reply was modified 1 week, 4 days ago by
-
AuthorPosts
- You must be logged in to reply to this topic.