Render multiple objects - Automate as much as possible

   2198   4   3
User Avatar
Member
17 posts
Joined: March 2022
Offline
Hello everyone,

Beginner Houdini user here.

I have a project coming up where I'll have a large amount of objects I need to render, lets say 200. They are furniture pieces. Each of them will be given to me as fbx file. Each file has a unique model name. Each model will have to have exact same materials assigned to them. I'm trying to automate everything as much as possible to save time.


I'm trying to use Solaris, and I red that I should later use PDG for this repetitive task - rendering 200 images.

What I'm trying to do is make a Solaris scene graph hierarchy based on name attributes that I assign. This will be something like this:

Box_Top
Box_Bottom
Sphere_Top
Sphere_Bottom
etc.

I then make 2 materials called "Top" and "Bottom". Now that's where I stumble. I don't want to manually drag Box_Top and Sphere_Top on to "Top" material.

Question 1:
How can I assign material "Top" using only a section of a name attribute? That is, tell Houdini to assign "Top" material to all objects that have "_Top" as part of their name?

Let's assume I have my materials assigned, lights placed and now I want to render each object individually. I want each image that I render to have a unique name, such as Box.png, Sphere.png etc. But in my Solaris hierarchy object names are divided (Box_Top and Box_Bottom). My understanding is that I have to use PDG to do it. But I just have no idea how to tell Houdini to use only first part of name from Solaris hierarchy to split up the objects. Something like "Take everything that has "Box_" in it's name and make it into one object, then render it", "Take everything that has "Sphere_" in it's name and make it into one object, then render it" etc.. Which brings me to my second question.

Question 2:
How can I render 200 images that will have unique names using PDG and Solaris?

I would appreciate any help and learning resources!

Attachments:
Solaris_USD_TOPs.hipnc (179.4 KB)
Screenshot_1.png (694.1 KB)

User Avatar
Member
6 posts
Joined: Aug. 2023
Offline
psychoboy852
Beginner Houdini user here.
Question 2:
How can I render 200 images that will have unique names using PDG and Solaris?

I have just little time for answer but

To render 200 images with unique names using PDG and Solaris, you can follow these steps:

Create a new PDG Graph:

Go to the "PDG" menu and select "New PDG Graph."
In the PDG Graph Network view, you'll build your graph.
Import your Solaris Scene:

Use the "Houdini TOP Import" node to import your Solaris scene.
Connect the "TOP Import" node to the rest of your graph.
Use the "TOP Fetch" Node:

Add a "TOP Fetch" node to your graph for each object you want to render.
Configure each "TOP Fetch" node to fetch a different object from your Solaris scene.
Create a Python Script for Unique Naming:

Add a "Python" node to the graph after each "TOP Fetch" node.
In the "Python" node's parameters, write a script that extracts the object's name and creates a unique output path for each render. e.g.python


input_path = workItem.inputFilePaths[0]
object_name = os.path.basename(input_path).split('.')[0]
output_path = os.path.join(workItem.outputFilePath, f"{object_name}.png")

workItem.addResult(output_path)
Render Node:

Add a "ROP Fetch" node to your graph.
Configure it to fetch the correct ROP (your rendering output driver) that you've set up in your Solaris scene.
Connect Nodes:

Connect the "Python" node to the "ROP Fetch" node.
Connect the "ROP Fetch" node to the "TOP Fetch" node(s).
Execute the PDG Graph:

Click the "Generate" button in the PDG Graph Network view to generate the tasks.
Click the "Cook" button to execute the graph and render the images.

Tell me if that works for you. I will respond in the evening if there is any problem with that solution
User Avatar
Member
9271 posts
Joined: July 2007
Offline
DyktaT
To render 200 images with unique names using PDG and Solaris, you can follow these steps:
...
Is this another one of ChatGPT hallucinations?
Has that ever helped anyone? Why posting this here and wasting OP's time?
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
447 posts
Joined: April 2018
Offline
psychoboy852
Question 1:
How can I assign material "Top" using only a section of a name attribute? That is, tell Houdini to assign "Top" material to all objects that have "_Top" as part of their name?
This one is easy. Use an Assign Material LOP, and set the Primitives to *Top and *Bottom, and assign the respective materials.

If you want Houdini to do less searching (traversing a heavy scene graph can be slow), you can be more explicit with your search pattern and use /geo/Objects/*Top instead. It should not be an issue with just 400 items though.





psychoboy852
Question 2:
How can I render 200 images that will have unique names using PDG and Solaris?
This one is more involved, but also fairly simple if you familiarise yourself with TOPs. The following is not necessarily a sequential list, but a breakdown of different steps of the whole process.

#1
You will need a list of names - one for each object. These will have to be unique names. You can do this with a Wedge TOP, and manually type the names in there, but a better approach would be to generate a CSV file of all the names, and then import that (with a CSV Input TOP). I don't know how you are sourcing your objects, so I cannot advise on the automation for this step. For your example, I manually created a CSV file with the names of the 3 objects.



#2
When you import your names, they will be stored in an attribute (let's say obj_name). How TOPs works is that you can then reference that attribute value anywhere in Houdini (as @obj_name), in order to isolate objects with that name, and also use it to specify your rendered file name.

#3
You can isolate objects in Solaris with a Prune LOP (set to Prune Unselected). You can then use the TOPs attribute in the Primitive Pattern like so:
/geo/Objects/`@obj_name`_*
This will resolve to /geo/Objects/Torus_Top /geo/Objects/Torus_Bottom (for example, thus isolating both those objects simultaneously).





#4
For the Karma Render Settings LOP, you can specify the output name to be $HIP/render/`@obj_name`.exr.
This will resolve to <your scene path>/render/Torus.exr (for example).





#5
You will need a ROP Fetch TOP in the TOP network, point it to your render ROP, and plug your CSV Input TOP into that. That way, for each object name, the ROP Fetch will call the render ROP and render that isolated object, with the current object name.




And the result of running the TOPnet:




I have attached a sample scene here.
Edited by eikonoklastes - Aug. 13, 2023 08:44:21

Attachments:
Solaris_USD_TOPs.hipnc (613.9 KB)
Book1.csv (35 bytes)

User Avatar
Member
17 posts
Joined: March 2022
Offline
eikonoklastes
I have attached a sample scene here.

Amazing, this is exactly what I was looking for. Thanks a lot for your help! I will spend some time to study your example and apply it to a bigger project!
  • Quick Links