Jump to content

Exporting FBX with dynamic textures/materials


mbrajsa

Recommended Posts

Hi all,

I'm new to Houdini, but I'm already finding it fascinating. Coming from a developer background, I really enjoy the ability to use scripting nodes and the complexity of the software altogether.

I've started experimenting with creating a texture from the object's colors and then applying it to the object's clone. I've used a simple box geometry for testing, and what I did was the following:

  1. Created a detail "Attribute Wrangle" node, which sets different colors to all of the box's points.
  2. Added a "Volume Wrangle" node which samples the color at a specific UV coordinate of the box and updates the value for that voxel in a 2D volume.
  3. Created a COPNet with a "SOP Import" node where I'm reading the value of the "Volume Wrangle" node using a custom plane (the volume's output).
  4. Added a "Channel Copy" node where I'm mapping that custom plane to an RGB one.
  5. Created a MATNet with a "Principled Shader" with a base color of white, which doesn't use the point color, but a texture instead. Set the texture value to read the output of the COPNet.

I've got my source material set up with all that in place. I've added a new box, applied the "UV Texture" node to it, unwrapped the UVs, and applied the material. The result (and the node layout) can be seen in the screenshots below:

image.thumb.jpeg.7fe91a7d612d0164d5ca1a00f6db2765.jpeg

image.thumb.jpeg.14561e38ae5ab94757c0fd68451dc6c6.jpeg

And as far as the initial dynamic material creation from mesh points is concerned, all works.

Now, I've also wanted to export the mesh and the applied material as an ".fbx" using an export node. For that, I had to purchase an Indie license. So, I've used https://www.orbolt.com/upgrade-houdini-files to convert the project to an Indie-compatible version.

Here's where I've actually hit a wall. The only ".fbx" export node I could find is a "ROP FBX Output" node. Still, I cannot rely on it to be automated, meaning I cannot have a collection of objects, e.g., a segmented point cloud, and export each of the segments in a for-loop since the "ROP FBX Output" node requires a user to tap "Save to Disk" manually. One workaround would be to create a pipeline where I'd just have a for-loop generate a single segment for each frame. I could manually hit "Save to Disk" with a frame range specified, but I would prefer to have an automated solution like the simple "File" node, but it saves the model as an ".obj". I've tried to make it save the model as an ".fbx" by changing the extension, but it seems to save it as an ASCII ".fbx," which Blender can't read.

The other issue is that once I've manually exported the model as an ".fbx", when I open it up in Blender (or 3d MAX), I get a single-color material. The material's color represents the color of the last point of our box in Houdini. Could it be due to the fact that we cannot actually export a dynamically-created texture but have to bake it first?

So my questions are actually the following:

  1. Is there a way/node to export a piece of geometry as an ".fbx" without the need to tap "Save to Disk", as when using the "ROP FBX Output" node?
  2. How to export the geometry as an ".fbx" so that it actually exports the material correctly as well, meaning that, once imported in Blender, it actually displays in the same way it can be seen in the Houdini rendering?
  3. Is there a way to export a geometry as an ".obj" + ".mtl" combo? From what I've read and seen, this doesn't seem to be something Houdini supports.

Thank you in advance, and apologies for a quite long post :) 

 

material_boxes.hipnc

Link to comment
Share on other sites

Bit of history, bit of context, apologies in advance for the rambling...

Houdini tries to unify the concept of rendering, be it rendering images, or 'rendering' geometry to disk, or 'rendering' a simulation, its all just 'rendering'.

Any time you see a 'save to disk' button, that node will likely have 'rop' in its name, short for 'render operator'.

The rop context ( or /out ) in houdini is a way to control rop node execution, the idea being that you might need to first render some geometry, then render a simulation cache, then render foreground and background images, then render a comp. Rops lets you chain all those together. Rops also gives you the choice of native nodes within its own network, or a remote control called a 'fetch' that will click that 'save to disk' button in a rop node anywhere else in your scene, like the fbx node you have.

A core assumption with rops however is that you're working frame sequences. In your case this is tricky, as you don't want to process a sequence of frames, but a collection of objects.

The traditional workaround was to pretend your objects were a sequence of frames somehow. So you might wire all your objects into a switch node, make the switch be controlled by $F, so that when rops renders the timeline, each frame gets a different piece of geometry. This might work for you, but I've had issues in the past where the fbx rop itself expects to be saving an animation sequence into a single file, it gets confused.

Tops, or Task Operators, is a more recent addition to Houdini, and is a more generalised context for managing processes. Tops does allow you to work on collections of objects directly, as well as fetch to other rop nodes in your scene. It's what I'd use here.

Right, history lesson over! I have a couple of examples and notes you might find useful:

https://www.tokeru.com/cgwiki/HoudiniTops#Export_RBD_fracture_pieces_to_seperate_fbx_files

https://www.tokeru.com/cgwiki/HoudiniTops#Tops_and_Rop_FBX_animation_output

(edit)

Ah, forgot to actually answer your questions:

  • Is there a way/node to export a piece of geometry as an ".fbx" without the need to tap "Save to Disk", as when using the "ROP FBX Output" node?

Yes,  use tops or rops (i'd use tops)

  • How to export the geometry as an ".fbx" so that it actually exports the material correctly as well, meaning that, once imported in Blender, it actually displays in the same way it can be seen in the Houdini rendering?

You'll need to play with this. Fbx is an oddball format that is half proprietary, half assumed standard in games, all the dccs support it slightly differently. Last I checked fbx is supposed to only support its own specific fbx material format, but no-one seems to care. I think if you create your materials using the standard houdini principled shader, that gets translated by the fbx rop into one of those basic fbx materials that supports simple texture slots, but then I don't know if blender's fbx importer will read it. There's also a fbx material type lurking in shops, the really old shader context of houdini, but I'd be amazed if the fbx rop is aware of it or would understand it.

  • Is there a way to export a geometry as an ".obj" + ".mtl" combo? From what I've read and seen, this doesn't seem to be something Houdini supports.

Pretty sure you can't.

 

Link to comment
Share on other sites

Hi Matt,

Thank you very much for the detailed answers (and guidelines), really appreciate it. I'll make sure to go through the links.

And also, think I understand a bit better the "rendering" idea behind Houdini. I'll continue digging into the .fbx export, but until I get it working, I'll keep using the .obj + .mtl + .jpg route.

I've actually managed to create a "pipeline" without any need for user input, where I save the .obj file, manually create the simplest .mtl file possible, export the SOP texture as .jpg, and update the .obj file with the newly created material name, using a python node. I'm updating the .obj because the default material name saved in the .obj is a full node path, e.g., /obj/matnet1/OUT_Material. This isn't a problem since Blender reads it like it is, but 3d Max converts the material name from the .obj file by replacing "/" with "_". That way, it ends up with .obj material named _obj_matnet1_OUT_Material and complains that it cannot find that specific material since the .mtl file still contains the material called /obj/matnet1/OUT_Material.

I'm attaching the functional project file (and the outputs) in case someone finds it helpful.

material_boxes_obj.hipnc

box.jpg

box.mtl box.obj

Edited by mbrajsa
forgot to attach pipeline outputs
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...