Color components higher than 1

Hi,

Here is my color.

Color color = new Color(.988200009f, 1.11380005f, 1.26279998f, 1);

As you can see g and b components have a value higher than 1. However Unity renders it as a light blue.

I believe there is an equivalent color with components between 0 and 1.

Is is right? How can I determine it?

the Color values are normalized r,g,b,a ranges
so it only reads values from 0-1
you can alwas make a little math to get the r,g,b values like

int red = (int)youColor.r * 255;

this will give the decimal value of the red color component, do this with the other components and check it out on the color picker.

for more information read:

It entirely depends on the shader you’re using. Most shaders combine the color with the incoming texture and some even double the incoming value. In the end the color is always clamped between 0 and 1.

I think you’re asking the wrong question.

RGB colour components must be between 0 - 1. Your original code is not a valid colour so, as @Jeffom pointed out, there is no defined behaviour in your case. The “light blue” colour you see is effectively arbitrarily chosen (in other programming environments, it would have thrown an exception).

The problem you need to solve is how you came to derive the RGB component values listed in the first place, and to ensure these are normalised to the 0 - 1 range.

A value of 1 on the final, rendered pixel means it should be the brightest possible, so yes, you are right. Another color with clamped values would produce the same result as the one you mentioned, because it’s impossible for the pixel to be brighter than “1” (which is defined as the maximum brightness).

Until it gets to that final stage, however, anything you do with your color struct (such as multiplying it by 0.5) happens to the unclamped values you provided and can lead to unintended results.

The Color struct in Unity is basically just a data container, and (it seems like) they don’t check for argument validity, so values over 1 are allowed.