Color Mask (vector 3???) Selector Node

Hello there…

I am trying to replicate the below World Machine node set up in Unreal Engine. i.e. to be able to mask out a single color 3 vector from a texture file, which is then used to mask a texture, say grass or sand.

I can achieve this by using only the RGB channels, but this means I am limited to 3 colors per each texture I use for masking. Whereas using one texture file and masking out specific vector 3 colors (instead of only Red, Green & Blue) I could hold all my mask info in one texture/image file. This would make the art work a lot simpler.

The closest answers I can find are the 2 descibed in the below link, but niether really does the same thing as the World Machine example in the pics below.

[link text][1]

Any help you might have I would greatly appreciate, I´ve been stuck on this for months

I don’t know how World Machine suppose to work but The 2nd example you link should give what you want as you need to difference of from selection color and texture, the closer they get to 0 the higher chance it is same as selection color. There few thing you can do different:

Insted of using if nodes you can use smoothstep, with with on Min pin tolerance+falloff and Max just tolerance, this will smooth out the selection mask a bit

You can also convert RGB to HSV which will make masking based on hue, saturation and brightness of color instead of RGB values, but this change color accuracy

Think of mathematical formula of what World Machine is doing and try to reproduce it in material (aka shader)

Thanks for the response. I will need to have a think about the maths behind the World Machine node, then figure out how to recreate it in Unreal. I guess it will need to be a custom macro/function. Shame this is not a standard node in Unreal, I think it would be really useful.

Found a method to do this well so thought I would share. Using a Distance node and an If node does the job fairly well.
The selected colour is filtered out of the input image and can be used as a mask for defining boundaries of materials on a landscape, without the need for mulitple image files to define the masks, where only RGB channels can be used as masks. i,e, limited to 3 channels per image. This way you can have alomost infinite channels in one image file, which can be used as masks.