2
$\begingroup$

can you do the same action as the color range selection in photoshop inside of blender ? is there anyway you can do this action below ?

enter image description here

enter image description here

if its not is it possible trough the compositor? what node is it ?

---


there is a method out there: How can I use colours to separate texture node treatment?

it really work well for hard edges, but for soft edges its a mess

enter image description here

$\endgroup$
2

1 Answer 1

5
$\begingroup$

Here's a technique you can use to select multiple colors, and get soft edge selections.

I borrowed the idea of using a Vector Math Node set to Length to measure the similarity of colors from Robin Betts. It also relates to this question about replacing colors.

This is not an exact replica of the formula that's coded into Photoshop, but it achieves the same thing. In Ps the "fuzziness" has a range of values from 0 to 200, with 100 being the default. While putting together this node setup I got to wondering what "fuzziness" is actually a measurement of, and found out that it is brightness values. In my node setup the fuzziness is represented in a range of 0.0 to 1.0.

So instead of using Photoshop's eyedropper in additive mode, we place a custom "Select Color" group node for each color we want to add to the color range, and combine them with MixRGB nodes set to Add and Fac set to 1.0. We can chain as many as desired.

Note: It is also possible to subtract from the selection by setting a MixRGB node's blend mode to Subtract (instead of Add). More about the Subtract blend mode here.

Select Color Range - Blender material node setup

This is what's happening inside of each "Select Color" Group Node:

Inside the "Select Color" Group Node

The final Math Node set to Subtract is just inverting the selection so that the selected area is white instead of black.

When dealing with a selection mask or alpha transparency, we want a range of 0.0 to 1.0, so enable Clamp on the final Math Node to ensure the values stay within that range.

The final selection (basically a mask) can be used for anything, but in this example I have it factoring a a MixRGB node so that all the selected colors get replaced with a pale green.

Original image (credit):

Selection (mask):

Example result:

That's basically all there is to it, and this can be customized in various ways to select ranges of colors for whatever purpose.


2023/02/16 update:

Blend file added.

(Created with Blender ver. 3.4)

General notes on color mixing and selection

(Things that will be obvious to many people, but maybe not everyone.)

  • In my example I am using the Mix node to simply replace the selected area with a solid color fill, however by changing the blend type in the drop-down from Mix to another type you can get different effects. For example, Hue will colorize the selected area with a new hue.
  • To change a selection with soft edges to one with hard edges, one simple way is to run it through a Math node set to Greater Than and adjust the Threshold.
  • To make selection edges harder (but not necessarily completely hard), you can route the selection through an RGB Curves node and shape the curve into an S-curve or a steep linear curve. The steeper the curve, the harder the edges become.
$\endgroup$
2
  • $\begingroup$ would you mind posting the Blender file, I am having a hard time replicate your direction. $\endgroup$
    – ajthechan
    Commented Feb 14, 2023 at 19:09
  • $\begingroup$ @ajthechan Done! :-) $\endgroup$
    – Mentalist
    Commented Feb 16, 2023 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .