From c601df17e14a0df12aed45ba7f1f7022807894d7 Mon Sep 17 00:00:00 2001 From: myaaaaaaaaa <103326468+myaaaaaaaaa@users.noreply.github.com> Date: Thu, 7 Nov 2024 01:46:59 -0500 Subject: [PATCH] Add a variadic color picker node --- addons/material_maker/nodes/color_pick.mmg | 77 ++++++++++++++++++++++ material_maker/library/base.json | 5 ++ 2 files changed, 82 insertions(+) create mode 100644 addons/material_maker/nodes/color_pick.mmg diff --git a/addons/material_maker/nodes/color_pick.mmg b/addons/material_maker/nodes/color_pick.mmg new file mode 100644 index 000000000..fa797a37c --- /dev/null +++ b/addons/material_maker/nodes/color_pick.mmg @@ -0,0 +1,77 @@ +{ + "name": "color_pick", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "seed_int": 0, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(1.0)", + "label": "", + "longdesc": "The input ID map", + "name": "in", + "shortdesc": "Input", + "type": "rgb" + } + ], + "instance": "", + "longdesc": "Pick colors from an input ID map", + "name": "Color Pick", + "outputs": [ + { + "f": "1.0 - clamp((dot(abs($in($uv) - $color#.rgb), vec3(1.0/3.0)) - $threshold) / max($falloff, 0.00001), 0.0, 1.0)", + "longdesc": "Output mask corresponding to the picked color", + "shortdesc": "Output #", + "type": "f" + } + ], + "parameters": [ + { + "default": { + "a": 1, + "b": 1, + "g": 1, + "r": 1 + }, + "label": "", + "longdesc": "Color to pick from the ID map", + "name": "color#", + "shortdesc": "Color #", + "type": "color" + }, + { + "control": "None", + "default": 0.01, + "label": "Threshold", + "longdesc": "Controls the sensitivity of color matching. Higher values will match more colors.", + "max": 1, + "min": 0, + "name": "threshold", + "shortdesc": "Threshold", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Falloff", + "longdesc": "Controls the softness of the output mask. Set to 0 to output a binary black/white image.", + "max": 1, + "min": 0, + "name": "falloff", + "shortdesc": "Falloff", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Pick colors" + }, + "type": "shader" +} diff --git a/material_maker/library/base.json b/material_maker/library/base.json index 2f1d96f1a..d622ea105 100644 --- a/material_maker/library/base.json +++ b/material_maker/library/base.json @@ -2751,6 +2751,11 @@ "tree_item": "Filter/Decompose", "type": "decompose" }, + { + "display_name": "Color Pick", + "tree_item": "Filter/Color Pick", + "type": "color_pick" + }, { "display_name": "SwapChannels", "icon": "filter_swapchannels",