-2

I started learning Unity and Shader Graph. Right now I try to understand, how the Channel Mixer is working internally.

I put in a color R 50,G 100,B 150 and the configuration on the output-R channel is R 1,G 1,B 1

Configuration on output-G is R 0,G 1,B 0 and on output-B is R 0,G 0,B 1.

According to ChatGPT the ChannelMixer in that case is calculating the output channel like:

100% input-R (50) + 100% input-G (100) + 100% input-B (150) = 300.

Because colors can be not higher than 255, the output-R should be 255. But it is 181, which i figured out with a color picker.

I even made another shader with just the expected output color of R 255,G 100,B 150 and put two cubes besides one another.

And the colors clearly differ.

So, the assumption that the ChannelMixer just adds the colors and caps it on 255 is apparently not correct.

Can anyone explain, how it is really working?

Thanks :)

0

1 Answer 1

2

how about the API => it apparently uses DOT product

Generated Code Example

The following example code represents one possible outcome of this node.

_ChannelMixer_Red = float3 (OutRedInRed, OutRedInGreen, OutRedInBlue);
_ChannelMixer_Green = float3 (OutGreenInRed, OutGreenInGreen, OutGreenInBlue);
_ChannelMixer_Blue = float3 (OutBlueInRed, OutBlueInGreen, OutBlueInBlue);

void Unity_ChannelMixer_float(float3 In, float3 _ChannelMixer_Red, float3 _ChannelMixer_Green, float3 _ChannelMixer_Blue, out float3 Out)
{
   Out = float3(dot(In, _ChannelMixer_Red), dot(In, _ChannelMixer_Green), dot(In, _ChannelMixer_Blue));
}

And it makes sense, you basically configure how much of the original channels IN should influence each individual of the resulting channels OUT.

As said above it is indeed a Dot product - which in other words basically means "How aligned is the IN color as a vector with each of the OUT channel mixes as a vector

Sign up to request clarification or add additional context in comments.

1 Comment

Okay, I am missing some math concepts here. That's why I don't understand it. Thank you. Guess I will learn more math first lol.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.