Maya Geometry loses shaders (goes green) using HISTORY mode

   1645   5   1
User Avatar
Member
5 posts
Joined: 3月 2019
Offline
Hi, I'm a long time Maya-based TA, but brand new to Houdini.
I'm trying to get the Engine plugin set up in Maya so that we can leverage some Houdini functionality inside Maya, as extra modelling tools for artists.
I have a working test HDA that simply does a UV Layout on a given mesh, (applying the layout ONLY to shells that are sitting in negative UV space). It works fine in Maya using what seems to be the "default approach" - i.e. it creates a new asset node with a transform child and a NEW COPY of the source mesh underneath it that the network is applied to.

However, I don't really want to use this method (at least in this example) as it's more of a mess to clean up afterwards, I'd much rather just apply the functionality onto the original mesh, i.e. as "history" ideally. This does seem to be supported by the plugin, but when I try it, either manually selecting and pressing buttons in the Attribute Editor, or via the provided MEL command(s), my source mesh DOES recieve the correct UV Layout, but it also goes bright green and loses all it's shader connections. If I then UNDO, all my UVs become permanently corrupt and the correct shader assignments never come back. (see images).



Am I doing something wrong in Maya, or in the HDA network? or is there a problem with this source mesh?
I tried the same approach on a simpler cube and it initially seemed to work fine, but as soon as I applied more than one material to the cube it exhibited the same broken behaviour. Likewise, I re-applied a single new shader to the whole original mesh and that also fixed it, so it does seem to be related to how the shaders are applied. I'm assuming it should work on meshes with more than one shader though, right?

Any ideas how I can fix or avoid this? Thanks
Edited by Naughty - 2023年7月21日 12:56:38

Attachments:
1_initial_mesh_uvs.png (114.7 KB)
2_hda_applied.png (132.6 KB)
3_after_undo.png (137.8 KB)

User Avatar
スタッフ
451 posts
Joined: 8月 2019
Offline
Hi Nathan,

Would you be able to share the HDA in question?
User Avatar
Member
5 posts
Joined: 3月 2019
Offline
Hi John, yes, I can absolutely share the HDA and/or the Maya scene/test object, all of this is just test data atm.

I assume I can just add all that here as an attachment? lets try it and see.

and, for context, here is the python code I am using to "execute" everything (assuming plugin is already loaded and active):

from maya import cmds, mel
cmds.select('hourglass')
hdaFile = 'D:/tests/HDA/Partial_UV_Layout.hda'
hdaAssets = cmds.houdiniAsset(listAssets=hdaFile)
hdaAsset = hdaAssets[0] # only one, just assume the first
assetNode = mel.eval('houdiniEngine_loadAndAddAsset "{}" "{}" "HISTORY";'.format(hdaFile, hdaAsset))

Many thanks for taking a look.
Edited by Naughty - 2023年7月21日 12:49:38

Attachments:
Partial_UV_Layout.hda (6.0 KB)
hourglass.ma (839.7 KB)

User Avatar
スタッフ
451 posts
Joined: 8月 2019
Offline
Thanks for that. I believe the issue is due to the fact that the plugin does not know if it's safe to re-apply the materials to the same components. For instance, your history asset could have performed something like a polygon reduction - in this case it is not safe to reapply the materials to the same components as the components themselves have changed.

As a work-around, since you know that your components haven't changed, you could do something like the following:

from maya import cmds, mel

def partial_layout(dest):
    hdaFile   = 'Partial_UV_Layout.hda'
    hdaAssets = cmds.houdiniAsset(listAssets=hdaFile)
    hdaAsset  = hdaAssets[0] # only one, just assume the first
    assetNode = mel.eval('houdiniEngine_loadAsset "{}" "{}";'.format(hdaFile, hdaAsset))
    src       = assetNode + '_0'

    cmds.select(dest)

    mel.eval('AEhoudiniAssetSetInputToSelection("{}.input[0].inputNodeId");'.format(assetNode))
    mel.eval('houdiniEngine_syncAssetOutput "{}";'.format(assetNode))
    mel.eval('houdiniEngine_bakeAsset "{}";'.format(assetNode))

    cmds.delete(assetNode)

    cmds.transferAttributes(src, dest, transferUVs=2, sampleSpace=4, sourceUvSpace="map1", targetUvSpace="map1", searchMethod=3)
    cmds.delete(dest, ch=True)

    cmds.delete(src)

    cmds.select(dest)

partial_layout(cmds.ls(sl=True))
Edited by johnmather - 2023年8月1日 13:49:41
User Avatar
Member
5 posts
Joined: 3月 2019
Offline
Hi John, thanks for taking the time to look into this for me. This is essentially what I'm already having to do as a workaround; use the standard method to create a new asset then transfer the UVs from the new instance back onto to the original and delete the asset. The problem I have with this approach is that it requires a bespoke "clean-up" procedure for every HDA we make, which means users can't simply add new generic HDAs to the "Maya HDA tool collection" without a corresponding script written on the Maya side, which is disappointing.

Am I to assume from this then, that the history method just doesn't work on meshes that have more than a single material applied? And, if it is ultimately due to the fact that they can't know if the mesh component IDs have changed or not, does that mean it can never be fixed..?

If I poly reduce a mesh in Houdini that has different materials on its faces, presumably Houdini can still retain some semblance of material assignment information post reduction? is this data not something that can be stored/extracted at the Maya side? Actually, obviously it is, because it all works fine in non-history mode... :S

Maybe a better alternative workaround could be to apply a single shader to the original source mesh before attaching it to the HDA as history, and then re-applying the original shaders afterwards. This would effectively be our single, generic "clean-up procedure" and thus still allow users to add HDAs without worying about how they will be correctly applied/cleaned up. Might be awkward if the HDA has to do anything with shader assignments :o

We'll stick with the workarounds for now and I'll experiment with the shader-swapping approach, but if you (or anyone else reading this) figures anything else out in the meantime that could be helpful, it'd be great to hear it.

Cheers!
User Avatar
スタッフ
451 posts
Joined: 8月 2019
Offline
Hi Nathan,

To be honest, I don't have much experience with the history mode as it isn't commonly used. There does seem to be some underlying bug with assigning multiple shaders, however I spent quite a while in the node editor trying to figure out what was different in term of the connections. Unfortunately I wasn't able to resolve the issue there, so I'll most likely need to dig into the code and see if any of the underlying data is different.

I won't say that it can never be fixed, however I need to figure out exactly what is different before I can start implementing one.
  • Quick Links