\@inspectableMethod(() => ({
x: GraphNumberF32,
y: GraphNumberF32,
z: GraphNumberF32,
}), () => GraphVector3F32)
\@carbonShaderExpression()
\@category("Construct")
static makeFloat3(node: CodeGeneratingGraphNode, context: GraphCodeGenerationContext)
{
context.emitCode(context.getTypeName(node.outputPins.front.type));
context.emitParameterListBegin();
context.emitInputValueOrInvocationForNode(node, node.inputPins[0]);
context.emitParameterListSeparator();
context.emitInputValueOrInvocationForNode(node, node.inputPins[1]);
context.emitParameterListSeparator();
context.emitInputValueOrInvocationForNode(node, node.inputPins[2]);
context.emitParameterListEnd();
}
The carbonShaderExpression requires the inspectableMethod decorator to be present on the function. Otherwise an error will be logged at startup. The inspectableMethod must used graph parameters such as GraphNumberF32 as input parameters.
It is important to keep the name of your function constant, otherwise graphs may cease to function as the registration is based on a mangled name, that includes the type and function name.
A static function that can be used as an expression in the Carbon Shader graph system. A node will be dynamically created and registered in the graph system. The decorated API will received a GraphCodeGenerationContext to generate the code for the expression.
The signature of the method must be
The function can then use the
nodeandcontextto dynamically generate the expression code for the code-generation language of thecontext.The following code shows how to create a function that calls the
float3constructors.