diff --git a/addons/material_maker/nodes/blend2.mmg b/addons/material_maker/nodes/blend2.mmg index 626edc14..e4d05141 100644 --- a/addons/material_maker/nodes/blend2.mmg +++ b/addons/material_maker/nodes/blend2.mmg @@ -61,10 +61,73 @@ "", "vec3 blend_exclusion(vec2 uv, vec3 c1, vec3 c2, float opacity) {", "\treturn opacity*vec3(blend_exclusion_f(c1.x, c2.x), blend_exclusion_f(c1.y, c2.y), blend_exclusion_f(c1.z, c2.z)) + (1.0-opacity)*c2;", + "}", + "", + "vec3 blend_hue(vec2 uv, vec3 c1, vec3 c2, float opacity) {", + "\tvec3 outcol = c2;", + "", + "\tvec3 hsv, hsv2, tmp;", + "\thsv2 = rgb_to_hsv(c1);", + "", + "\tif (hsv2.y != 0.0) {", + "\t\thsv = rgb_to_hsv(outcol);", + "\t\thsv.x = hsv2.x;", + "\t\ttmp = hsv_to_rgb(hsv);", + "\t\toutcol = mix(outcol, tmp, opacity);", + "\t}", + "\treturn outcol;", + "}", + "", + "vec3 blend_saturation(vec2 uv, vec3 c1, vec3 c2, float opacity) {", + "\tfloat facm = 1.0 - opacity;", + "", + "\tvec3 outcol = c2;", + "\tvec3 hsv, hsv2;", + "", + "\thsv = rgb_to_hsv(outcol);", + "", + "\tif (hsv.y != 0.0) {", + "\t\thsv2 = rgb_to_hsv(c1);", + "", + "\t\thsv.y = facm * hsv.y + opacity * hsv2.y;", + "\t\toutcol = hsv_to_rgb(hsv);", + "\t}", + "\treturn outcol;", + "}", + "", + "vec3 blend_color(vec2 uv, vec3 c1, vec3 c2, float opacity) {", + "\tfloat facm = 1.0 - opacity;", + "", + "\tvec3 outcol = c2;", + "", + "\tvec3 hsv, hsv2, tmp;", + "\thsv2 = rgb_to_hsv(c1);", + "", + "\tif (hsv2.y != 0.0) {", + "\t\thsv = rgb_to_hsv(outcol);", + "\t\thsv.x = hsv2.x;", + "\t\thsv.y = hsv2.y;", + "\t\ttmp = hsv_to_rgb(hsv);", + "", + "\t\toutcol = mix(outcol, tmp, opacity);", + "\t}", + "\treturn outcol;", + "}", + "", + "vec3 blend_value(vec2 uv, vec3 c1, vec3 c2, float opacity) {", + "\tfloat facm = 1.0 - opacity;", + "", + "\tvec3 hsv, hsv2;", + "\thsv = rgb_to_hsv(c2);", + "\thsv2 = rgb_to_hsv(c1);", + "", + "\thsv.z = facm * hsv.z + opacity * hsv2.z;", + "\treturn hsv_to_rgb(hsv);", "}" ], "includes": [ - "blend" + "blend", + "adjust_hsv" ], "inputs": [ { @@ -187,6 +250,22 @@ { "name": "Exclusion", "value": "exclusion" + }, + { + "name": "Hue", + "value": "hue" + }, + { + "name": "Saturation", + "value": "saturation" + }, + { + "name": "Color", + "value": "color" + }, + { + "name": "Value", + "value": "value" } ] }, diff --git a/material_maker/doc/images/blend_color.png b/material_maker/doc/images/blend_color.png new file mode 100644 index 00000000..c76772f1 Binary files /dev/null and b/material_maker/doc/images/blend_color.png differ diff --git a/material_maker/doc/images/blend_hue.png b/material_maker/doc/images/blend_hue.png new file mode 100644 index 00000000..509b6778 Binary files /dev/null and b/material_maker/doc/images/blend_hue.png differ diff --git a/material_maker/doc/images/blend_saturation.png b/material_maker/doc/images/blend_saturation.png new file mode 100644 index 00000000..589ad4af Binary files /dev/null and b/material_maker/doc/images/blend_saturation.png differ diff --git a/material_maker/doc/images/blend_value.png b/material_maker/doc/images/blend_value.png new file mode 100644 index 00000000..a1753402 Binary files /dev/null and b/material_maker/doc/images/blend_value.png differ diff --git a/material_maker/doc/node_filter_blend.rst b/material_maker/doc/node_filter_blend.rst index 611c2879..5062589b 100644 --- a/material_maker/doc/node_filter_blend.rst +++ b/material_maker/doc/node_filter_blend.rst @@ -34,7 +34,8 @@ The **Blend** node has two or more parameters: * The *blend mode*, that can be one of the following: *Normal*, *Dissolve*, *Multiply*, *Screen*, *Overlay*, *Hard Light*, *Soft Light*, *Linear Light*, *Vivid Light*, *Pin Light*, *Burn*, *Dodge*, - *Lighten*, *Darken*, *Difference*, *Additive*, *AddSub*, *Hard Mix*, *Exclusion*. + *Lighten*, *Darken*, *Difference*, *Additive*, *AddSub*, *Hard Mix*, *Exclusion*, *Hue*, *Saturation*, + *Color*, *Value*. * The *opacity* is used when mixing the result of the blend operation with the background input when the corresponding input is not connected. When connected, the opacity channel is @@ -83,6 +84,14 @@ Blending modes .. |blend_exclusion| image:: images/blend_exclusion.png +.. |blend_hue| image:: images/blend_hue.png + +.. |blend_saturation| image:: images/blend_saturation.png + +.. |blend_color| image:: images/blend_color.png + +.. |blend_value| image:: images/blend_value.png + +-----------------------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ | Blend mode  | Example    | Description     | +=======================+===============================+===============================================================================================================================+ @@ -124,6 +133,14 @@ Blending modes +-----------------------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ | Exclusion | |blend_exclusion|  | This blend mode is similar to Difference, but it is less intense  | +-----------------------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| Hue | |blend_hue|  | This blend mode takes the hue of the top layer and combines them with the saturation and value of the bottom layer  | ++-----------------------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| Saturation | |blend_saturation|  | This blend mode takes the saturation of the top layer and combines them with the hue and value of the bottom layer  | ++-----------------------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| Color | |blend_color|  | This blend mode takes the hue and saturation of the top layer and combines them with the value of the bottom layer  | ++-----------------------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| Value | |blend_value|  | This blend mode takes the value of the top layer and combines them with the hue and saturation of the bottom layer  | ++-----------------------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ Notes +++++