public string getCallStr(BaseNode.NodeInput nodeInput, Dictionary <string, string> outputVariableNames) { var node = nodeInput.inputNode; int numInputs = node.inputs.Count; string callStr = ""; //pre evaluation callStr += getPreEvaluation(nodeInput); for (int i = 0; i < numInputs; i++) { var input = node.inputs[i]; if (null != input.inputNode) { callStr += GeneratorFactory.getShaderGenerator(input.inputNode).getCallStr(input, outputVariableNames); } } string outputVariableName = "out" + node.GetType().Name + node.getNodeID() + "_" + nodeInput.outputIndex; bool declareOutputVariable = !outputVariableNames.ContainsKey(outputVariableName); if (declareOutputVariable) { outputVariableNames.Add(outputVariableName, outputVariableName); callStr += "fixed4 "; } callStr += outputVariableName + "= " + getFunctionName(nodeInput) + "( uv,0,0"; for (int i = 0; i < numInputs; i++) { callStr += ", "; var input = node.inputs[i]; if (null != input.inputNode) { callStr += "out" + input.inputNode.GetType().Name + input.inputNode.getNodeID() + "_" + input.outputIndex; } else { callStr += "float4(0,0,0,0)"; } } callStr += " );\n"; //post-evaluation callStr += getPostEvaluation(nodeInput); return(callStr); }
private static string getCalls(ShaderLayer shaderLayer) { Dictionary <string, string> outputVariableNames = new Dictionary <string, string>(); string nodeCalls = ""; var rootInput = shaderLayer.getRoot().inputs[0]; if (rootInput.inputNode != null) { nodeCalls += GeneratorFactory.getShaderGenerator(rootInput.inputNode).getCallStr(rootInput, outputVariableNames); nodeCalls += "col = out" + rootInput.inputNode.GetType().Name + rootInput.inputNode.getNodeID() + "_" + rootInput.outputIndex + ";"; } return(nodeCalls); }
private static string getNodePropertyStr(BaseNode.NodeInput nodeInput) { var node = nodeInput.inputNode; return(GeneratorFactory.getShaderGenerator(node).getProperties(nodeInput)); }
private static string getNodeInputStr(BaseNode.NodeInput nodeInput) { return(GeneratorFactory.getShaderGenerator(nodeInput.inputNode).getInputs(nodeInput)); }
private static string getNodeFunctionStr(BaseNode.NodeInput nodeInput) { var node = nodeInput.inputNode; return(GeneratorFactory.getShaderGenerator(node).getFunctionSignature(nodeInput) + GeneratorFactory.getShaderGenerator(node).getFunctionBody(nodeInput) + "}\n"); }