Skip to content

Commit

Permalink
Add a variadic color picker node
Browse files Browse the repository at this point in the history
  • Loading branch information
myaaaaaaaaa committed Nov 7, 2024
1 parent 5dbd41d commit c601df1
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
77 changes: 77 additions & 0 deletions addons/material_maker/nodes/color_pick.mmg
Original file line number Diff line number Diff line change
@@ -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"
}
5 changes: 5 additions & 0 deletions material_maker/library/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c601df1

Please sign in to comment.