Merge pull request #1807 from MathemanFlo/ReplaceColorNode
Implement replace node
This commit is contained in:
@@ -2484,6 +2484,75 @@ let nodes_material_color: ui_node_t[] = [
|
||||
buttons: [],
|
||||
width: 0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
name: _tr("Replace Color"),
|
||||
type: "REPLACECOL",
|
||||
x: 0,
|
||||
y: 0,
|
||||
color: 0xff448c6d,
|
||||
inputs: [
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: _tr("Color"),
|
||||
type: "RGBA",
|
||||
color: 0xffc7c729,
|
||||
default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0)
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: _tr("Old Color"),
|
||||
type: "RGBA",
|
||||
color: 0xffc7c729,
|
||||
default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0)
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: _tr("New Color"),
|
||||
type: "RGBA",
|
||||
color: 0xffc7c729,
|
||||
default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0)
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: _tr("Radius"),
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: f32_array_create_x(0.1),
|
||||
min: 0.0,
|
||||
max: 1.74,
|
||||
precision: 100,
|
||||
display: 0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: _tr("Fuzziness"),
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: f32_array_create_x(0.0),
|
||||
min: 0.0,
|
||||
max: 1.0,
|
||||
precision: 100,
|
||||
display: 0
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: _tr("Color"),
|
||||
type: "RGBA",
|
||||
color: 0xffc7c729,
|
||||
default_value: f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0)
|
||||
}
|
||||
],
|
||||
buttons: []
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
name: _tr("Warp"),
|
||||
|
||||
@@ -734,6 +734,14 @@ function parser_material_parse_vector(node: ui_node_t, socket: ui_node_socket_t)
|
||||
let col: string = parser_material_parse_vector_input(node.inputs[1]);
|
||||
return "(floor(100.0 * " + strength + " * " + col + ") / (100.0 * " + strength + "))";
|
||||
}
|
||||
else if (node.type == "REPLACECOL") {
|
||||
let inputColor: string = parser_material_parse_vector_input(node.inputs[0]);
|
||||
let oldColor: string = parser_material_parse_vector_input(node.inputs[1]);
|
||||
let newColor: string = parser_material_parse_vector_input(node.inputs[2]);
|
||||
let radius: string = parser_material_parse_value_input(node.inputs[3]);
|
||||
let fuzziness: string = parser_material_parse_value_input(node.inputs[4]);
|
||||
return "mix(" + newColor + ", " + inputColor + ", clamp((distance(" + oldColor + ", " + inputColor + ") - " + radius + ") / max(" + fuzziness + ", " + parser_material_eps + "), 0.0, 1.0))";
|
||||
}
|
||||
else if (node.type == "VALTORGB") { // ColorRamp
|
||||
let fac: string = parser_material_parse_value_input(node.inputs[0]);
|
||||
let data0: i32 = node.buttons[0].data[0];
|
||||
|
||||
Reference in New Issue
Block a user