Materials How to: if Base output has blue color - then inverse the blue, otherwise do nothing?

UE4.27

  1. What is the Material logic to have 2 input paths, 1 output.
  2. And how to detect a color/color range + 5% in the Base feed, and if it equals a certain color (blue), then inverse that blue so the final output does not look blue?
  • Purpose: I have a color changing Material Instance (w/ Master) and a Base texture with some blue colored highlights, while most of the texture is White, so it can be colorized.

  • If the player changes the Color Param in game to red, then the White main-parts turn Red, and the Blue-highlight gets a tint of red, but it’s ok - there is still some contrast between the new Red and the Blue highlight.

  • But if the player changes Param to Blue, then the White main-parts and Blue highlights are both blue, thus the highlight part can’t be distinguished.

  • Thus I want a smart Material that detects if the Base output (after Color Param modifier) turns blue, then inverse the blue to not look blue.

  • Please help, ty.

Just use a mask to color things differently.

A texture is less cost than trying to bungle math you don’t understand hoping to get a result.

As an example, look up any metallic material, the process is essentially the same.

I have a texture heavy project (50x textures Id have to make a mask-change for), and I keep going over budget after increasing pool. Thus I want a non texture-asset way to do this - using code.

Do you understand the code, where I went wrong? I put it together the best I could based on different example. But I dont the parts in red.

Theres so much wrong with it, its pointless to even speculate.

Since it seems all your channels are packed, just isolate blue by using a mask for B.
The output will be directly the blue color.
Either before for a mask of the original, or after to change it all as it got mixed by your operations.

If you are going over texture budget, chances are you are using way too large files compared to what is needed. Usually, a 1k^2 texture is enough.
Additionally generally speaking, specularity, roughness, metallic, and displacement get packed up into a single texture (R = roughness, G = specular or gloss, B is bump/height, and A is metallic, but people change to whatever they prefer).

Does anyone know the Material logic to have 2 input paths, 1 output?
Or is it even possible?

The code I posted is incomplete because I do not understand how the nodes in the red box work, thus my question.

  • What do I put as [Value] in the Switch node?
    I need 2 inputs A & B, a 3rd for off/on, no/yes, and an output based on the no/yes result.
    Closeup pic (full pic is in OP):

I got the idea from this pic, using Distance node as a measurement of the difference between [Base output] and [the color I want to detect]:

Your whole code is wrong period. There is no “because”.

Distance is a measure. In float.
The input you are using is a float 3.
The result would mean some sort of difference between RGB of A and RGB of B.
As a float 3.
Probably euqal to B minus A as RGB.
Ei: blue minus blue equal 0 blue channel.
Again, completely useless.

What you are asking for above, is only applicable by your own asking to a single channel. BLUE. So work in a single channel - which also costs less.

Further, switch makes no sense, as it takes the values and toggles them on or off based on something. But in theory an IF would already be doing the same thing. Either filtering out, or returning the same.

Additionally, you don’t multiply colors to change them. 0x1 is? 1x1 is? Your result of 0,0,1 x 0,0,0 would be?
Just no.
To color something a different hue, you use a lerp and replace light to black values to other color(s).
You can change single channel darkenss/lightness to create a different specific color, or you can do it on a texture as a whole by feeding a desaturated version of it as the alpha.

Essentially, go back to the drawing board here. Potentially to learning how materials work.

I would suggest any Ben Cloward videos on youtube as an introductory start.

Also some of the Escape Studios videos - though not as basic - are probably a good idea.

I made that clear in the first post, with the big red comment box, and the Engine saying ERROR. Thus why I posted a visual on this help forum, for the pros to see and answer.
Ive asked for help 3 times, and you replied 3 times.

  1. So do you know the Material logic to have 2 input paths, 1 output? (I showed that I am working with R,G,B.) Can you post a picture instead of words? I am a visual learner.
  2. Do you know how to detect a color in the Base feed, and if it equals a certain color [that I set as a PARAM in an MI instance], then inverse that [color detected] so the final output does not look [that color]? Can you post a picture of the code? Ty
  • No, I am asking for a “smart Material” wildcard “code” solution - that I set the [color to detect/inverse] with a Param in an MI (NOT the Master - not a one time solution for only one channel) - so that I can manually change the Param wildcard (color) as needed for ANY color in any texture-set when using this for 50x MIs.

  • The color blue is irrelevant, and only posted as an example for the pros to see what I am asking for help with.

  • I know the Alpha connection is wrong in my first pic (orange arrow). I posted it to show I tried many ways, and both gave errors. The RGB route is wrong too, because the Switch node is wrong.

  • I used the Switch to guess, what has 2 inputs and a selector to determine which input goes to the output? And I dont know what to put for all the inputs for the [If node], prior answers worked in older engines but not UE4.27. Thus I asked you.

  • So do you know the answer?