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
Instancing multiple objects from disk
2912 4 2- arhusvegard
- Member
- 19 posts
- Joined: 2月 2017
- Offline
- toadstorm
- Member
- 384 posts
- Joined: 4月 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:
That last line there puts your path, filename, and random number together into a single string, then binds it to s@instancefile.
Mantra and Redshift both support this attribute. I'm not sure about other render engines but I imagine that others do as well.
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.
%g
means "substitute whatever here", it's kind of a catch-all. %03d
means "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 - 2021年8月21日 16:25:24
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
- arhusvegard
- Member
- 19 posts
- Joined: 2月 2017
- Offline
- toadstorm
- Member
- 384 posts
- Joined: 4月 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.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
- arhusvegard
- Member
- 19 posts
- Joined: 2月 2017
- Offline
-
- Quick Links