Unity Color vs. Color32, channel explanation corresponding to PS

1. First talk about Unity Color and Color32:

Official website documents:

Unity - Scripting API: Color

Unity - Scripting API: Color32

Color and Color32 are interchangeable. Unity seems to use Color by default. What is the difference?

Color : Use Float (4 bytes, 32 bits!) to correspond to a channel. Then RGBA=4*4 bytes*8= 128 bit !

Big has big benefits. The number of colors that can be expressed is also higher. It can even be directly combined with HDR (float, of course, can represent data above 1).

Color32 : Use Byte (1 byte 8 bits) to correspond to a channel, so RGBA=4*1 byte*8 = 32 bit

Small has its advantages. It is theoretically faster and takes up less memory , which is 1/4 of Color. The disadvantage is that 256*256*256=16777216 colors are fixed. Many colors cannot be represented. To represent HDR, the data capacity is not enough. The solution is to rely on multiple images or additional data. But Unity is a black box inside, and the processing of the lower-level rendering algorithm is even more unclear, so if you just want to express 16 million colors, it is better to use this theory.

You can use a breakpoint to see:

 

2, let’s talk about the PS channel:

Channel : expressed in bits, the amount of information that can be supported.

The most commonly used 8-bit channel: use 8bit (1 byte) information to describe the information in the channel.

 

Well, the color mode  is RGB color , 8-bit channels . 8*3 channels (RGB) = corresponding to 24-bit color. 8 bits, the data range that can be represented is 0-255, so it can display: 256*256*256=16777216 colors. Plus 8 bits, the Alpha channel that describes the transparency of this pixel also corresponds to Unity's Color32 data format.

PS channel, above 16 bits, not many supported formats. So don't talk about it for now.

3. Display equipment, such as display parameter problems:

At present, most of the mainstream 1 billion color displays are 8 to 10. Of course, in addition to monitors, other display devices also have higher color depth. I will not mention it for now.

 

4. Commonly used color depth:

I remembered the teaching materials for the system analyst exam many years ago:

Color Depth: Use bits (not bytes) to represent the number of colors.

1 bit : 2 colors, monochromatic light, black and white two colors.

8 bits : 256 colors. The most commonly used is the Gif map .

16-bit : used by some old games and old operating systems.

(Red occupies 5 bits, blue occupies 5 bits, and green occupies 6 bits, so red, blue, and green each have 32, 32, and 64 variations, and a total of 64K colors can be combined)

24-bit : the most commonly used at present. There are 16,777,216 colors, true color. Most used.

32-bit : generally refers to adding an 8-bit transparent channel on the basis of 24-bit true color.

Guess you like

Origin blog.csdn.net/chenggong2dm/article/details/124283791