Talk gamma correction - the important points

What is gamma correction, after learning about it through, I would like to use the most simple 400 words explain the problem.
Firstly here several reference URL:
https://blog.csdn.net/candycat1992/article/details/46228771/
https://www.bilibili.com/video/BV15t411Y7cf?from=search&seid=4640175940751520217
HTTPS: // zhuanlan.zhihu.com/p/66558476
https://blog.csdn.net/yangxuan0261/article/details/92732725
https://zhuanlan.zhihu.com/p/36507196
https://zhuanlan.zhihu.com/p / 66558476

Give these bars, is looking more confused and incomprehensible, but today I will be a new perspective to explain the problem, hope is the correct interpretation Ha, no, please light hammer. . .

Let me give you an example:
First, look back at the movie Titanic, Jack and when the high point of falling in love pork, collapse soon, came a hit an iceberg.
Iron at Nick has since become the Heart by Will Go ON and My ON ...
the ok, here we do not forget, we are talking about what is gamma correction.

When the ship sink faster when the need to grab a seat.
Join us only 100 seats.
Consider children, ladies first principle, can only select 100 people to sit in, to escape.
Then so many people on the ship, assuming there are 10,000, at this time you can only choose 100. This involves trade-offs, who die, who live?
Obviously those important people, priority be saved.

Back to the gamma correction involves four steps:
natural color - "Camera acquisition (stored as a picture) -" The display shows - "the human eye to see the color of nature

The myriad colors of nature - "corresponds to the number of victims of the Titanic (everyone has a seat number)
camera collection (stored as a picture) -" Escape correspond 100 seats (everyone is renumbered in accordance with the conversion from 0-100 back row)
display shows - "100 people came back to escape, to find the original seat number on the Titanic.

Here Insert Picture Description
We need to find a mapping between the original people numbered, mapped to the number on the boat.
Here Insert Picture Description
We out a policy, not directly cut off some people, but to follow importance sampling, more importantly, have a greater chance of being put into boats.

ok, here's importance, which is more sensitive we are to the human eye corresponding to the dark, we sacrificed more unimportant people, at the expense of higher color brightness.

So how does this map?
Check the image above sampling frequency, the sampling frequency of the green part is getting smaller and smaller, which is an important part of the sampling very many times without important part of reducing the number of samples.
The image above red plaid, uniform changes, because what? Because the number of housing prices will inevitably follow a linear transformation. The red is the corresponding code.

Sampling frequency can be drawn by a power of (1 / 2.2) red values:
Here Insert Picture Description

This is a way of understanding.

Another is storage space is limited, we have a new number of low-frequency (dark part) shading, so let people come in dark portions come to live. The dark parts, such as real is 0.2, how to transform the space allowed to live in it 0.5? 0.2 ^ (1 / 2.2) to power.

ps in the color space View:
Here Insert Picture Description
Here Insert Picture Description

How to view a picture color space used:
Here Insert Picture Description

How do I change a picture's color space:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

ok. It ends here.

Then the following to show unity in sampling:
First gamma workflow:
Here Insert Picture Description
Image is checked by default sRGB import of:
Here Insert Picture Description
sampling shader:

fixed4 frag (v2f i) : SV_Target
{
    fixed4 col = tex2D(_MainTex, i.uv);
    return col;
}

Here Insert Picture Description
In the figure above, we can see the effect at 8 in different situations.
You can see the picture no matter what the format, as long as the online work environment, uncheck srgb brightening effect occurs.

The following analysis of unity at rendering time, do what, use renderdoc cut frame analysis tools.

The following is a cross-sectional analysis using the snapdragon see picture frame formats:
Reference: https:? //Editor.csdn.net/md/ articleId = 103799344

Here Insert Picture Description
First, we tested in gamma space, check the situation srgb or not.
Check the time, cut the frame see the picture format is:
Here Insert Picture Description
is RGB8_ETC2, or after treatment: RGBA8 format.

If you uncheck sRGB
Here Insert Picture Description
is RGB8_ETC2, or after treatment: RGBA8 format.

Experiments show that in unity for the gamma workflow situation, check srgb or not does not matter.

Here is switched to the linear workflow:
First, cancel auto graphics api, attention is unchecked, then removed opengl es2
Here Insert Picture Description
Here Insert Picture Description
Note that if you are using a linear workflow, then, must be above opengl es3, so here out of the openg es2. Before packing test.

Here is a check of the results srgb: cut frames, dark. Then the input and output are:
SRGB8_ETC2 and SRGB8_ALPHA8
Here Insert Picture Description

Finally, operating results are normal.

The following is not checked the situation srgb:
Here Insert Picture Description
finally there is a slight change in the input and output into a RGB8_ETC2 still is SRGB8_ALPHA8.

Here Insert Picture Description
The final picture changed bright.

So summarized as follows:
1, if unity using gamma workflow, regardless of the picture is checked or unchecked srgb, then unity is without any treatment, not linear change of 2.2, not 1 / 2.2 after treatment do operation.

2, if the use of linear workflow unity, then if the selected image srgb mode, unity is reduced to make its linear processing is 2.2, then when the output is automatically processed 1 / 2.2.
If the picture is not checked srgb mode, unity does not do its linear drop of 2.2, and after treatment, lack of operation do still retains 1 / 2.2. Then the final image will become bright.
Srgb original picture is still space in the shooting or ps, the operation has made a 1 / 2.2. But because we do not check srgb, so do not drop linear 2.2, and in the final output, unity automatic operation made a 1 / 2.2, so do it, twice and 1 / 2.2, so the picture brightens a.

3, how to distinguish a picture if you want to check srgb it? If unity is the choice of gamma workflow, we do not care enough to choose, because unity is for us not to do anything. They are in accordance with how the input, how to process.
And if it is a linear workflow, you will need a human operator is required to determine whether people need to check this image srgb.

4, which pictures need to check srgb it? Check the srgb actually gives unity implies what?
For online work flow, that is, unity using the linear mode, for a diffuse map that art given, it is directly drawn in ps, whereas plotted in ps in the picture, it is stored as srgb space (and a good discussion of fine Arts). It is stored in the (space 1 / 2.2 in) on the curve. So this time after importing unity, we must know that this figure is a non-linear diagram. You will have to check srgb.

While other figures, such as normal maps, mask map, noise map, procedural textures, are linear map, then check srgb in order to avoid causing unity help us to do the operation a 2.2, so to explicitly tell unity, this you do not need to turn linear, and I myself have a linear diagram.

Summary does not know is wrong, but you do think is right.

Published 646 original articles · won praise 107 · views 360 000 +

Guess you like

Origin blog.csdn.net/wodownload2/article/details/105124113