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