2
0
Эх сурвалжийг харах

Merge pull request #9 from MathemanFlo/quantize_node

Add Quantize node
Lubos Lenco 4 жил өмнө
parent
commit
4539b2e98b

+ 5 - 0
Sources/arm/shader/MaterialParser.hx

@@ -676,6 +676,11 @@ class MaterialParser {
 			if (use_clamp) return 'clamp($out_col, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0))';
 			else return out_col;
 		}
+		else if (node.type == "QUANTIZE") {
+			var amount = parse_value_input(node.inputs[0]);
+			var col = parse_vector_input(node.inputs[1]);
+			return '(floor(100*$amount*$col)/(100*$amount))';
+		}
 		else if (node.type == "VALTORGB") { // ColorRamp
 			var fac = parse_value_input(node.inputs[0]);
 			var interp = node.buttons[0].data == 0 ? "LINEAR" : "CONSTANT";

+ 39 - 0
Sources/arm/shader/NodesMaterial.hx

@@ -1822,6 +1822,45 @@ class NodesMaterial {
 						output: 0
 					}
 				]
+			},
+			{
+				id: 0,
+				name: _tr("Quantize"),
+				type: "QUANTIZE",
+				x: 0,
+				y: 0,
+				color: 0xff448c6d,
+				inputs: [
+					{
+						id: 0,
+						node_id: 0,
+						name: _tr("Amount"),
+						type: "VALUE",
+						color: 0xffa1a1a1,
+						default_value: 0.1,
+						min: 0,
+						max: 1
+					},
+					{
+						id: 0,
+						node_id: 0,
+						name: _tr("Color"),
+						type: "RGBA",
+						color: 0xffc7c729,
+						default_value: f32([0.0, 0.0, 0.0, 1.0])
+					}
+				],
+				outputs: [
+					{
+						id: 0,
+						node_id: 0,
+						name: _tr("Color"),
+						type: "RGBA",
+						color: 0xffc7c729,
+						default_value: f32([0.8, 0.8, 0.8, 1.0])
+					}
+				],
+				buttons: []
 			}
 		],
 		[ // Vector