Forráskód Böngészése

Adding ObjectPos.hx and ObjectScale.hx shader graph nodes.

clementlandrin 8 hónapja
szülő
commit
086d428123
2 módosított fájl, 45 hozzáadás és 0 törlés
  1. 19 0
      hrt/shgraph/nodes/ObjectPos.hx
  2. 26 0
      hrt/shgraph/nodes/ObjectScale.hx

+ 19 - 0
hrt/shgraph/nodes/ObjectPos.hx

@@ -0,0 +1,19 @@
+package hrt.shgraph.nodes;
+
+using hxsl.Ast;
+
+@name("ObjectPos")
+@description("Returns the position of the object (in world space)")
+@group("Property")
+class ObjectPos extends ShaderNodeHxsl {
+
+	static var SRC = {
+		@sgoutput var output : Vec3;
+
+		@global var global : { @perObject var modelView : Mat4; };
+
+		function fragment() {
+			output = vec3(0.0) * global.modelView.mat3x4();
+		}
+	};
+}

+ 26 - 0
hrt/shgraph/nodes/ObjectScale.hx

@@ -0,0 +1,26 @@
+package hrt.shgraph.nodes;
+
+using hxsl.Ast;
+
+@name("ObjectScale")
+@description("Returns the scale of the object")
+@group("Property")
+class ObjectScale extends ShaderNodeHxsl {
+
+	static var SRC = {
+		@sgoutput var output : Vec3;
+
+		@global var global : { @perObject var modelView : Mat4; };
+
+		function fragment() {
+			var objPos = vec3(0.0) * global.modelView.mat3x4();
+			var xPos = vec3(1.0, 0.0, 0.0) * global.modelView.mat3x4();
+			var x = length(xPos - objPos);
+			var yPos = vec3(0.0, 1.0, 0.0) * global.modelView.mat3x4();
+			var y = length(yPos - objPos);
+			var zPos = vec3(0.0, 0.0, 1.0) * global.modelView.mat3x4();
+			var z = length(zPos - objPos);
+			output = vec3(x, y, z);
+		}
+	};
+}