Closed kwokcb closed 4 months ago
@kwokcb The reason for that is that QuiltiX didn't detect the node type names from the gltf image node definitions correctly. QuiltiX is looking at the nodef name, which is in this case: ND_gltf_image_vector3_vector3_1_0, which is quite different from other node definitions. This pull request split the nodedef name now by underscores to find the correct type: https://github.com/PrismPipeline/QuiltiX/pull/68
It works for all nodes that I'm aware of, but it still feels like a dirty workaround. Do you know a better way to detect the type from a node definition?
Hi @RichardFrangenberg ,
The safest way to do this would be to get the output
s for the nodedef
. If there is more than 1 then it's type is multioutput
. Otherwise get the type from the single output
. Parsing the name is unreliable especially for nodedefs
coming from various DCCs which can use different naming logic.
Using the output type doesn't seem like a safe way too. For example there are the ND_extract_color3
and ND_extract_color4
node definitions, which outputs are of type float
.
Hi @RichardFrangenberg ,
Yes, you are correct.
The more general logic is found in Node::getNodeDef()
Here it will match by:
For 4. there still exists a problem if you don't specify enough unique inputs on the node instance. There is a logged issue for this I believe. However it is the most complete logic check that I know of in use, except for 5.
nodedef
name on the node instance's nodedef
attribute at creation time. ( I'm unsure if this is the reason why, but as you know USD stores the nodedef
name in the SDR registry and then specifies this on USDShade node instances. )With this getNodeDef() function I can get the correct definition from a mtlx node, but there is still the problem how QuiltiX should populate the type dropdown for nodes like the Extract node.
I would like to avoid having every single node definition in the tab menu like LookdevX is doing it.
Instead I would prefer to keep it as it is and have only Extract in the tab menu and a dropdown in the node settings with the node types, like Houdini is doing it.
In that case there is no mtlx node, which needs to be matched to a definition. I only have a list of definitions and I need to extract a gui friendly string for the dropdown. ND_extract_color3
or ND_gltf_image_vector3_vector3_1_0
are not really gui friendly.
For this context, yes the nodedef names in the std library weren't really intended for user facing parsing.
I also do not like exploding all variants and am interested in the solution to this.
All I can think of is to allow output type as the primary selection key and where ambiguous input type, version, target, namespace as subsequent keys. If you handle input type that should at least handle extract.
You can use getMatchingNodeDefs()
as done getNodeDef() to find all the variants.
On the flip-side would you be interested in looking into a "standardized" naming scheme. I do this for new node definitions myself and reflect this in the output file name. Then there is a sequence of sub-strings that can be parsed. e.g.
NG_[<output_type>...]_[<input_type>]_<version>_<target>
(std disclaimer, I had been looking at this for LookdevX before moving on).
Yet even with this anyone can create a nodedef name which does not parse well. Thus the suggestion to parse the actual attributes on the nodedef.
I changed the approach how the nodedefinitions are chosen when a mtlx file gets loaded.
It's using the getNodeDef
function now, so all that logic is now handled by MaterialX itself instead of in the QuiltiX code.
The only not so clean code, which is left, is how the displayname is generated from the nodedefname. It would be great if MaterialX would provide displaynames in the future, but for the moment the current implementation in QuiltiX does the job.
I would be fine with enforcing a naming convention for nodedefs created in QuiltiX. But as you said, there might be nodedefs coming from other applications, which don't follow this convention.
Issue
A gltf image node which is of type vector3 ends up being a color3 after load for some reason.
This is an example file:
The errors you get are:
This be because the
gltf_image
type is considered to becolor3
.If you save it out you get: