- Home /
How many different levels of r g b and a can unity create in a Color?
I have tried looking at the unity documentation for Color, but can't find any information related to how many different levels of red, green, blue or alpha unity can display when using Color. I know there is Color32, which can have values from 0 to 255 (in integer steps of 1) of r, g, b and a, but there is no information for just Color.
How many different levels of r, g, b or a can unity display when using Color?
Is it 32 bit, with 256 choices like Color32, or is it 64bit?
Answer by Namey5 · Apr 30, 2021 at 09:22 AM
For the Color struct, each channel is stored as a float (i.e. 32-bit floating point value) adding to a total size of 128 bits - 4,294,967,296 unique values per-channel that can exist outside the normalised range of [0,1].
Excuse me good sir, 4 294 967 296
is true for UInt32
public const uint MaxValue = 4294967295;
Float
has a 23-bit long mantissa, so more like 8 388 608
Answer by andrew-lukasik · Apr 30, 2021 at 11:29 AM
How many different levels of r, g, b or a can unity display when using Color?
Number of possible color variants doesn't depend on input data structures alone but on your whole graphics pipeline as well (this is true for every engine).
Imagine pushing this fat 128bpp byte4x4
( Color
) struct through a transformation pipeline (both on CPU and GPU sides) producing some variant of 32bpp or 24bpp struct at the other end and not knowing about it - you may think you have RGBA{ float r,g,b,a; }
but, in reality, it's more like RGBA{ byte r,g,b; }
when it hits your screen.
Also if you setup your pipeline correctly so you have 4 floats landing on the GPU memory, and have to be very pedantic about it, remember that even some lighting and basic shader operations, mere rounding errors etc (not to mention post-processing) running on your GPU can limit final color palette as well.
(not to mention physical display device that will mess all that up)
Your answer
Follow this Question
Related Questions
Problem graphics (ground & invisible object at a certain distance) 1 Answer
Shaders problems after moving to URP 0 Answers
Vertex colors as diffuse in lightmapping. 0 Answers
[Resolved] Game view displays the wrong colors? 1 Answer
Set Gameobject a certain color based off of other game objects 1 Answer