2
0
Clement Espeute 2 жил өмнө
parent
commit
08af05681a
39 өөрчлөгдсөн 528 нэмэгдсэн , 797 устгасан
  1. 7 7
      hide/view/shadereditor/ShaderEditor.hx
  2. 7 10
      hrt/shgraph/nodes/BoolConst.hx
  3. 10 14
      hrt/shgraph/nodes/Clamp.hx
  4. 52 1
      hrt/shgraph/nodes/Color.hx
  5. 13 101
      hrt/shgraph/nodes/Combine.hx
  6. 9 45
      hrt/shgraph/nodes/CombineAlpha.hx
  7. 8 13
      hrt/shgraph/nodes/Cos.hx
  8. 9 17
      hrt/shgraph/nodes/Cross.hx
  9. 9 4
      hrt/shgraph/nodes/Divide.hx
  10. 9 10
      hrt/shgraph/nodes/Dot.hx
  11. 8 13
      hrt/shgraph/nodes/Exp.hx
  12. 38 30
      hrt/shgraph/nodes/FloatConst.hx
  13. 8 13
      hrt/shgraph/nodes/Floor.hx
  14. 8 13
      hrt/shgraph/nodes/Fract.hx
  15. 8 13
      hrt/shgraph/nodes/Length.hx
  16. 8 13
      hrt/shgraph/nodes/Log.hx
  17. 9 17
      hrt/shgraph/nodes/Max.hx
  18. 0 28
      hrt/shgraph/nodes/Maximum.hx
  19. 9 16
      hrt/shgraph/nodes/Min.hx
  20. 0 27
      hrt/shgraph/nodes/Minimum.hx
  21. 10 19
      hrt/shgraph/nodes/Mix.hx
  22. 9 14
      hrt/shgraph/nodes/Mod.hx
  23. 1 5
      hrt/shgraph/nodes/Multiply.hx
  24. 8 12
      hrt/shgraph/nodes/Normalize.hx
  25. 9 13
      hrt/shgraph/nodes/Pow.hx
  26. 8 13
      hrt/shgraph/nodes/Saturate.hx
  27. 8 13
      hrt/shgraph/nodes/Sin.hx
  28. 10 19
      hrt/shgraph/nodes/SmoothStep.hx
  29. 15 26
      hrt/shgraph/nodes/Split.hx
  30. 8 13
      hrt/shgraph/nodes/Sqrt.hx
  31. 9 18
      hrt/shgraph/nodes/Step.hx
  32. 12 39
      hrt/shgraph/nodes/StripAlpha.hx
  33. 118 118
      hrt/shgraph/nodes/SubGraph.hx
  34. 9 5
      hrt/shgraph/nodes/Subtract.hx
  35. 8 13
      hrt/shgraph/nodes/Tan.hx
  36. 25 25
      hrt/shgraph/nodes/Text.hx
  37. 16 3
      hrt/shgraph/nodes/UVScroll.hx
  38. 8 13
      hrt/shgraph/nodes/UnpackNormal.hx
  39. 8 11
      hrt/shgraph/nodes/UvToScreen.hx

+ 7 - 7
hide/view/shadereditor/ShaderEditor.hx

@@ -988,11 +988,11 @@ class ShaderEditor extends hide.view.Graph {
 			shaderPreview.shaderGraph = shaderGraph;
 			return;
 		}*/
-		var subGraphNode = Std.downcast(node, hrt.shgraph.nodes.SubGraph);
-		if (subGraphNode != null) {
-			subGraphNode.loadGraphShader();
-			return;
-		}
+		// var subGraphNode = Std.downcast(node, hrt.shgraph.nodes.SubGraph);
+		// if (subGraphNode != null) {
+		// 	subGraphNode.loadGraphShader();
+		// 	return;
+		// }
 	}
 
 	function addNode(p : Point, nodeClass : Class<ShaderNode>) {
@@ -1011,7 +1011,7 @@ class ShaderEditor extends hide.view.Graph {
 	function addSubGraph(p : Point, path : String) {
 		var node : SubGraph = cast addNode(p, SubGraph);
 		@:privateAccess node.pathShaderGraph = path;
-		node.loadGraphShader();
+		// node.loadGraphShader();
 		return node;
 	}
 
@@ -1340,7 +1340,7 @@ class ShaderEditor extends hide.view.Graph {
 				field = edge.nodeFrom.attr("field");
 			}
 			var newBox = refreshBox(edge.to);
-			subGraph.loadGraphShader();
+			// subGraph.loadGraphShader();
 
 			clearAvailableNodes();
 			if (isCreatingLink == FromInput) {

+ 7 - 10
hrt/shgraph/nodes/BoolConst.hx

@@ -12,16 +12,13 @@ class BoolConst extends ShaderConst {
 
 	@prop() var value : Bool = true;
 
-	// override public function getOutputTExpr(key : String) : TExpr {
-	// 	return {
-	// 				e: TConst(CBool(value)),
-	// 				p: null,
-	// 				t: TBool
-	// 			};
-	// }
-
-	override public function build(key : String) : TExpr {
-		return null;
+	override function getShaderDef():hrt.shgraph.ShaderGraph.ShaderNodeDef {
+		var pos : Position = {file: "", min: 0, max: 0};
+
+		var output : TVar = {name: "output", id:1, type: TBool, kind: Local, qualifiers: [SgOutput]};
+		var finalExpr : TExpr = {e: TBinop(OpAssign, {e:TVar(output), p:pos, t:output.type}, {e: TConst(CBool(value)), p: pos, t: output.type}), p: pos, t: output.type};
+
+		return {expr: finalExpr, inVars: [], outVars:[output], externVars: [output], inits: []};
 	}
 
 	#if editor

+ 10 - 14
hrt/shgraph/nodes/Clamp.hx

@@ -6,20 +6,16 @@ using hxsl.Ast;
 @description("Limits value between min and max")
 @width(80)
 @group("Math")
-class Clamp extends ShaderFunction {
+class Clamp extends ShaderNodeHxsl {
 
-// 	@input("X") var x = SType.Number;
-// 	@input("Min", true) var min = SType.Number;
-// 	@input("Max", true) var max = SType.Number;
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var min : Vec4;
+		@sginput var max : Vec4;
 
-// 	public function new() {
-// 		super(Clamp);
-// 	}
-
-// 	override public function computeOutputs() {
-// 		if (x != null && !x.isEmpty())
-// 			addOutput("output", x.getType());
-// 		else
-// 			removeOutput("output");
-// 	}
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = clamp(a, min, max);
+		}
+	};
 }

+ 52 - 1
hrt/shgraph/nodes/Color.hx

@@ -26,6 +26,57 @@ class Color extends ShaderConst {
 	// 	};
 	// }
 
+	override function getShaderDef():hrt.shgraph.ShaderGraph.ShaderNodeDef {
+		var pos : Position = {file: "", min: 0, max: 0};
+
+		var output : TVar = {name: "output", id:1, type: TVec(4, VFloat), kind: Local, qualifiers: [SgOutput]};
+		var finalExpr : TExpr =
+		{ e: TBinop(OpAssign, {
+				e: TVar(output),
+				p: null,
+				t: output.type
+			}, {
+				e: TCall({
+					e: TGlobal(Vec4),
+					p: null,
+					t: TFun([
+						{
+							ret: output.type,
+							args: [
+							{ name: "r", type : TFloat },
+							{ name: "g", type : TFloat },
+							{ name: "b", type : TFloat },
+							{ name: "a", type : TFloat }]
+						}
+					])
+				}, [{
+						e: TConst(CFloat(r)),
+						p: null,
+						t: TFloat
+					},
+					{
+						e: TConst(CFloat(g)),
+						p: null,
+						t: TFloat
+					},
+					{
+						e: TConst(CFloat(b)),
+						p: null,
+						t: TFloat
+					},{
+						e: TConst(CFloat(a)),
+						p: null,
+						t: TFloat
+					}]),
+				p: null,
+				t: output.type
+			}),
+			p: null,
+			t: output.type
+		};
+		return {expr: finalExpr, inVars: [], outVars:[output], externVars: [output], inits: []};
+	}
+
 	// override public function build(key : String) : TExpr {
 
 	// 	return { e: TBinop(OpAssign, {
@@ -77,7 +128,7 @@ class Color extends ShaderConst {
 	override public function getPropertiesHTML(width : Float) : Array<hide.Element> {
 		var elements = super.getPropertiesHTML(width);
 		var element = new hide.Element('<div style="width: 47px; height: 35px"></div>');
-		var picker = new hide.comp.ColorPicker(true, element);
+		var picker = new hide.comp.ColorPicker.ColorBox(element, true, true);
 
 
 		var start = h3d.Vector.fromArray([r, g, b, a]);

+ 13 - 101
hrt/shgraph/nodes/Combine.hx

@@ -8,105 +8,17 @@ using hxsl.Ast;
 @name("Combine")
 @description("Create a vector of size 4 from 4 floats")
 @group("Channel")
-class Combine extends ShaderNode {
-
-	// @input("R", false, false) var r = SType.Float;
-	// @input("G", false, false) var g = SType.Float;
-	// @input("B", false, false) var b = SType.Float;
-	// @input("A", false, false) var a = SType.Float;
-
-
-	var components = [X, Y, Z, W];
-	var componentsString = ["r", "g", "b", "a"];
-	var numberOutputs = 0;
-
-	// function generateOutputComp(idx : Int) : TExpr {
-	// 	var comp = components[idx];
-
-	// 	var input = getInput(componentsString[idx]);
-	// 	return {
-	// 				p : null,
-	// 				t : output.type,
-	// 				e : TBinop(OpAssign, {
-	// 					e: TSwiz({
-	// 						e: TVar(output),
-	// 						p: null,
-	// 						t : output.type
-	// 					}, [comp]),
-	// 					p: null,
-	// 					t: TVec(1, VFloat)
-	// 				}, input.getVar())
-	// 			};
-	// }
-
-	// override public function computeOutputs() {
-	// 	numberOutputs = 0;
-	// 	if (a != null && !a.isEmpty()) {
-	// 		numberOutputs = 4;
-	// 	} else if (b != null && !b.isEmpty()) {
-	// 		numberOutputs = 3;
-	// 	} else if (g != null && !g.isEmpty()) {
-	// 		numberOutputs = 2;
-	// 	} else if (r != null && !r.isEmpty()) {
-	// 		numberOutputs = 1;
-	// 	}
-	// 	if (numberOutputs == 1) {
-	// 		addOutput("output", TFloat);
-	// 	} else {
-	// 		addOutput("output", TVec(numberOutputs, VFloat));
-	// 	}
-	// }
-
-	// override public function build(key : String) : TExpr {
-
-	// 	var args = [];
-	// 	var valueArgs = [];
-	// 	var opTGlobal : TGlobal = Vec4;
-	// 	if (numberOutputs >= 1) {
-	// 		args.push({ name: "r", type : TFloat });
-	// 		valueArgs.push(r.getVar());
-	// 		opTGlobal = ToFloat;
-	// 	}
-	// 	if (numberOutputs >= 2) {
-	// 		args.push({ name: "g", type : TFloat });
-	// 		valueArgs.push(g.getVar());
-	// 		opTGlobal = Vec2;
-	// 	}
-	// 	if (numberOutputs >= 3) {
-	// 		args.push({ name: "b", type : TFloat });
-	// 		valueArgs.push(b.getVar());
-	// 		opTGlobal = Vec3;
-	// 	}
-	// 	if (numberOutputs >= 4) {
-	// 		args.push({ name: "a", type : TFloat });
-	// 		valueArgs.push(a.getVar());
-	// 		opTGlobal = Vec4;
-	// 	}
-
-	// 	return {
-	// 		p : null,
-	// 		t : output.type,
-	// 		e : TBinop(OpAssign, {
-	// 			e: TVar(output),
-	// 			p: null,
-	// 			t : output.type
-	// 		},
-	// 		{
-	// 			e: TCall({
-	// 				e: TGlobal(opTGlobal),
-	// 				p: null,
-	// 				t: TFun([
-	// 					{
-	// 						ret: output.type,
-	// 						args: args
-	// 					}
-	// 				])
-	// 			}, valueArgs
-	// 			),
-	// 			p: null,
-	// 			t: output.type
-	// 		})
-	// 	};
-	// }
-
+class Combine extends ShaderNodeHxsl {
+
+	static var SRC = {
+		@sginput var r : Float;
+		@sginput var g : Float;
+		@sginput var b : Float;
+		@sginput var a : Float;
+		@sgoutput var output : Vec4;
+
+		function fragment() {
+			output = vec4(r,g,b,a);
+		}
+	}
 }

+ 9 - 45
hrt/shgraph/nodes/CombineAlpha.hx

@@ -8,52 +8,16 @@ using hxsl.Ast;
 @name("Combine Alpha")
 @description("Create a vector of size 4 from a RGB and an Alpha float")
 @group("Channel")
-class CombineAlpha extends ShaderNode {
+class CombineAlpha extends ShaderNodeHxsl {
 
-	// @input("RGB") var rgb = SType.Vec3;
-	// @input("A", true) var a = SType.Float;
+	static var SRC = {
+		@sginput var rgb : Vec3;
+		@sginput var a : Float;
+		@sgoutput var output : Vec4;
 
-
-	// override public function computeOutputs() {
-
-	// 	addOutput("output", TVec(4, VFloat));
-	// }
-
-	// override public function build(key : String) : TExpr {
-
-	// 	var args = [];
-	// 	var valueArgs = [];
-	// 	var opTGlobal : TGlobal = Vec4;
-	// 	args.push({ name: "rgb", type : TVec(3, VFloat) });
-	// 	valueArgs.push(rgb.getVar());
-	// 	args.push({ name: "a", type : TFloat });
-	// 	valueArgs.push(a.getVar());
-	// 	opTGlobal = Vec4;
-
-	// 	return {
-	// 		p : null,
-	// 		t : output.type,
-	// 		e : TBinop(OpAssign, {
-	// 			e: TVar(output),
-	// 			p: null,
-	// 			t : output.type
-	// 		},
-	// 		{
-	// 			e: TCall({
-	// 				e: TGlobal(opTGlobal),
-	// 				p: null,
-	// 				t: TFun([
-	// 					{
-	// 						ret: output.type,
-	// 						args: args
-	// 					}
-	// 				])
-	// 			}, valueArgs
-	// 			),
-	// 			p: null,
-	// 			t: output.type
-	// 		})
-	// 	};
-	// }
+		function fragment() {
+			output = vec4(rgb,a);
+		}
+	}
 
 }

+ 8 - 13
hrt/shgraph/nodes/Cos.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("The output is the cosinus of A")
 @width(80)
 @group("Math")
-class Cos extends ShaderFunction {
+class Cos extends ShaderNodeHxsl {
 
-	// @input("A") var a = SType.Float;
-
-	// public function new() {
-	// 	super(Cos);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", a.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = cos(a);
+		}
+	};
 
 }

+ 9 - 17
hrt/shgraph/nodes/Cross.hx

@@ -6,23 +6,15 @@ using hxsl.Ast;
 @description("The output is the cross product of a and b")
 @width(80)
 @group("Math")
-class Cross extends ShaderFunction {
+class Cross extends ShaderNodeHxsl {
 
-	// @input("A") var a = SType.Number;
-	// @input("B") var b = SType.Number;
+	static var SRC = {
+		@sginput var a : Vec3;
+		@sginput var b : Vec3;
+		@sgoutput var output : Vec3;
+		function fragment() {
+			output = cross(a,b);
+		}
+	};
 
-	// public function new() {
-	// 	super(Cross);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty() && b != null && !b.isEmpty())
-	// 		addOutput("output", a.getVar(b.getType()).t);
-	// 	else if (a != null && !a.isEmpty() )
-	// 		addOutput("output", a.getType());
-	// 	else if (b != null && !b.isEmpty())
-	// 		addOutput("output", b.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
 }

+ 9 - 4
hrt/shgraph/nodes/Divide.hx

@@ -6,10 +6,15 @@ using hxsl.Ast;
 @description("The output is the result of A / B")
 @width(80)
 @group("Operation")
-class Divide extends Operation {
+class Divide extends ShaderNodeHxsl {
 
-	// public function new() {
-	// 	super(OpDiv);
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = a / b;
+		}
+	};
 
 }

+ 9 - 10
hrt/shgraph/nodes/Dot.hx

@@ -6,16 +6,15 @@ using hxsl.Ast;
 @description("The output is the dot product of a and b")
 @width(80)
 @group("Math")
-class Dot extends ShaderFunction {
+class Dot extends ShaderNodeHxsl {
 
-	// @input("A") var a = SType.Number;
-	// @input("B") var b = SType.Number;
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sgoutput var output : Float;
+		function fragment() {
+			output = dot(a,b);
+		}
+	};
 
-	// public function new() {
-	// 	super(Dot);
-	// }
-
-	// override public function computeOutputs() {
-	// 	addOutput("output", TFloat);
-	// }
 }

+ 8 - 13
hrt/shgraph/nodes/Exp.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("The output is the result of exp(x)")
 @width(80)
 @group("Math")
-class Exp extends ShaderFunction {
+class Exp extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Number;
-	// @input("P", true) var p = SType.Number;
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = exp(a);
+		}
+	};
 
-	// public function new() {
-	// 	super(Exp);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
 }

+ 38 - 30
hrt/shgraph/nodes/FloatConst.hx

@@ -9,8 +9,16 @@ using hxsl.Ast;
 @noheader()
 class FloatConst extends ShaderConst {
 
+	override function getShaderDef():hrt.shgraph.ShaderGraph.ShaderNodeDef {
+		var pos : Position = {file: "", min: 0, max: 0};
 
-	// @prop() var value : Float = 0.;
+		var output : TVar = {name: "output", id:1, type: TFloat, kind: Local, qualifiers: [SgOutput]};
+		var finalExpr : TExpr = {e: TBinop(OpAssign, {e:TVar(output), p:pos, t:output.type}, {e: TConst(CFloat(value)), p: pos, t: output.type}), p: pos, t: output.type};
+
+		return {expr: finalExpr, inVars: [], outVars:[output], externVars: [output], inits: []};
+	}
+
+	@prop() var value : Float = 0.;
 
 	// public function new(?value : Float) {
 	// 	if (value != null)
@@ -29,34 +37,34 @@ class FloatConst extends ShaderConst {
 	// 	return null;
 	// }
 
-	// #if editor
-	// override public function getPropertiesHTML(width : Float) : Array<hide.Element> {
-	// 	var elements = super.getPropertiesHTML(width);
-	// 	var element = new hide.Element('<div style="width: 75px; height: 30px"></div>');
-	// 	element.append(new hide.Element('<input type="text" id="value" style="width: ${width*0.5}px" value="${value}" />'));
-
-	// 	var input = element.children("input");
-	// 	input.on("keydown", function(e) {
-	// 		e.stopPropagation();
-	// 	});
-	// 	input.on("mousedown", function(e) {
-	// 		e.stopPropagation();
-	// 	});
-	// 	input.on("change", function(e) {
-	// 		var tmpValue = Std.parseFloat(input.val());
-	// 		if (Math.isNaN(tmpValue) ) {
-	// 			input.addClass("error");
-	// 		} else {
-	// 			this.value = tmpValue;
-	// 			input.val(tmpValue);
-	// 			input.removeClass("error");
-	// 		}
-	// 	});
-
-	// 	elements.push(element);
-
-	// 	return elements;
-	// }
-	// #end
+	#if editor
+	override public function getPropertiesHTML(width : Float) : Array<hide.Element> {
+		var elements = super.getPropertiesHTML(width);
+		var element = new hide.Element('<div style="width: 75px; height: 30px"></div>');
+		element.append(new hide.Element('<input type="text" id="value" style="width: ${width*0.5}px" value="${value}" />'));
+
+		var input = element.children("input");
+		input.on("keydown", function(e) {
+			e.stopPropagation();
+		});
+		input.on("mousedown", function(e) {
+			e.stopPropagation();
+		});
+		input.on("change", function(e) {
+			var tmpValue = Std.parseFloat(input.val());
+			if (Math.isNaN(tmpValue) ) {
+				input.addClass("error");
+			} else {
+				this.value = tmpValue;
+				input.val(tmpValue);
+				input.removeClass("error");
+			}
+		});
+
+		elements.push(element);
+
+		return elements;
+	}
+	#end
 
 }

+ 8 - 13
hrt/shgraph/nodes/Floor.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("The nearest integer less than or equal to X")
 @width(80)
 @group("Math")
-class Floor extends ShaderFunction {
+class Floor extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Number;
-
-	// public function new() {
-	// 	super(Floor);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = floor(a);
+		}
+	};
 
 }

+ 8 - 13
hrt/shgraph/nodes/Fract.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("The fractional part of X")
 @width(80)
 @group("Math")
-class Fract extends ShaderFunction {
+class Fract extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Number;
-
-	// public function new() {
-	// 	super(Fract);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = fract(a);
+		}
+	};
 
 }

+ 8 - 13
hrt/shgraph/nodes/Length.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("")
 @width(80)
 @group("Math")
-class Length extends ShaderFunction {
+class Length extends ShaderNodeHxsl {
 
-	// @input("A") var a = SType.Vec2;
-
-	// public function new() {
-	// 	super(Length);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", TFloat);
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Float;
+		function fragment() {
+			output = length(a);
+		}
+	};
 
 }

+ 8 - 13
hrt/shgraph/nodes/Log.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("The output is the result of log(x)")
 @width(80)
 @group("Math")
-class Log extends ShaderFunction {
+class Log extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Number;
-	// @input("P", true) var p = SType.Number;
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = log(a);
+		}
+	};
 
-	// public function new() {
-	// 	super(Log);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
 }

+ 9 - 17
hrt/shgraph/nodes/Max.hx

@@ -6,23 +6,15 @@ using hxsl.Ast;
 @description("The output is the maximum between A and B")
 @width(80)
 @group("Math")
-class Max extends ShaderFunction {
-
-	// @input("A") var a = SType.Number;
-	// @input("B") var b = SType.Number;
-
-	// public function new() {
-	// 	super(Max);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", a.getType());
-	// 	else if (b != null && !b.isEmpty())
-	// 		addOutput("output", b.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+class Max extends ShaderNodeHxsl {
 
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = max(a,b);
+		}
+	};
 
 }

+ 0 - 28
hrt/shgraph/nodes/Maximum.hx

@@ -1,28 +0,0 @@
-package hrt.shgraph.nodes;
-
-using hxsl.Ast;
-
-@name("Maximum")
-@description("The output is the maximum between A and B")
-@width(80)
-@group("Math")
-class Maximum extends ShaderFunction {
-
-	// @input("A") var a = SType.Number;
-	// @input("B") var b = SType.Number;
-
-	// public function new() {
-	// 	super(Max);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", a.getType());
-	// 	else if (b != null && !b.isEmpty())
-	// 		addOutput("output", b.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
-
-
-}

+ 9 - 16
hrt/shgraph/nodes/Min.hx

@@ -6,22 +6,15 @@ using hxsl.Ast;
 @description("The output is the minimum between A and B")
 @width(80)
 @group("Math")
-class Min extends ShaderFunction {
+class Min extends ShaderNodeHxsl {
 
-	// @input("A") var a = SType.Number;
-	// @input("B") var b = SType.Number;
-
-	// public function new() {
-	// 	super(Min);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", a.getType());
-	// 	else if (b != null && !b.isEmpty())
-	// 		addOutput("output", b.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = min(a,b);
+		}
+	};
 
 }

+ 0 - 27
hrt/shgraph/nodes/Minimum.hx

@@ -1,27 +0,0 @@
-package hrt.shgraph.nodes;
-
-using hxsl.Ast;
-
-@name("Minimum")
-@description("The output is the minimum between A and B")
-@width(80)
-@group("Math")
-class Minimum extends ShaderFunction {
-
-	// @input("A") var a = SType.Number;
-	// @input("B") var b = SType.Number;
-
-	// public function new() {
-	// 	super(Min);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", a.getType());
-	// 	else if (b != null && !b.isEmpty())
-	// 		addOutput("output", b.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
-
-}

+ 10 - 19
hrt/shgraph/nodes/Mix.hx

@@ -6,25 +6,16 @@ using hxsl.Ast;
 @description("Linear interpolation between A and B using Mix")
 @width(80)
 @group("Math")
-class Mix extends ShaderFunction {
+class Mix extends ShaderNodeHxsl {
 
-	// @input("A") var x = SType.Number;
-	// @input("B") var y = SType.Number;
-	// @input("Mix") var a = SType.Number;
-
-	// public function new() {
-	// 	super(Mix);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty() && y != null && !y.isEmpty())
-	// 		addOutput("output", x.getVar(y.getType()).t);
-	// 	else if (x != null && !x.isEmpty() )
-	// 		addOutput("output", x.getType());
-	// 	else if (y != null && !y.isEmpty())
-	// 		addOutput("output", y.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sginput var fact : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = mix(a,b, fact);
+		}
+	};
 
 }

+ 9 - 14
hrt/shgraph/nodes/Mod.hx

@@ -6,20 +6,15 @@ using hxsl.Ast;
 @description("The output is the result of X modulo MOD")
 @width(80)
 @group("Math")
-class Mod extends ShaderFunction {
+class Mod extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Variant;
-	// @input("Mod", true) var mod = SType.Float;
-
-	// public function new() {
-	// 	super(Mod);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = mod(a,b);
+		}
+	};
 
 }

+ 1 - 5
hrt/shgraph/nodes/Multiply.hx

@@ -6,11 +6,7 @@ using hxsl.Ast;
 @description("The output is the result of A * B")
 @width(80)
 @group("Operation")
-class Multiply extends Operation {
-
-	// public function new() {
-	// 	super(OpMult);
-	// }
+class Multiply extends ShaderNodeHxsl {
 
 	static var SRC = {
 		@sginput var a : Vec4;

+ 8 - 12
hrt/shgraph/nodes/Normalize.hx

@@ -6,18 +6,14 @@ using hxsl.Ast;
 @description("The output is the result of normalize(x)")
 @width(80)
 @group("Math")
-class Normalize extends ShaderFunction {
+class Normalize extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Number;
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = normalize(a);
+		}
+	};
 
-	// public function new() {
-	// 	super(Normalize);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
 }

+ 9 - 13
hrt/shgraph/nodes/Pow.hx

@@ -6,19 +6,15 @@ using hxsl.Ast;
 @description("The output is the result of x ^ b")
 @width(80)
 @group("Math")
-class Pow extends ShaderFunction {
+class Pow extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Number;
-	// @input("P", true) var p = SType.Number;
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = pow(a,b);
+		}
+	};
 
-	// public function new() {
-	// 	super(Pow);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
 }

+ 8 - 13
hrt/shgraph/nodes/Saturate.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("Saturate input A")
 @width(80)
 @group("Math")
-class Saturate extends ShaderFunction {
+class Saturate extends ShaderNodeHxsl {
 
-	// @input("X") var x = SType.Number;
-
-	// public function new() {
-	// 	super(Saturate);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty())
-	// 		addOutput("output", x.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = saturate(a);
+		}
+	};
 
 }

+ 8 - 13
hrt/shgraph/nodes/Sin.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("The output is the sinus of A")
 @width(80)
 @group("Math")
-class Sin extends ShaderFunction {
+class Sin extends ShaderNodeHxsl {
 
-	// @input("A") var a = SType.Float;
-
-	// public function new() {
-	// 	super(Sin);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", a.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = sin(a);
+		}
+	};
 
 }

+ 10 - 19
hrt/shgraph/nodes/SmoothStep.hx

@@ -6,25 +6,16 @@ using hxsl.Ast;
 @description("Linear interpolation between A and B using Mix")
 @width(100)
 @group("Math")
-class SmoothStep extends ShaderFunction {
+class SmoothStep extends ShaderNodeHxsl {
 
-	// @input("A") var x = SType.Number;
-	// @input("B") var y = SType.Number;
-	// @input("Mix") var a = SType.Number;
-
-	// public function new() {
-	// 	super(Smoothstep);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty() && y != null && !y.isEmpty())
-	// 		addOutput("output", x.getVar(y.getType()).t);
-	// 	else if (x != null && !x.isEmpty() )
-	// 		addOutput("output", x.getType());
-	// 	else if (y != null && !y.isEmpty())
-	// 		addOutput("output", y.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sginput var fact : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = smoothstep(a,b, fact);
+		}
+	};
 
 }

+ 15 - 26
hrt/shgraph/nodes/Split.hx

@@ -5,31 +5,20 @@ using hxsl.Ast;
 @name("Split")
 @description("Split all components of a vector into floats")
 @group("Channel")
-class Split extends ShaderNode {
-
-	// @input("RGBA") var input = SType.Vec4;
-
-
-	// var components = [X, Y, Z, W];
-	// var componentsString = ["r", "g", "b", "a"];
-
-	// override public function computeOutputs() {
-	// 	addOutput("r", TFloat);
-	// 	addOutput("g", TFloat);
-	// 	addOutput("b", TFloat);
-	// 	addOutput("a", TFloat);
-	// }
-
-	// override public function build(key : String) : TExpr {
-	// 	var compIdx = componentsString.indexOf(key);
-	// 	return { e: TBinop(OpAssign, {
-	// 				e: TVar(getOutput(key)),
-	// 				p: null,
-	// 				t: getOutput(key).type
-	// 			}, {e: TSwiz(input.getVar(TVec(4, VFloat)), [components[compIdx]]), p: null, t: getOutput(key).type }),
-	// 			p: null,
-	// 			t: getOutput(key).type
-	// 		};
-	// }
+class Split extends ShaderNodeHxsl {
+
+	static var SRC = {
+		@sginput var rgba : Vec4;
+		@sgoutput var r : Float;
+		@sgoutput var g : Float;
+		@sgoutput var b : Float;
+		@sgoutput var a : Float;
+		function fragment() {
+			r = rgba.r;
+			g = rgba.g;
+			b = rgba.b;
+			a = rgba.a;
+		}
+	};
 
 }

+ 8 - 13
hrt/shgraph/nodes/Sqrt.hx

@@ -7,19 +7,14 @@ using hxsl.Ast;
 @width(80)
 @group("Math")
 @:keep
-class Sqrt extends ShaderFunction {
+class Sqrt extends ShaderNodeHxsl {
 
-	// @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");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = sqrt(a);
+		}
+	};
 
 }

+ 9 - 18
hrt/shgraph/nodes/Step.hx

@@ -6,24 +6,15 @@ using hxsl.Ast;
 @description("Generate a step function by comparing a[i] to edge[i]")
 @width(80)
 @group("Math")
-class Step extends ShaderFunction {
+class Step extends ShaderNodeHxsl {
 
-	// @input("Edge") var edge = SType.Number;
-	// @input("A") var x = SType.Number;
-
-	// public function new() {
-	// 	super(Step);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (x != null && !x.isEmpty() && edge != null && !edge.isEmpty())
-	// 		addOutput("output", edge.getVar(x.getType()).t);
-	// 	else if (x != null && !x.isEmpty() )
-	// 		addOutput("output", x.getType());
-	// 	else if (edge != null && !edge.isEmpty())
-	// 		addOutput("output", edge.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var edge : Vec4;
+		@sginput var fact : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = step(edge, fact);
+		}
+	};
 
 }

+ 12 - 39
hrt/shgraph/nodes/StripAlpha.hx

@@ -5,44 +5,17 @@ using hxsl.Ast;
 @name("Strip Alpha")
 @description("Separate the rgb and a components of an rgba vector")
 @group("Channel")
-class StripAlpha extends ShaderNode {
-
-	// @input("RGBA") var input = SType.Vec4;
-
-
-
-	// override public function computeOutputs() {
-	// 	addOutput("rgb", TVec(3, VFloat));
-	// 	addOutput("a", TFloat);
-	// }
-
-	// override public function build(key : String) : TExpr {
-    //     if( key == "a" ) {
-    //         return { e: TBinop(OpAssign, {
-    //                 e: TVar(getOutput(key)),
-    //                 p: null,
-    //                 t: getOutput(key).type
-    //             }, {
-    //                 e: TSwiz(input.getVar(TVec(4, VFloat)), [W]),
-    //                 p: null,
-    //                 t: getOutput(key).type
-    //             }),
-    //             p: null,
-    //             t: getOutput(key).type
-    //         };
-	//     }
-    //     return { e: TBinop(OpAssign, {
-    //             e: TVar(getOutput(key)),
-    //             p: null,
-    //             t: getOutput(key).type
-    //         }, {
-    //             e: TSwiz(input.getVar(TVec(4, VFloat)), [X, Y, Z]),
-    //             p: null,
-    //             t: getOutput(key).type
-    //         }),
-    //         p: null,
-    //         t: getOutput(key).type
-    //     };
-    // }
+class StripAlpha extends ShaderNodeHxsl {
+
+	static var SRC = {
+		@sginput var rgba : Vec4;
+		@sgoutput var rgb : Vec3;
+		@sgoutput var a : Float;
+
+		function fragment() {
+			rgb = rgba.rgb;
+			a = rgba.a;
+		}
+	};
 
 }

+ 118 - 118
hrt/shgraph/nodes/SubGraph.hx

@@ -39,95 +39,95 @@ class SubGraph extends ShaderNode {
 
 	public var varsSubGraph : Array<TVar> = [];
 
-	public function loadGraphShader() {
-		if (this.pathShaderGraph != null) {
-			subShaderGraph = new ShaderGraph(pathShaderGraph);
-			inputsInfo = new Map<String, ShaderNode.InputInfo>();
-			inputInfoKeys = [];
-			var paramInfoKeys = [];
-			outputsInfo = new Map<String, ShaderNode.OutputInfo>();
-			outputInfoKeys = [];
-			parameters = [];
-			propertiesSubGraph = new Map<Int, Dynamic>();
-			var prefixSubGraph = "shgraph_" + id + "_";
-
-			for (node in subShaderGraph.getNodes()) {
-				switch (node.type.split(".").pop()) {
-					case "ShaderParam": // params become inputs
-						var shaderParam = Std.downcast(node.instance, ShaderParam);
-						var paramName = subShaderGraph.getParameter(shaderParam.parameterId).name;
-						var paramId = "param_" + shaderParam.parameterId;
-						var paramInfo = inputsInfo.get(prefixSubGraph+paramId);
-						var ids = [];
-						if (paramInfo != null && paramInfo.ids != null)
-							ids = paramInfo.ids;
-						ids.push(node.id);
-						if (!inputsInfo.exists(prefixSubGraph + paramId)) {
-							paramInfoKeys.push(prefixSubGraph+paramId);
-						}
-						inputsInfo.set(prefixSubGraph+paramId, { name : paramName , type: ShaderType.getSType(shaderParam.variable.type), hasProperty: false, isRequired : false, ids : ids, index :  subShaderGraph.getParameter(shaderParam.parameterId).index});
-					case "ShaderInput":
-						var shaderInput = Std.downcast(node.instance, ShaderInput);
-						var inputId = "input_" + shaderInput.variable.name;
-						var inputInfo = inputsInfo.get(prefixSubGraph+inputId);
-						var ids = [];
-						if (inputInfo != null && inputInfo.ids != null)
-							ids = inputInfo.ids;
-						ids.push(node.id);
-						if (!inputsInfo.exists(prefixSubGraph+inputId)) {
-							inputInfoKeys.push(prefixSubGraph+inputId);
-						}
-						inputsInfo.set(prefixSubGraph+inputId, { name : "*" + shaderInput.variable.name , type: ShaderType.getSType(shaderInput.variable.type), hasProperty: false, isRequired : false, ids : ids });
-					case "ShaderGlobalInput":
-						var shaderInput = Std.downcast(node.instance, ShaderGlobalInput);
-						var inputId = "globalInput_" + shaderInput.variable.name;
-						var inputInfo = inputsInfo.get(prefixSubGraph+inputId);
-						var ids = [];
-						if (inputInfo != null && inputInfo.ids != null)
-							ids = inputInfo.ids;
-						ids.push(node.id);
-						if (!inputsInfo.exists(prefixSubGraph+inputId)) {
-							inputInfoKeys.push(prefixSubGraph+inputId);
-						}
-						inputsInfo.set(prefixSubGraph+inputId, { name : "*" + shaderInput.variable.name , type: ShaderType.getSType(shaderInput.variable.type), hasProperty: false, isRequired : false, ids : ids });
-					case "ShaderCameraInput":
-						var shaderInput = Std.downcast(node.instance, ShaderCameraInput);
-						var inputId = "cameraInput_" + shaderInput.variable.name;
-						var inputInfo = inputsInfo.get(prefixSubGraph+inputId);
-						var ids = [];
-						if (inputInfo != null && inputInfo.ids != null)
-							ids = inputInfo.ids;
-						ids.push(node.id);
-						if (!inputsInfo.exists(prefixSubGraph+inputId)) {
-							inputInfoKeys.push(prefixSubGraph+inputId);
-						}
-						inputsInfo.set(prefixSubGraph+inputId, { name : "*" + shaderInput.variable.name , type: ShaderType.getSType(shaderInput.variable.type), hasProperty: false, isRequired : false, ids : ids });
-					case "ShaderOutput":
-						var shaderOutput = Std.downcast(node.instance, ShaderOutput);
-						var prefix = shaderOutput.variable.kind == Local ? "" : "*";
-
-						outputsInfo.set(prefixSubGraph+node.id, { name : prefix + shaderOutput.variable.name , type: ShaderType.getSType(shaderOutput.variable.type), id : node.id });
-						outputInfoKeys.push(prefixSubGraph+node.id);
-
-						addOutput(prefixSubGraph+node.id, shaderOutput.variable.type);
-					default:
-						var shaderConst = Std.downcast(node.instance, ShaderConst);
-						if (shaderConst != null) { // input static become properties
-							if (shaderConst.name.length == 0) continue;
-							if (Std.isOfType(shaderConst, BoolConst)) {
-								parameters.push({ name : shaderConst.name, type : TBool, defaultValue : null, id : shaderConst.id, index : parameters.length });
-							} else if (Std.isOfType(shaderConst, FloatConst)) {
-								parameters.push({ name : shaderConst.name, type : TFloat, defaultValue : null, id : shaderConst.id, index : parameters.length });
-							} else if (Std.isOfType(shaderConst, Color)) {
-								parameters.push({ name : shaderConst.name, type : TVec(4, VFloat), defaultValue : null, id : shaderConst.id, index : parameters.length });
-							}
-						}
-				}
-			}
-			paramInfoKeys.sort((x,y) -> Reflect.compare(inputsInfo[x].index, inputsInfo[y].index));
-			inputInfoKeys = paramInfoKeys.concat(inputInfoKeys);
-		}
-	}
+	// public function loadGraphShader() {
+	// 	if (this.pathShaderGraph != null) {
+	// 		subShaderGraph = new ShaderGraph(pathShaderGraph);
+	// 		inputsInfo = new Map<String, ShaderNode.InputInfo>();
+	// 		inputInfoKeys = [];
+	// 		var paramInfoKeys = [];
+	// 		outputsInfo = new Map<String, ShaderNode.OutputInfo>();
+	// 		outputInfoKeys = [];
+	// 		parameters = [];
+	// 		propertiesSubGraph = new Map<Int, Dynamic>();
+	// 		var prefixSubGraph = "shgraph_" + id + "_";
+
+	// 		for (node in subShaderGraph.getNodes()) {
+	// 			switch (node.type.split(".").pop()) {
+	// 				case "ShaderParam": // params become inputs
+	// 					var shaderParam = Std.downcast(node.instance, ShaderParam);
+	// 					var paramName = subShaderGraph.getParameter(shaderParam.parameterId).name;
+	// 					var paramId = "param_" + shaderParam.parameterId;
+	// 					var paramInfo = inputsInfo.get(prefixSubGraph+paramId);
+	// 					var ids = [];
+	// 					if (paramInfo != null && paramInfo.ids != null)
+	// 						ids = paramInfo.ids;
+	// 					ids.push(node.id);
+	// 					if (!inputsInfo.exists(prefixSubGraph + paramId)) {
+	// 						paramInfoKeys.push(prefixSubGraph+paramId);
+	// 					}
+	// 					inputsInfo.set(prefixSubGraph+paramId, { name : paramName , type: ShaderType.getSType(shaderParam.variable.type), hasProperty: false, isRequired : false, ids : ids, index :  subShaderGraph.getParameter(shaderParam.parameterId).index});
+	// 				case "ShaderInput":
+	// 					var shaderInput = Std.downcast(node.instance, ShaderInput);
+	// 					var inputId = "input_" + shaderInput.variable.name;
+	// 					var inputInfo = inputsInfo.get(prefixSubGraph+inputId);
+	// 					var ids = [];
+	// 					if (inputInfo != null && inputInfo.ids != null)
+	// 						ids = inputInfo.ids;
+	// 					ids.push(node.id);
+	// 					if (!inputsInfo.exists(prefixSubGraph+inputId)) {
+	// 						inputInfoKeys.push(prefixSubGraph+inputId);
+	// 					}
+	// 					inputsInfo.set(prefixSubGraph+inputId, { name : "*" + shaderInput.variable.name , type: ShaderType.getSType(shaderInput.variable.type), hasProperty: false, isRequired : false, ids : ids });
+	// 				case "ShaderGlobalInput":
+	// 					var shaderInput = Std.downcast(node.instance, ShaderGlobalInput);
+	// 					var inputId = "globalInput_" + shaderInput.variable.name;
+	// 					var inputInfo = inputsInfo.get(prefixSubGraph+inputId);
+	// 					var ids = [];
+	// 					if (inputInfo != null && inputInfo.ids != null)
+	// 						ids = inputInfo.ids;
+	// 					ids.push(node.id);
+	// 					if (!inputsInfo.exists(prefixSubGraph+inputId)) {
+	// 						inputInfoKeys.push(prefixSubGraph+inputId);
+	// 					}
+	// 					inputsInfo.set(prefixSubGraph+inputId, { name : "*" + shaderInput.variable.name , type: ShaderType.getSType(shaderInput.variable.type), hasProperty: false, isRequired : false, ids : ids });
+	// 				case "ShaderCameraInput":
+	// 					var shaderInput = Std.downcast(node.instance, ShaderCameraInput);
+	// 					var inputId = "cameraInput_" + shaderInput.variable.name;
+	// 					var inputInfo = inputsInfo.get(prefixSubGraph+inputId);
+	// 					var ids = [];
+	// 					if (inputInfo != null && inputInfo.ids != null)
+	// 						ids = inputInfo.ids;
+	// 					ids.push(node.id);
+	// 					if (!inputsInfo.exists(prefixSubGraph+inputId)) {
+	// 						inputInfoKeys.push(prefixSubGraph+inputId);
+	// 					}
+	// 					inputsInfo.set(prefixSubGraph+inputId, { name : "*" + shaderInput.variable.name , type: ShaderType.getSType(shaderInput.variable.type), hasProperty: false, isRequired : false, ids : ids });
+	// 				case "ShaderOutput":
+	// 					var shaderOutput = Std.downcast(node.instance, ShaderOutput);
+	// 					var prefix = shaderOutput.variable.kind == Local ? "" : "*";
+
+	// 					outputsInfo.set(prefixSubGraph+node.id, { name : prefix + shaderOutput.variable.name , type: ShaderType.getSType(shaderOutput.variable.type), id : node.id });
+	// 					outputInfoKeys.push(prefixSubGraph+node.id);
+
+	// 					addOutput(prefixSubGraph+node.id, shaderOutput.variable.type);
+	// 				default:
+	// 					var shaderConst = Std.downcast(node.instance, ShaderConst);
+	// 					if (shaderConst != null) { // input static become properties
+	// 						if (shaderConst.name.length == 0) continue;
+	// 						if (Std.isOfType(shaderConst, BoolConst)) {
+	// 							parameters.push({ name : shaderConst.name, type : TBool, defaultValue : null, id : shaderConst.id, index : parameters.length });
+	// 						} else if (Std.isOfType(shaderConst, FloatConst)) {
+	// 							parameters.push({ name : shaderConst.name, type : TFloat, defaultValue : null, id : shaderConst.id, index : parameters.length });
+	// 						} else if (Std.isOfType(shaderConst, Color)) {
+	// 							parameters.push({ name : shaderConst.name, type : TVec(4, VFloat), defaultValue : null, id : shaderConst.id, index : parameters.length });
+	// 						}
+	// 					}
+	// 			}
+	// 		}
+	// 		paramInfoKeys.sort((x,y) -> Reflect.compare(inputsInfo[x].index, inputsInfo[y].index));
+	// 		inputInfoKeys = paramInfoKeys.concat(inputInfoKeys);
+	// 	}
+	// }
 
 	// override public function getOutputInfo(key : String) : ShaderNode.OutputInfo {
 	// 	return outputsInfo.get(key);
@@ -137,39 +137,39 @@ class SubGraph extends ShaderNode {
 	// 	return outputInfoKeys;
 	// }
 
-	override public function loadProperties(props : Dynamic) {
-		this.pathShaderGraph = Reflect.field(props, "pathShaderGraph");
-		loadGraphShader();
-
-		var parametersValues : Array<hrt.shgraph.ShaderGraph.Parameter> = Reflect.field(props, "parametersValues");
-		if (parametersValues == null) return;
-		var index = 0;
-		for (p in this.parameters) {
-			if (parametersValues.length <= index) break;
-			if (p.id != parametersValues[index].id) {
-				continue;
-			}
-			p.defaultValue = parametersValues[index].defaultValue;
-			index++;
-		}
-	}
+	// override public function loadProperties(props : Dynamic) {
+	// 	this.pathShaderGraph = Reflect.field(props, "pathShaderGraph");
+	// 	loadGraphShader();
+
+	// 	var parametersValues : Array<hrt.shgraph.ShaderGraph.Parameter> = Reflect.field(props, "parametersValues");
+	// 	if (parametersValues == null) return;
+	// 	var index = 0;
+	// 	for (p in this.parameters) {
+	// 		if (parametersValues.length <= index) break;
+	// 		if (p.id != parametersValues[index].id) {
+	// 			continue;
+	// 		}
+	// 		p.defaultValue = parametersValues[index].defaultValue;
+	// 		index++;
+	// 	}
+	// }
 
-	override public function saveProperties() : Dynamic {
+	// override public function saveProperties() : Dynamic {
 
-		var parametersValues = [];
-		for (p in this.parameters) {
-			if (p.defaultValue != null) {
-				parametersValues.push({id: p.id, defaultValue : p.defaultValue});
-			}
-		}
+	// 	var parametersValues = [];
+	// 	for (p in this.parameters) {
+	// 		if (p.defaultValue != null) {
+	// 			parametersValues.push({id: p.id, defaultValue : p.defaultValue});
+	// 		}
+	// 	}
 
-		var properties = {
-			pathShaderGraph: this.pathShaderGraph,
-			parametersValues : parametersValues
-		};
+	// 	var properties = {
+	// 		pathShaderGraph: this.pathShaderGraph,
+	// 		parametersValues : parametersValues
+	// 	};
 
-		return properties;
-	}
+	// 	return properties;
+	// }
 
 	#if editor
 	override public function getPropertiesHTML(width : Float) : Array<hide.Element> {

+ 9 - 5
hrt/shgraph/nodes/Subtract.hx

@@ -6,10 +6,14 @@ using hxsl.Ast;
 @description("The output is the result of A - B")
 @width(80)
 @group("Operation")
-class Subtract extends Operation {
-
-	// public function new() {
-	// 	super(OpSub);
-	// }
+class Subtract extends ShaderNodeHxsl {
 
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sginput var b : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = a - b;
+		}
+	}
 }

+ 8 - 13
hrt/shgraph/nodes/Tan.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("The output is the tangent of A")
 @width(80)
 @group("Math")
-class Tan extends ShaderFunction {
+class Tan extends  ShaderNodeHxsl {
 
-	// @input("A") var a = SType.Float;
-
-	// public function new() {
-	// 	super(Tan);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (a != null && !a.isEmpty())
-	// 		addOutput("output", a.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec4;
+		function fragment() {
+			output = tan(a);
+		}
+	};
 
 }

+ 25 - 25
hrt/shgraph/nodes/Text.hx

@@ -10,30 +10,30 @@ using hxsl.Ast;
 @noheader()
 class Text extends ShaderNode {
 
-	// @prop() var text : String = "";
-
-	// override public function build(key : String) : TExpr {
-	// 	return null;
-	// }
-
-	// #if editor
-	// override public function getPropertiesHTML(width : Float) : Array<hide.Element> {
-	// 	var elements = super.getPropertiesHTML(width);
-	// 	var element = new hide.Element('<div style="width: ${width-35}px; height: 35px"></div>');
-	// 	element.append(new hide.Element('<input type="text" id="value" style="width: ${width-35}px; height: 22px; font-size: 16px;" placeholder="Name" value="${this.text}" />'));
-
-	// 	var input = element.children("input");
-	// 	input.on("keydown", function(e) {
-	// 		e.stopPropagation();
-	// 	});
-	// 	input.on("change", function(e) {
-	// 		this.text = input.val();
-	// 	});
-
-	// 	elements.push(element);
-
-	// 	return elements;
-	// }
-	// #end
+	@prop() var text : String = "";
+
+	override function getShaderDef():hrt.shgraph.ShaderGraph.ShaderNodeDef {
+		return {expr: null, inVars: [], outVars: [], inits: [], externVars: []};
+	}
+
+	#if editor
+	override public function getPropertiesHTML(width : Float) : Array<hide.Element> {
+		var elements = super.getPropertiesHTML(width);
+		var element = new hide.Element('<div style="width: ${width-35}px; height: 35px"></div>');
+		element.append(new hide.Element('<input type="text" id="value" style="width: ${width-35}px; height: 22px; font-size: 16px;" placeholder="Name" value="${this.text}" />'));
+
+		var input = element.children("input");
+		input.on("keydown", function(e) {
+			e.stopPropagation();
+		});
+		input.on("change", function(e) {
+			this.text = input.val();
+		});
+
+		elements.push(element);
+
+		return elements;
+	}
+	#end
 
 }

+ 16 - 3
hrt/shgraph/nodes/UVScroll.hx

@@ -5,7 +5,22 @@ using hxsl.Ast;
 @name("UV Scroll")
 @description("Scroll UV according to U & V speed")
 @group("Specials")
-class UVScroll extends ShaderNode {
+class UVScroll extends  ShaderNodeHxsl {
+
+	static var SRC = {
+		@sginput var uv : Vec2;
+		@sginput var uSpeed : Float;
+		@sginput var vSpeed : Float;
+		@sginput var time : Float;
+
+		@sgoutput var output : Vec2;
+
+		function fragment() {
+			output = mod(uv + vec2(uSpeed * time, vSpeed * time), 1.0);
+		}
+	};
+
+}
 
 	// @input("UV") var uv = SType.Vec2;
 	// @input("USpeed", true) var uSpeed = SType.Number;
@@ -104,5 +119,3 @@ class UVScroll extends ShaderNode {
 	// 				t: output.type
 	// 			};
 	// }
-
-}

+ 8 - 13
hrt/shgraph/nodes/UnpackNormal.hx

@@ -6,19 +6,14 @@ using hxsl.Ast;
 @description("")
 @width(120)
 @group("Channel")
-class UnpackNormal extends ShaderFunction {
+class UnpackNormal extends  ShaderNodeHxsl {
 
-	// @input("normal") var normal = SType.Vec4;
-
-	// public function new() {
-	// 	super(UnpackNormal);
-	// }
-
-	// override public function computeOutputs() {
-	// 	if (normal != null && !normal.isEmpty())
-	// 		addOutput("output", TVec(3, VFloat));
-	// 	else
-	// 		removeOutput("output");
-	// }
+	static var SRC = {
+		@sginput var a : Vec4;
+		@sgoutput var output : Vec3;
+		function fragment() {
+			output = unpackNormal(a);
+		}
+	};
 
 }

+ 8 - 11
hrt/shgraph/nodes/UvToScreen.hx

@@ -6,19 +6,16 @@ using hxsl.Ast;
 @description("")
 @width(100)
 @group("Math")
-class UvToScreen extends ShaderFunction {
+class UvToScreen extends ShaderNodeHxsl {
 
-	// @input("UV") var uv = SType.Vec2;
+	static var SRC = {
+		@sginput var uv : Vec2;
 
-	// public function new() {
-	// 	super(UvToScreen);
-	// }
+		@sgoutput var output : Vec2;
 
-	// override public function computeOutputs() {
-	// 	if (uv != null && !uv.isEmpty())
-	// 		addOutput("output", uv.getType());
-	// 	else
-	// 		removeOutput("output");
-	// }
+		function fragment() {
+			output = uvToScreen(uv);
+		}
+	};
 
 }