浏览代码

shader graph: add Sqrt, rename Lerp to Mix, pretty print json

trethaller 4 年之前
父节点
当前提交
fb8a8ef239
共有 4 个文件被更改,包括 29 次插入3 次删除
  1. 1 0
      hide.hxml
  2. 1 1
      hrt/shgraph/ShaderGraph.hx
  3. 2 2
      hrt/shgraph/nodes/Mix.hx
  4. 25 0
      hrt/shgraph/nodes/Sqrt.hx

+ 1 - 0
hide.hxml

@@ -9,5 +9,6 @@ common.hxml
 --macro include("hxd.clipper")
 --macro include("hxd.earcut")
 --macro include("hrt.prefab")
+--macro include("hrt.shgraph.nodes")
 -dce no
 -debug

+ 1 - 1
hrt/shgraph/ShaderGraph.hx

@@ -547,7 +547,7 @@ class ShaderGraph {
 			parameters: [
 				for (p in parametersAvailable) { id : p.id, name : p.name, type : [p.type.getName(), p.type.getParameters().toString()], defaultValue : p.defaultValue }
 			]
-		});
+		}, "\t");
 
 		return json;
 	}

+ 2 - 2
hrt/shgraph/nodes/Lerp.hx → hrt/shgraph/nodes/Mix.hx

@@ -2,11 +2,11 @@ package hrt.shgraph.nodes;
 
 using hxsl.Ast;
 
-@name("Lerp")
+@name("Mix")
 @description("Linear interpolation between a and b using mix")
 @width(80)
 @group("Math")
-class Lerp extends ShaderFunction {
+class Mix extends ShaderFunction {
 
 	@input("a") var x = SType.Number;
 	@input("b") var y = SType.Number;

+ 25 - 0
hrt/shgraph/nodes/Sqrt.hx

@@ -0,0 +1,25 @@
+package hrt.shgraph.nodes;
+
+using hxsl.Ast;
+
+@name("Sqrt")
+@description("The output is the squre root A")
+@width(80)
+@group("Math")
+@:keep
+class Sqrt extends ShaderFunction {
+
+	@input("A") var a = SType.Number;
+
+	public function new() {
+		super(Sqrt);
+	}
+
+	override public function computeOutputs() {
+		if (a != null && !a.isEmpty())
+			addOutput("output", a.getType());
+		else
+			removeOutput("output");
+	}
+
+}