0

My goal is to optimize a synthetic dataset program that imports N-number of .glb files, places them randomly, and fixates a camera on the center of all these objects (so it can render an image of everything); this is done for M-number of desired renderings. Basically creating a collection of 2D pictures with random assortments of my objects.

I have the bulk of this figured out. When I run the program it starts by importing the N-number of .glb files in under a second and renders a picture, but then starts to import them at about 2-3 seconds each and renders a picture, then 8-10 seconds and renders a picture, etc. It doesn't take long before it's importing a single file at 30-60+ second speeds. The render speeds are fine though, they happen fairly quickly; it's just the .glb import speeds. Maybe it is the rendering that is somehow slowing everything down over time; I don't know for sure. Could be anything.

I don't know why this is, or what could be causing it. I couldn't really find anything on the internet about this exact problem. Maybe this is a memory issue and I should be freeing more memory (my RAM usage isn't really increasing though)? Honestly open to (and would appreciate) any suggestions.

Thank you in advance for any help!

1 Answers1

0

The problem lies in the way Blender handles orphan data. Try removing a material from an object and adding another one to it. In the dropdown you will see at least one material with a 0 in front of it. That means 0 users (oprhan). However the material still exists and will only be deleted once you close Blender. Therefore importing and deleting objects will clutter your RAM and the time Blender takes to sort things out.

The correct solution is: Run Blender from the commandline, starting a new instance everytime you want to render. something like:

blender.exe my.blend --python myScript.py -- path_to_glb render_image_name

everything after the last " -- " (spaces are important) will be ignored by Blender, but can be read via sys.argv More about sys args in Blender:
How to pass command line arguments to a Blender Python script?
all built-in commandline args:
https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html

Frederik Steinmetz
  • 2,879
  • 1
  • 8
  • 11