Instancing multiple objects from disk

   2933   4   2
User Avatar
Member
19 posts
Joined: Feb. 2017
Offline
HI, is it possible to instance multiple objects from disk. I have made 100 different models with a rop_geo. Then I have imported using a file node. I want to Instance all the different objects onto a grid of lets say 1000 points.

Today I have one geometry node for each object like below, so box, box1, box2 etc. But this is not optimized, and I would like to only use one geo node for importing the boxes. Can I write my code differently to import all the different boxes, then scatter them on my grid in my instance node?


My wrangle inside my instance nodethe code below is just an example for instancing 3 different boxes)
string instances;
push(instances, "/obj/Box");
push(instances, "/obj/Box2");
push(instances, "/obj/Box3");
s@instance = instances;

Here I have to manually make a geo node for each object I want to scatter around. But I will end up needing to make 100 geo nodes, that makes me a sad 3d artist

thanks for any advice on this
User Avatar
Member
384 posts
Joined: April 2017
Offline
This kind of depends on your render engine, but yes it's very doable.

There's an instancing attribute called s@instancefile. You can point this to a .bgeo file on disk and it will be loaded in at runtime.

Let's say you have 100 objects and they're each named /path/to/box001.bgeo, /path/to/box002.bgeo, etc. You can use an integer attribute or any random value that evaluates from 1 to 100 and construct the instance path out of it like this:

int num = int(rint(fit01(rand(@ptnum), 1, 100)));
string path = chs("base_path"); // this would be "/path/to"
string filename = chs("filename"); // this would be "box"
s@instancefile = sprintf("%g/%g%03d.bgeo", path, filename, num);

That last line there puts your path, filename, and random number together into a single string, then binds it to s@instancefile. %gmeans "substitute whatever here", it's kind of a catch-all. %03dmeans "substitute an integer here and pad it to fill three digits".

Mantra and Redshift both support this attribute. I'm not sure about other render engines but I imagine that others do as well.
Edited by toadstorm - Aug. 21, 2021 16:25:24
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
19 posts
Joined: Feb. 2017
Offline
Hi thanks for the help, this is very helpful! I have tried setting it up, But I had no luck getting in my geo. (I'm not good with coding, so might be I misunderstood the lines and comments you sent me?)


Im using Redshift.

Attached a snippet of the wrangle node

Cheers

Attachments:
Capture.PNG (152.3 KB)

User Avatar
Member
384 posts
Joined: April 2017
Offline
The filename you're generating isn't gonna be valid... you won't be able to pick it like a normal file picker with this setup. I'm attaching a readymade example for you specifically built for Redshift. You'll get better performance instancing .rs proxy files, so I'm generating those first and then pointing to those using a similar VEX script to the one I posted earlier.

Attachments:
redshift_instancefile_toadstorm.hip (616.6 KB)

MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
19 posts
Joined: Feb. 2017
Offline
Thank you so much! This seems to work fine

Is there a way to display the proxies? I found a tutorial by Atom from 2017covering rs proxies, he writes out bgeo.sc and proxies at the same time, and instance the bgeo for displaying the proxies.

Is that the only way to see the copied proxies?
  • Quick Links