Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish nodes #1545

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions base/Sources/arm/shader/MaterialParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,14 @@ class MaterialParser {
var col = parse_vector_input(node.inputs[1]);
return '(floor(100.0 * $strength * $col) / (100.0 * $strength))';
}
else if (node.type == "REPLACECOL") {
var inputColor = parse_vector_input(node.inputs[0]);
var oldColor = parse_vector_input(node.inputs[1]);
var newColor = parse_vector_input(node.inputs[2]);
var radius = parse_value_input(node.inputs[3]);
var fuzziness = parse_value_input(node.inputs[4]);
return 'mix($newColor, $inputColor, clamp((distance($oldColor, $inputColor) - $radius) / max($fuzziness, $eps), 0.0, 1.0))';
}
else if (node.type == "VALTORGB") { // ColorRamp
var fac = parse_value_input(node.inputs[0]);
var interp = node.buttons[0].data == 0 ? "LINEAR" : "CONSTANT";
Expand Down
81 changes: 81 additions & 0 deletions base/Sources/arm/shader/NodesMaterial.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,7 @@ class NodesMaterial {
},
{
name: _tr("use_clamp"),
tooltip: _tr("Clamps the output value to the interval [0,1]."),
type: "BOOL",
default_value: false,
output: 0
Expand All @@ -1767,6 +1768,7 @@ class NodesMaterial {
{
id: 0,
name: _tr("Quantize"),
tooltip: _tr("Creates a posterization effect."),
type: "QUANTIZE",
x: 0,
y: 0,
Expand Down Expand Up @@ -1803,6 +1805,73 @@ class NodesMaterial {
],
buttons: []
},
{
id: 0,
name: _tr("Replace Color"),
type: "REPLACECOL",
x: 0,
y: 0,
color: 0xff62676d,
inputs: [
{
id: 0,
node_id: 0,
name: _tr("Color"),
type: "RGBA",
color: 0xffc7c729,
default_value: f32([0.8, 0.8, 0.8, 1.0])
},
{
id: 0,
node_id: 0,
name: _tr("Old Color"),
tooltip: _tr("Color to replace."),
type: "RGBA",
color: 0xffc7c729,
default_value: f32([0.8, 0.8, 0.8, 1.0])
},
{
id: 0,
node_id: 0,
name: _tr("New Color"),
tooltip: _tr("The replacement color."),
type: "RGBA",
color: 0xffc7c729,
default_value: f32([0.8, 0.8, 0.8, 1.0])
},
{
id: 0,
node_id: 0,
name: _tr("Radius"),
tooltip: _tr("Replace colors within this range."),
type: "VALUE",
color: 0xffa1a1a1,
default_value: 0.1,
min: 0.0,
max: 1.74
},
{
id: 0,
node_id: 0,
name: _tr("Fuzziness"),
tooltip: _tr("Soften edges around replaced regions."),
type: "VALUE",
color: 0xffa1a1a1,
default_value: 0.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: []
},
{
id: 0,
name: _tr("Warp"),
Expand Down Expand Up @@ -1857,6 +1926,7 @@ class NodesMaterial {
{
id: 0,
name: _tr("Bump"),
tooltip: _tr("Generates a normal map from a height texture."),
type: "BUMP",
x: 0,
y: 0,
Expand All @@ -1874,6 +1944,7 @@ class NodesMaterial {
id: 0,
node_id: 0,
name: _tr("Distance"),
tooltip: _tr("Currently not implemented."),
type: "VALUE",
color: 0xffa1a1a1,
default_value: 0.0
Expand All @@ -1882,6 +1953,7 @@ class NodesMaterial {
id: 0,
node_id: 0,
name: _tr("Height"),
tooltip: _tr("Scalar value-typically a height map texture-giving the height offset from the surface."),
type: "VALUE",
color: 0xffa1a1a1,
default_value: 1.0
Expand Down Expand Up @@ -1910,6 +1982,7 @@ class NodesMaterial {
{
id: 0,
name: _tr("Mapping"),
tooltip: _tr("Transforms the input vector by applying translation, rotation, and scaling."),
type: "MAPPING",
x: 0,
y: 0,
Expand Down Expand Up @@ -2002,6 +2075,7 @@ class NodesMaterial {
buttons: [
{
name: _tr("blend_type"),
tooltip: _tr("Blending method"),
type: "ENUM",
data: [_tr("Partial Derivative"), _tr("Whiteout"), _tr("Reoriented")],
default_value: 0,
Expand Down Expand Up @@ -2142,6 +2216,7 @@ class NodesMaterial {
{
id: 0,
name: _tr("Clamp"),
tooltip: _tr("Clamps a value between a minimum and a maximum."),
type: "CLAMP",
x: 0,
y: 0,
Expand Down Expand Up @@ -2241,6 +2316,7 @@ class NodesMaterial {
{
id: 0,
name: _tr("Color Mask"),
tooltip: _tr("Generates a mask from color values-typically a texture-equal to mask color."),
type: "COLMASK",
x: 0,
y: 0,
Expand All @@ -2258,6 +2334,7 @@ class NodesMaterial {
id: 0,
node_id: 0,
name: _tr("Mask Color"),
tooltip: _tr("Color to use for mask."),
type: "RGBA",
color: 0xffc7c729,
default_value: f32([0.8, 0.8, 0.8, 1.0])
Expand All @@ -2266,6 +2343,7 @@ class NodesMaterial {
id: 0,
node_id: 0,
name: _tr("Radius"),
tooltip: _tr("Select colors within this range from input Mask Color."),
type: "VALUE",
color: 0xffa1a1a1,
default_value: 0.1,
Expand All @@ -2276,6 +2354,7 @@ class NodesMaterial {
id: 0,
node_id: 0,
name: _tr("Fuzziness"),
tooltip: _tr("Feather edges around selection. Higher values result in a softer mask."),
type: "VALUE",
color: 0xffa1a1a1,
default_value: 0.0
Expand Down Expand Up @@ -2490,6 +2569,7 @@ class NodesMaterial {
buttons: [
{
name: _tr("use_clamp"),
tooltip: _tr("Clamps the output value to the interval [0,1]."),
type: "BOOL",
default_value: false,
output: 0
Expand Down Expand Up @@ -2541,6 +2621,7 @@ class NodesMaterial {
},
{
name: _tr("use_clamp"),
tooltip: _tr("Clamps the output value to the interval [0,1]."),
type: "BOOL",
default_value: false,
output: 0
Expand Down