I believe the MaterialX file listed below should work. However, I get the following warnings:
Mismatched types in port connection: <input name="diffuseColor" type="color3" nodename="myfunc1" member="color">
Mismatched types in port connection: <input name="roughness" type="float" nodename="myfunc1" member="roughness">
<?xml version="1.0"?>
<materialx version="1.38" colorspace="lin_rec709">
<typedef name="myoutput">
<member name="color" type="color3"/>
<member name="roughness" type="float"/>
</typedef>
<nodedef name="ND_myfunc_myoutput" node="myfunc">
<input name="in1" type="color3" value="0.5, 0, 0"/>
<input name="in2" type="color3" value="0.5, 0, 0"/>
<output name="out1" type="myoutput"/>
</nodedef>
<implementation name="IM_myfunc_myoutput" nodedef="ND_myfunc_myoutput" file="blah2.glsl" function="myfunc"/>
<myfunc name="myfunc1" type="myoutput">
<input name="in1" type="color3" value="0, 0.5, 0"/>
<input name="in2" type="color3" value="0, 0.5, 0"/>
</myfunc>
<UsdPreviewSurface name="SR_default" type="surfaceshader">
<input name="diffuseColor" type="color3" nodename="myfunc1" member="color"/>
<input name="roughness" type="float" nodename="myfunc1" member="roughness"/>
</UsdPreviewSurface>
<surfacematerial name="mymaterial" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_default"/>
</surfacematerial>
</materialx>
I'm not sure how blah2.glsl should be written in this case, but this is what I'm trying:
void myfunc(vec3 in1, vec3 in2, out myoutput out1)
{
out1.color = in1 + in2;
out1.roughness = 0.5;
}