buildCode method
dynamic
buildCode()
override
Implementation
buildCode() {
var shadersData = {"fragment": {}, "vertex": {}};
for (var shaderStage in shadersData.keys) {
var flow = '// code\n';
flow += "\t${this.flowCode[shaderStage]}";
flow += '\n';
var flowNodes = this.flowNodes[shaderStage];
var mainNode = null;
if (flowNodes.length >= 1) {
mainNode = flowNodes[flowNodes.length - 1];
}
for (var node in flowNodes) {
Map flowSlotData = this.getFlowData(shaderStage, node);
var slotName = node.name;
if (slotName != null) {
if (flow.length > 0) flow += '\n';
flow += "\t// FLOW -> ${slotName}\n\t";
}
flow += "${flowSlotData["code"]}\n\t";
if (node == mainNode) {
flow += '// FLOW RESULT\n\t';
if (shaderStage == 'vertex') {
flow += 'NodeVarys.Vertex = ';
} else if (shaderStage == 'fragment') {
flow += 'return ';
}
flow += "${flowSlotData["result"]};";
}
}
var stageData = shadersData[shaderStage]!;
stageData["uniforms"] = this.getUniforms(shaderStage);
stageData["attributes"] = this.getAttributes(shaderStage);
stageData["varys"] = this.getVarys(shaderStage);
stageData["vars"] = this.getVars(shaderStage);
stageData["codes"] = this.getCodes(shaderStage);
stageData["flow"] = flow;
}
this.vertexShader = this._getWGSLVertexCode(shadersData["vertex"]);
this.fragmentShader = this._getWGSLFragmentCode(shadersData["fragment"]);
}