Today, we are going to look at a little bit inside of fragment graph's connect element. For the first two attributes, from and to are self-explanatory. Essentially this allows connecting from one fragment's output to another fragment's input. However, the “name” attribute is not well explained.
The fragment graph is designed like the dependency graph in Maya. Connecting different nodes and having outputs after running through a series of fragments you'll get the result. But unlike the dependency graph, the fragment graph cannot accept inputs having the same name. For example, if you have a fragment f1 that you would like to create multiple instances and then connect to different fragments.
<connect from="f1.output" to="f2.input"/> <connect from="f1.output" to="f3.input"/>
In this case, you will have to rename the output of f1 with the “name” attribute so Maya will create multiple instances of f1 to connect them properly. Otherwise, only the first one will be connected.
<connect from="f1.output" to="f2.input" name="f2Input"/> <connect from="f1.output" to="f3.input" name="f3Input"/>
But there is also an exception here. When you are declaring an input struct for the alias output like this:
<properties> <struct name=\"fileTexturePluginFragmentOutput\" struct_name=\"fileTexturePluginFragmentOutput\" /> </properties> <outputs> <alias name=\"fileTexturePluginFragmentOutput\" struct_name=\"fileTexturePluginFragmentOutput\" /> <float3 name=\"outColor\" /> <float name=\"outAlpha\" /> </outputs>
The input(properties) “name” shouldn't be changed if you want to connect its output in your graph. After you've changed its name, Maya will try to create another instance of the renamed structure. After the input name is changed, Maya can't find the alias with original name and so the fragment graph can't be created.
The conclusion for correctly using the “name” attribute of the connect element:
- Rename the input attribute when reusing the same fragment's input for multiple outputs.
- Don't rename an alias output.