A tone mapping method based on Unity
By setting the brightness threshold in Unity and performing blur processing, distinguishing the dark and bright areas, combining the brightness texture and mapping curve for tone mapping, the shortcomings of the impact of tone mapping in the existing technology are solved, and dark information is retained and optimized. Mapping effect.
Patent Information
- Application Number
- CN202111573361.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-12-21
AI Technical Summary
The existing tone mapping method provided by Unity cannot control the strength of a single object affected by tone mapping, causing pixels with brightness to become darker in the dark area, losing color information, and failing to achieve the expected effect.
In Unity, by setting a brightness threshold, distinguishing dark and brightness areas, adjusting the brightness value and blurring, combining the brightness texture and mapping curve for tone mapping, mixing the tone mapping texture and basic texture, controlling the effect of the final image, and adjusting Color brightness of a single object to adjust the effect of tone mapping.
The color information of the dark area is retained, the influence intensity of tone mapping is controlled, and a more realistic and optimized mapping screen effect is achieved.
Smart Images

Figure CN114219737B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a tone mapping method based on Unity. Background Art
[0002] Tone mapping is a computer graphics technology that approximates the display of high dynamic range images on a limited dynamic range medium. Its basic principle is to perform a large contrast attenuation to transform the scene brightness to a displayable range while maintaining image details and colors, which are very important for representing the original scene. The existing tone mapping provided by Unity can only affect the final rendering of all objects as a whole, but cannot control the degree to which a single object is affected by tone mapping. It will also make the pixels in the dark area of the picture darker, lose some color information, and ultimately the effect of the entire picture will not meet expectations. Summary of the invention
[0003] To solve the above problems, the present invention provides a tone mapping method based on Unity.
[0004] The present invention adopts the following technical solutions:
[0005] A tone mapping method based on Unity, comprising the following steps:
[0006] S1. Save the rendering result of the original image as a basic texture before Unity performs tone mapping.
[0007] S2, distinguishing the dark area and the bright area of the original image according to a preset brightness threshold, adjusting the brightness values thereof respectively, performing blur processing on the adjusted brightness values and saving them as brightness textures;
[0008] S3, combining the brightness texture and the mapping curve, performing tone mapping processing on the original image, obtaining a rendering result after tone mapping, and saving it as a tone mapping texture;
[0009] S4. Mix the tone mapping texture and the color value of the basic texture to obtain a final tone mapping image.
[0010] Furthermore, the method further comprises step S5 of controlling the effect of the final tone mapping image by adjusting the color brightness of a single object in the original image.
[0011] Furthermore, the attributes of the basic texture, brightness texture and tone mapping texture are all global rendering textures.
[0012] Furthermore, step S2 specifically includes the following steps:
[0013] S21, calculating the brightness value L of each pixel in the basic texture;
[0014] S22, presetting a brightness threshold luminance, the area where the brightness value L is less than the brightness threshold luminance belongs to the dark area, and the area where the brightness value L is equal to or higher than the brightness threshold luminance belongs to the bright area;
[0015] S23, modifying the luminance value L of the dark area to L1=0, that is, the pixels in the dark area are not affected by tone mapping; and modifying the luminance value L of the bright area to L1=L-luminance, that is, the degree of influence of tone mapping on the pixels in the bright area is L-luminance;
[0016] S24, blurring the modified brightness value L1 and saving it as a brightness texture.
[0017] Furthermore, the brightness value L is calculated as:
[0018] L=color.r*0.2125+color.g*0.7154+color.b*0.0721; color.r represents the brightness value of red, color.g represents the brightness value of green, and color.b represents the brightness value of blue.
[0019] Furthermore, the blur processing adopts a Gaussian blur algorithm.
[0020] Furthermore, step S4 specifically includes the following steps:
[0021] S41, pre-set the minimum brightness value L min and the maximum brightness value L max ;
[0022] S42, use the smoothstep function at the lowest brightness value L min and the maximum brightness value L max Smoothing is performed between them to calculate the blending parameters;
[0023] S43. According to the blending parameter blend, the color values of the tone mapping texture and the basic texture are mixed to obtain a final color value affected by the tone mapping, and a final tone mapping image is output.
[0024] After adopting the above technical solution, the present invention has the following advantages compared with the background technology:
[0025] 1. The present invention distinguishes the dark area in the original image by setting a brightness threshold, and modifies the brightness value of the dark area to 0. Without changing the original tone mapping curve, the color information of the dark area is retained, and the situation of information loss of the dark area in the mapped image is improved;
[0026] 2. The brightness values of the original image and the mapped image are mixed through the mixing parameters to control the intensity of the scene affected by the tone mapping;
[0027] 3. According to the actual final mapping effect, the color brightness and brightness threshold parameters of a single object on the original image are adjusted in real time, so as to accurately control the intensity of the influence of tone mapping on a single object in the scene, and quickly and intuitively adjust the final mapping screen display effect to produce a more realistic and optimized mapping screen. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0030] Example
[0031] like Figure 1 As shown, a tone mapping method based on Unity includes the following steps:
[0032] S1. Save the rendering result of the original image as a basic texture before Unity performs tone mapping.
[0033] S2, distinguishing the dark area and the bright area of the original image according to a preset brightness threshold, adjusting the brightness values thereof respectively, performing blur processing on the adjusted brightness values and saving them as brightness textures;
[0034] Step S2 specifically includes the following steps:
[0035] S21, extracting brightness information from the basic texture, and calculating the brightness value L of each pixel in the basic texture;
[0036] The calculation of the brightness value L is:
[0037] L=color.r*0.2125+color.g*0.7154+color.b*0.0721; color.r represents the brightness value of red, color.g represents the brightness value of green, and color.b represents the brightness value of blue.
[0038] S22, presetting a brightness threshold luminance, the area where the brightness value L is less than the brightness threshold luminance belongs to the dark area, and the area where the brightness value L is equal to or higher than the brightness threshold luminance belongs to the bright area;
[0039] S23, modifying the luminance value L of the dark area to L1=0, that is, the pixels in the dark area are not affected by tone mapping; and modifying the luminance value L of the bright area to L1=L-luminance, that is, the degree of influence of tone mapping on the pixels in the bright area is L-luminance;
[0040] S24, blurring the modified brightness value L1 and saving it as brightness texture. The blurring process adopts Gaussian blurring algorithm. Blurring process is performed here to smooth the edge of the area affected by tone mapping.
[0041] S3. Combining the brightness texture and the mapping curve, tone mapping is performed on the original image to obtain a rendering result after tone mapping, and the result is saved as a tone mapping texture. Since the dark area is distinguished in the brightness texture by a preset brightness threshold luminance, and its brightness value L is modified to L1=0, the pixels in the dark area are not affected by the tone mapping, thereby retaining the color information of the dark area.
[0042] S4. Mix the tone mapping texture and the color value of the basic texture to obtain a final tone mapping image.
[0043] Step S4 specifically includes the following steps:
[0044] S41, pre-set the minimum brightness value L min and the maximum brightness value L max ; Low brightness means that the degree of influence by tone mapping is weak, and high brightness means that the degree of influence by tone mapping is strong;
[0045] S42, use the smoothstep function at the lowest brightness value L min and the maximum brightness value L max Smoothing is performed between them to calculate the blending parameters;
[0046] blend = smoothstep(L min , L max, L1), where L min Indicates the minimum brightness value, L max represents the highest brightness value, L1 represents the brightness value stored in the brightness texture;
[0047] S43. According to the blending parameter blend, the color values of the tone mapping texture and the basic texture are mixed to obtain a final color value affected by the tone mapping, and a final tone mapping image is output.
[0048] S5. Control the effect of the final tone mapping image by adjusting the color brightness of a single object in the original image. In actual operation, developers can adjust the color brightness of a single object in the original image in real time according to the effect of the final displayed tone mapping image, thereby controlling the degree to which a single object is affected by the tone mapping effect. Since the color of the object uses HDR color, the color brightness can be adjusted over a wider range; specifically, when the original brightness value of the object is less than the minimum brightness value L min When the object is not affected by the tone mapping effect, the original color of the object will be displayed; when the original brightness of the object is between the minimum brightness value L min and the maximum brightness value L max When the object is between , the object is affected by the partial tone mapping effect and is displayed as a transition color between the original color of the object and the color after tone mapping; when the brightness value of the object is greater than the maximum brightness value L max When the object is fully affected by the tone mapping effect, it is displayed as the tone mapped color. In actual operation, the minimum brightness value L min and the maximum brightness value L max The value range is between 0-2.0.
[0049] The attributes of the basic texture, brightness texture, and tone mapping texture in this embodiment are all global rendering textures.
[0050] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A tone mapping method based on Unity, characterized in that: The steps include: S1. Save the rendering result of the original image as a basic texture before Unity performs tone mapping. S2, distinguishing the dark area and the bright area of the original image according to a preset brightness threshold, adjusting the brightness values thereof respectively, performing blur processing on the adjusted brightness values and saving them as brightness textures; S3, combining the brightness texture and the mapping curve, performing tone mapping processing on the original image, obtaining a rendering result after tone mapping, and saving it as a tone mapping texture; S4. Mix the tone mapping texture and the color value of the basic texture to obtain a final tone mapping image.
2. A tone mapping method based on Unity as claimed in claim 1, characterized in that: The method further comprises step S5 of controlling the effect of the final tone mapping image by adjusting the color brightness of a single object in the original image.
3. A tone mapping method based on Unity as claimed in claim 2, characterized in that: The attributes of the basic texture, brightness texture and tone mapping texture are all global rendering textures.
4. A tone mapping method based on Unity as claimed in claim 3, characterized in that: Step S2 specifically includes the following steps: S21, calculating the brightness value L of each pixel in the basic texture; S22, presetting a brightness threshold luminance, the area where the brightness value L is less than the brightness threshold luminance belongs to the dark area, and the area where the brightness value L is equal to or higher than the brightness threshold luminance belongs to the bright area; S23, modifying the luminance value L of the dark area to L1=0, that is, the pixels in the dark area are not affected by tone mapping; and modifying the luminance value L of the bright area to L1=L-luminance, that is, the degree of influence of tone mapping on the pixels in the bright area is L-luminance; S24, blurring the modified brightness value L1 and saving it as a brightness texture.
5. A tone mapping method based on Unity as claimed in claim 4, characterized in that: The calculation of the brightness value L is: L=color.r*0.2125+color.g*0.7154+color.b*0.0721; wherein color.r represents the brightness value of red, color.g represents the brightness value of green, and color.b represents the brightness value of blue.
6. A tone mapping method based on Unity as claimed in claim 5, characterized in that: The blur processing adopts Gaussian blur algorithm.
7. A tone mapping method based on Unity as claimed in claim 4, characterized in that: Step S4 specifically includes the following steps: S41, pre-set the minimum brightness value L min and the maximum brightness value L max ; S42, use the smoothstep function at the lowest brightness value L min and the maximum brightness value L max Smoothing is performed between them to calculate the blending parameters; S43. According to the blending parameter blend, the color values of the tone mapping texture and the basic texture are mixed to obtain a final color value affected by the tone mapping, and a final tone mapping image is output.
Citation Information
Patent Citations
Methods, apparatus, and systems for extended high dynamic range (HDR) HDR to HDR tone mapping
CN107203974A
Bloom effect improvement method and device based on Unity
CN111598985A
