Solaris to Unreal Engine - Material Assignment

   8038   11   8
User Avatar
Member
1 posts
Joined: May 2018
Offline
Hi,

I'm trying the Houdini Solaris to UE4 USD workflow and it works pretty well so far.
Models and textures are showing and everything is in the right place. Very promising. Even point clouds are working.
I would like to apply existing unreal materials to specific meshes when opening or reloading the stage.
Houdini Digital Assets can do this with the unreal_material parameter where you assign the reference path of the material.

Looking through the source code of UnrealUSDWrapper there might be already a function in there:

// load each material at the material path;
UsdPrim MaterialPrim = Stage->Load(Path);

if(MaterialPrim)
{
// Default to using the prim path name as the path for this material in Unreal
FString MaterialName = ANSI_TO_TCHAR( MaterialPrim.GetName().GetString().c_str() ) ;

std::string UsdMaterialName;

// See if the material has an “unrealAssetPath” attribute. This should be the full name of the material
static const TfToken AssetPathToken = TfToken(UnrealIdentifiers::AssetPath);
UsdAttribute UnrealAssetPathAttr = MaterialPrim.GetAttribute(AssetPathToken);
if (UnrealAssetPathAttr && UnrealAssetPathAttr.HasValue())
{
UnrealAssetPathAttr.Get(&UsdMaterialName);


}

MaterialNames.Add( MoveTemp( MaterialName ) );
}

What kind of attribute and where do I need to create in Houdini Solaris to make this work in Unreal's USD Stage, if possible?

Thank you!

Steffen
User Avatar
Staff
1454 posts
Joined: July 2005
Offline
From the comment there, it looks like you need to create “unrealAssetPath” attribute of ‘asset’ type on the USD material primitive. You should be able to use Properties LOP do do that.
User Avatar
Member
113 posts
Joined: July 2005
Offline
Hi Steffen -
I'm very impressed you've got this far with the Houdini/UE4 Pipeline.
Is there a documentation you are following?
I'm relatively new to USD and have gone through the SideFX LOP tutorials.
However, I've seem to have hit a brick wall when trying to import into UE4.
I can't seem to get anything I export to import into the UE4 asset browser or get loaded into the USD Stage Actor.
I am able to get the “Original” USD assets to appear in the USD Stage Actor but that would be about it.
Any sort of direction for a USD NEWB is appreciated!
User Avatar
Member
52 posts
Joined:
Offline
Would be lovely to get some light on this workflow too as I too haven't seen much documentation about Solaris -> to Unreal workflows.

Could you share some pointers?

Thanks in advance !
User Avatar
Member
174 posts
Joined: March 2014
Offline
rafal
Solaris -> to Unreal
Hi,
I'm testing that but with “unrealAssetPath + (copy reference in Unreal)” propery on the material UE4.25 doesn't pick the material…
More than that, every Material applied in the editor don't survive after a close/open of UE…
Unusable !
User Avatar
Member
275 posts
Joined: Sept. 2012
Offline
Hey guys

Actually i think like you we are a bunch to be relatively new to Solaris, Unreal and USD.
I will be really interested to see a masterclass with an Houdini sample scene about how to create and manage a full environment, in USD with Solaris, which will be completely DCC agnostic. You could use the same USD scene to work in Houdini, edit in Blender or Maya export the scene in Unreal and finish there. Even Substance support USD to what i know, (havent tried myself )


Any input on this wide but important subject will be welcomed

________________________________________________________________
Vincent Thomas   (VFX and Art since 1998)
Senior Env artist & Lighting & MattePainter & Creative Concepts
 http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
Vincent Thomas   (VFX and Art since 1998)
Senior Env and Lighting  artist & Houdini generalist & Creative Concepts
http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
User Avatar
Member
16 posts
Joined: June 2018
Offline
NNois
rafal
Solaris -> to Unreal
Hi,
I'm testing that but with "unrealAssetPath + (copy reference in Unreal)" propery on the material UE4.25 doesn't pick the material...
More than that, every Material applied in the editor don't survive after a close/open of UE...
Unusable !

Hey,
Did you find a solution not to loose material assignments after opening new USD in Unreal?

Thanks
User Avatar
Member
54 posts
Joined: Jan. 2016
Online
I’m also looking for an answer to this question, did anyone ever figure out how to setup proper material assignments when going from Houdini to Unreal?
User Avatar
Member
20 posts
Joined: Oct. 2013
Offline
Hi
quite an old thread, anyway I found out:
to assign an existing Unreal Material to a primitive via USD one would need this attribute:
custom string unrealMaterial = "/Game/Materials/Glas.Glas" (for example).
You can choose between this override and the preview USD Material within the stage editor


I have no idea how to assign any other unreal attribute, like e.g. "overridden lightmap Resolution". If somebody has an idea (?)
Edited by raschberg - Jan. 22, 2023 08:38:58

Attachments:
chooseContext.jpg (633.7 KB)
screenshot_USDMaterial.jpg (1.0 MB)

User Avatar
Member
24 posts
Joined: July 2018
Offline
Curious if anyone got this working. I've got everything setup on the Houdini side but still can't get Unreal to recognize and use the Custom 'unrealMaterial' attribute and assign the shader in engine.
User Avatar
Member
24 posts
Joined: July 2018
Offline
Nevermind,got it working. Hip file...
Image Not Found

Attachments:
USD_ToUnreal_wMaterials.hiplc (206.9 KB)

User Avatar
Member
13 posts
Joined: Sept. 2016
Offline
Hi, I've also been trying to get this to work as a way to have a minimum of effort in Unreal and here are some of the gotchas I bumped into.

First I couldn't make an USD with Unreal materials and MaterialX work at the same time, so it seems you need to decide which one you want to use. Changing the USD Stage Editor > Options > Render Context changes which material kind you'll see (click the bulletpoint instead of the text if you want the menu to continue open).


--Unreal Materials
I got the unrealMaterial attribute working, just make sure it's not named as primvars:unrealMaterial, and it's not an Array like it will be if you set it as polygons attribute. You can simply set it in an Attribute Wrangle LOP, or if using SOP Create LOP you can put it in the USD Custom Attributes parameter so it avoids the primvar: prefix. It can be set to subsets.

The path to the Unreal material can either have the Type bits before /Game/ like this "/Script/Engine.Material'/Game/StarterContent/Materials/M_Basic_Floor.M_Basic_Floor'" or shorter like '/Game/StarterContent/Materials/M_Basic_Floor.M_Basic_Floor', it doesn't seem to matter.


--MaterialX
So first thing is that the materials shouldn't come inside of the USD but the .mtlx files referenced in it. So in your USD ROP make sure in your Save Style you are "Preserving References". Flattening the Stage will prevent the materialX's from working in Unreal.

I haven't figured out if there's a way of using relative paths, so I just didn't use any Houdini variables like $HIP and made sure all my paths were absolute.

If you authored your mtlx in Houdini exporting it from a Mtlx Surface Material node works for me, when exporting from Mtlx Standard Surface or Collect nodes it doesn't.


--
So because of having to decide which Render Context to work with, it seems to me that if it's not important for you to have your materials set in Houdini, you should simply set the unrealMaterial primvar and have all your materials in Unreal, even your MaterialXs, as you can import them separately from your USD. This way you can mix them with Bridge's surfaces easily, for intance.

USD Preview Materials also work out of the box but for some reason sometimes the BaseColorScaleTranslation color come with weird values in the alpha that I need to reset for the textures not to be all stretched out.

As a side note, lights and cameras were imported nicely on first try, with even correct area lights colour/sizes and focus length. Also, transform animations and point deformations come for free, so the whole process is looking promising.

I attached a zip with my HIP, USD, MTLX and texture files for you to play with. Just check the paths as they'll be absolute, and here's a preview of Houdini next to Unreal:

Cheers

Image Not Found
Edited by edschiffer - Sept. 2, 2024 15:54:45

Attachments:
solaris2unreal.png (1003.4 KB)
solaris2unreal.zip (8.3 MB)

  • Quick Links