Parcourir la source

ShaderGraph : fix color node without link + fix init shader output

Tom SPIRA il y a 2 ans
Parent
commit
ac40ca532e
2 fichiers modifiés avec 11 ajouts et 0 suppressions
  1. 3 0
      hrt/shgraph/ShaderOutput.hx
  2. 8 0
      hrt/shgraph/nodes/Color.hx

+ 3 - 0
hrt/shgraph/ShaderOutput.hx

@@ -108,6 +108,9 @@ class ShaderOutput extends ShaderNode {
 	}
 
 	override public function saveProperties() : Dynamic {
+		if (this.variable == null) {
+			this.variable = ShaderNode.availableVariables[0];
+		}
 		var parameters : Dynamic = {
 			name: variable.name,
 			type: variable.type.getName(),

+ 8 - 0
hrt/shgraph/nodes/Color.hx

@@ -20,6 +20,14 @@ class Color extends ShaderConst {
 		addOutput("output", TVec(4, VFloat));
 	}
 
+	override public function getOutputTExpr(key : String) : TExpr {
+		return {
+			e: TVar(output),
+			p: null,
+			t: TVec(4, VFloat)
+		};
+	}
+
 	override public function build(key : String) : TExpr {
 
 		return { e: TBinop(OpAssign, {