[go: up one dir, main page]

CN111598985B - Bloom effect improvement method and device based on Unity - Google Patents

Bloom effect improvement method and device based on Unity Download PDF

Info

Publication number
CN111598985B
CN111598985B CN202010292918.3A CN202010292918A CN111598985B CN 111598985 B CN111598985 B CN 111598985B CN 202010292918 A CN202010292918 A CN 202010292918A CN 111598985 B CN111598985 B CN 111598985B
Authority
CN
China
Prior art keywords
bloom
initial
value
texture
threshold
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010292918.3A
Other languages
Chinese (zh)
Other versions
CN111598985A (en
Inventor
陈亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ultimate Attainment Interactive Network Technical Concern Co ltd In Xiamen
Original Assignee
Ultimate Attainment Interactive Network Technical Concern Co ltd In Xiamen
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ultimate Attainment Interactive Network Technical Concern Co ltd In Xiamen filed Critical Ultimate Attainment Interactive Network Technical Concern Co ltd In Xiamen
Priority to CN202010292918.3A priority Critical patent/CN111598985B/en
Publication of CN111598985A publication Critical patent/CN111598985A/en
Application granted granted Critical
Publication of CN111598985B publication Critical patent/CN111598985B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/02Non-photorealistic rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)
  • Control Of Indicators Other Than Cathode Ray Tubes (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a Unity-based Bloom effect improvement method and a Unity-based Bloom effect improvement device, wherein the method comprises the following steps: opening a Bloom strength parameter and a threshold thereof; writing Bloom intensities to the transparent channel; extracting a picture; obtaining a new brightness value; and obtaining the texture of the luminous area. According to the invention, the effect is adjusted by controlling the Bloom strength parameter on the single material, so that the picture effect is improved.

Description

Bloom effect improvement method and device based on Unity
Technical Field
The invention relates to the field of computer graphics, in particular to a Unity-based Bloom effect improvement method and device.
Background
The Bloom effect is a screen special effect common in games. This special effect simulates an image effect of a real camera, which causes a brighter area in the picture to "diffuse" into surrounding areas, resulting in a hazy effect.
The processing flow of the Bloom effect of the game picture is that after all objects in the game play a picture through a camera, a brighter area in the picture is extracted according to a threshold value, the brighter area is stored in a rendering texture, the rendering texture is subjected to fuzzy processing by utilizing Gaussian blur, the effect of light diffusion is simulated, and finally the rendering texture is mixed with an original picture, so that the final effect is obtained.
The traditional scheme can only open a parameter and a threshold value of the parameter to adjust the Bloom effect of the whole picture, and can not adjust the whole picture according to a single material, so that the picture performance can not reach the expectations.
Disclosure of Invention
The invention provides a Bloom effect improvement method and device based on Unity, which are used for adjusting effects and improving picture effects by controlling Bloom strength parameters on single materials.
In order to achieve the above purpose, the invention adopts the following technical scheme:
a Unity-based Bloom effect improvement method comprises the following steps:
each material opens a Bloom strength parameter and a threshold value thereof;
writing Bloom strength into a transparent channel of each pixel of the material;
extracting an initial picture, wherein the initial picture comprises an initial texture, and the initial texture is provided with the transparent channel;
extracting a color value and a brightness value of each pixel of the initial picture to obtain an initial color value and an initial brightness value;
multiplying the Bloom intensity value by the initial brightness value to obtain a new brightness value;
creating a rendered texture of the same size as the initial texture;
and comparing the new brightness value with a brightness threshold, writing a transparent color value into a corresponding pixel of the rendering texture if the new brightness value is smaller than the brightness threshold, and writing the initial color value into the corresponding pixel of the rendering texture if the new brightness value is larger than or equal to the brightness threshold to obtain the luminous area texture.
Preferably, the Bloom strength parameter and the opening method of the threshold value thereof are respectively as follows: on a loader code of the texture, first, a first variable of a floating point type is declared as the Bloom strength parameter, and then a second variable of the floating point type is defined as a Bloom strength threshold, wherein an input value of the Bloom strength parameter is an initial Bloom strength.
Preferably, the material is an opaque material, and the method for writing the Bloom strength into the transparent channel of each pixel of the material includes the following steps:
calculating the color value of each pixel of the material;
writing the first Bloom strength into a transparent channel to obtain the initial color value;
returning the initial color value to perform rendering;
a method of writing the Bloom strength to a transparent channel of each pixel of the transparent material, comprising the steps of:
preferably, the material is a transparent material, and the method for writing the Bloom strength into the transparent channel of each pixel of the material includes the following steps:
firstly, performing first rendering, wherein the rendering only writes into an RGB channel, and the method comprises the following steps:
calculating the color value of each pixel of the material;
returning the color value to render;
then, carrying out second rendering, wherein the rendering only writes the transparent channel, and the method comprises the following steps:
multiplying the transparency by the first Bloom strength to obtain a second Bloom strength;
writing the second Bloom strength into a transparent channel to obtain the initial color value;
and returning the initial color value to perform rendering.
Preferably, the method for calculating the first Bloom strength comprises the following steps:
calculating the color value of each pixel of the material;
calculating a brightness value of the color value;
and comparing the brightness value with the Bloom intensity threshold to obtain a first Bloom intensity, wherein the first Bloom intensity is equal to 0 if the brightness value is smaller than the Bloom intensity threshold, and the first Bloom intensity is equal to the initial Bloom intensity if the brightness value is larger than or equal to the Bloom intensity threshold.
Preferably, the method further comprises the following steps:
carrying out Gaussian blur processing on the texture of the light-emitting area to obtain Gaussian blur textures;
mixing the Gaussian blur texture with the initial picture to obtain a final picture;
rendering the final picture to a screen.
Based on the same inventive concept, the invention also provides a Unity-based Bloom effect improvement device, which comprises:
the parameter setting module is used for opening a Bloom strength parameter and a threshold value thereof on each material;
the texture setting module is used for extracting an initial picture, wherein the initial picture comprises initial textures, and the initial textures are provided with the transparent channels; creating a rendered texture of the same size as the initial texture;
the computing module is used for extracting the color value and the brightness value of each pixel of the initial picture to obtain an initial color value and an initial brightness value; multiplying the initial brightness value by a Bloom intensity value to obtain a new brightness value;
a comparison module for comparing the new luminance value with a luminance threshold;
the writing module is used for writing the Bloom strength into a transparent channel of each pixel of the material; and if the new brightness value is smaller than the brightness threshold value, writing a transparent color value into the corresponding pixel of the rendering texture, and if the new brightness value is larger than or equal to the brightness threshold value, writing the initial color value into the corresponding pixel of the rendering texture to obtain the luminous area texture.
Based on the same inventive concept, the present invention also provides a storage medium including a stored program, wherein the program performs the above-described Unity-based Bloom effect improvement method.
Based on the same inventive concept, the invention also provides a processor for running a program, wherein the program runs to execute the Unity-based Bloom effect improvement method.
The beneficial effects of the invention are as follows: on the basis of adjusting parameters of the whole picture by the original Bloom effect scheme, a Bloom intensity parameter is opened on the material of each object, and the Bloom effect of each object is adjusted more finely, so that more excellent picture expression effect is manufactured.
Drawings
Fig. 1 is a flow diagram of a Unity-based Bloom effect improvement method.
Detailed Description
In order to make the technical problems, technical schemes and beneficial effects to be solved more clear and obvious, the invention is further described in detail below with reference to specific embodiments. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Example 1
As shown in fig. 1, the embodiment provides a Unity-based Bloom effect improvement method, which includes the following steps:
1. the Bloom strength parameter and its threshold are opened.
Firstly, a floating point type variable is declared on a loader code corresponding to a material and is used as a Bloom strength parameter. At this point, the property interface of the material may appear as an input box named Bloom Power, from which the user may adjust the initial Bloom strength.
Another floating point type variable is defined on the loader code as a Bloom strength threshold. A box named Bloom limit appears in the same way, from which the user can adjust the Bloom strength threshold.
2. The first Bloom intensity Bloom1 is calculated.
The color value color of each pixel of the material is calculated.
The luminance value light of the color value is calculated again,
the formula: light=color.r×0.2125+color.g×0.7154+color.b×0.0721.color. R, color. G, and color. B are color values of three color channels of red, green, and blue, respectively.
Finally, comparing the brightness value light with an input Bloom intensity threshold value Bloom light, and if the brightness value light is smaller than the Bloom intensity threshold value Bloom, enabling the first Bloom intensity Bloom1 to be equal to 0; if the luminance value light is greater than or equal to the Bloom intensity threshold Bloom light, the first Bloom intensity Bloom1 is equal to the input initial Bloom intensity Bloom Power.
3. And (5) material rendering treatment.
For the use cases of Alpha transparent channels of materials used in games, we have performed the following 2 classifications: a. opaque material (not using Alpha transparent channels); b. transparent material (Alpha transparent channel is used).
3.1 opaque material handling scheme.
Writing the first Bloom strength Bloom1 into an Alpha transparent channel of the color value color, namely setting color.a=bloom 1, and returning the color value color for rendering.
3.2 transparent Material handling scheme, two rendering processes are required.
First rendering: and declaring that the rendering is only written into the RGB channel, and directly returning to the color value color for rendering.
And (3) rendering for the second time: and declaring that the rendering is only written into the Alpha transparent channel, multiplying the transparency value color. A by the first Bloom strength Bloom1 to obtain a second Bloom strength Bloom2, writing the second Bloom strength Bloom2 into the Alpha transparent channel of the color value color, namely setting color. A=bloom 2, and returning to the color value color for rendering.
Bloom treatment.
The initial picture is extracted at the end of the frame. It is stated that it is necessary to have Alpha transparent channels, such as RGBA32, when extracting the texture of the original picture.
And processing the initial picture pixel by pixel, and extracting an initial color value color and an initial brightness value light of each pixel.
The transparency value color. A is multiplied by the luminance value light to obtain a new luminance value lightnew.
A piece of rendering texture of the same size is created and color values are written. Comparing the new brightness value lightnew with the brightness threshold value, if the new brightness value lightnew is smaller than the brightness threshold value, writing a transparent color value into a corresponding pixel of the rendered texture, namely, firstly setting color.a=0, and then writing an initial color value color; if the new brightness value lightnew is greater than or equal to the brightness threshold value, the initial color value color is directly written into the corresponding pixel of the rendering texture, and the texture of the luminous area in the initial picture is extracted.
The original flow with Bloom effect is used for processing, and the original following flow is:
and blurring processing is carried out on textures of the luminous area by using a Gaussian blurring process, and the effect of light diffusion is simulated.
And mixing the picture with the initial picture to obtain a final effect.
And finally, rendering the final effect to a screen.
Unity is one of the mainstream game engines in the current game industry, and can enable players to easily create types of interactive contents such as three-dimensional video games, building visualizations, real-time three-dimensional animations, etc. The method is implemented based on Unity. However, the algorithm of the method can be extended to use on other game engines.
Those skilled in the art will appreciate that implementing all or part of the steps of the above-described method embodiments may be accomplished by a program stored in a storage medium, including instructions for causing a device (which may be a single-chip microcomputer, chip or the like) or processor (processor) to perform all or part of the steps of the method described in the various embodiments of the application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Example two
The invention provides a Unity-based Bloom effect improvement device, which comprises:
the parameter setting module is used for opening a Bloom intensity parameter and a threshold value thereof on each material and inputting an initial Bloom intensity Bloom Power and a Bloom intensity threshold value Bloom Limit.
The texture setting module is used for extracting an initial picture, wherein the initial picture comprises initial textures, and the initial textures are provided with Alpha transparent channels; a rendered texture of the same size as the original texture is created.
The calculating module is used for multiplying the Bloom intensity value with the initial brightness value color to obtain a new brightness value lightnew, and calculating a color value color, a brightness value light, a first Bloom intensity Bloom1 and a second Bloom intensity Bloom2.
And the comparison module is used for comparing the new brightness value lightnew with the brightness threshold value and comparing the brightness value lightwith the Bloom intensity threshold value Bloom.
The writing module is used for writing the Bloom strength into the Alpha transparent channel of each pixel of the material; and if the new brightness value lightnew is smaller than the brightness threshold value, writing a transparent color value into the corresponding pixel of the rendering texture, and if the new brightness value lightnew is larger than or equal to the brightness threshold value, directly writing an initial color value color into the corresponding pixel of the rendering texture to obtain the luminous region texture.
And the rendering module is used for performing rendering processing on the materials and rendering the final effect on the screen.
The present embodiment provides a storage medium having a program stored thereon, which when executed by a processor, implements a Unity-based Bloom effect improvement method.
The embodiment provides a processor, which is used for running a program, and executing a Unity-based Bloom effect improvement method when the program runs.
While the foregoing description illustrates and describes the preferred embodiments of the present invention, it is to be understood that the invention is not limited to the forms disclosed herein, but is not to be construed as limited to other embodiments, but is capable of use in various other combinations, modifications and environments and is capable of changes or modifications within the scope of the inventive concept, either as described above or as a matter of skill or knowledge in the relevant art. And that modifications and variations which do not depart from the spirit and scope of the invention are intended to be within the scope of the appended claims.

Claims (8)

1. A Unity-based Bloom effect improvement method is characterized by comprising the following steps:
each material opens a Bloom strength parameter and a threshold value thereof;
writing Bloom strength into a transparent channel of each pixel of the material;
extracting an initial picture, wherein the initial picture comprises an initial texture, and the initial texture is provided with the transparent channel;
extracting a color value and a brightness value of each pixel of the initial picture to obtain an initial color value and an initial brightness value;
multiplying the initial brightness value by a Bloom intensity value to obtain a new brightness value;
creating a rendered texture of the same size as the initial texture;
comparing the new brightness value with a brightness threshold, writing a transparent color value into a corresponding pixel of the rendering texture if the new brightness value is smaller than the brightness threshold, and writing the initial color value into the corresponding pixel of the rendering texture if the new brightness value is larger than or equal to the brightness threshold to obtain a luminous area texture;
the Bloom strength parameter and the opening method of the threshold value are respectively as follows: on a loader code of the texture, first, a first variable of a floating point type is declared as the Bloom strength parameter, and then a second variable of the floating point type is defined as a Bloom strength threshold, wherein an input value of the Bloom strength parameter is an initial Bloom strength.
2. The Unity-based Bloom effect improvement method as claimed in claim 1, wherein the material is an opaque material, the method of writing the Bloom intensity to the transparent channel of each pixel of the material, comprising the steps of:
calculating the color value of each pixel of the material;
writing the first Bloom strength into a transparent channel to obtain the initial color value;
and returning the initial color value to perform rendering.
3. The Unity-based Bloom effect improvement method as claimed in claim 1, wherein the material is a transparent material, the method of writing the Bloom intensity to the transparent channel of each pixel of the material, comprising the steps of:
firstly, performing first rendering, wherein the rendering only writes into an RGB channel, and the method comprises the following steps:
calculating the color value of each pixel of the material;
returning the color value to render;
then, carrying out second rendering, wherein the rendering only writes the transparent channel, and the method comprises the following steps:
multiplying the transparency by the first Bloom strength to obtain a second Bloom strength;
writing the second Bloom strength into a transparent channel to obtain the initial color value;
and returning the initial color value to perform rendering.
4. A Unity-based Bloom effect improvement method as claimed in claim 2 or 3, characterized in that the calculation method of the first Bloom strength comprises the steps of:
calculating the color value of each pixel of the material;
calculating a brightness value of the color value;
and comparing the brightness value with the Bloom intensity threshold to obtain a first Bloom intensity, wherein the first Bloom intensity is equal to 0 if the brightness value is smaller than the Bloom intensity threshold, and the first Bloom intensity is equal to the initial Bloom intensity if the brightness value is larger than or equal to the Bloom intensity threshold.
5. The Unity-based Bloom effect improvement method as claimed in claim 1, further comprising the steps of:
carrying out Gaussian blur processing on the texture of the light-emitting area to obtain Gaussian blur textures;
mixing the Gaussian blur texture with the initial picture to obtain a final picture;
rendering the final picture to a screen.
6. A Unity-based Bloom effect improvement apparatus, comprising:
the parameter setting module is used for opening a Bloom strength parameter and a threshold value thereof on each material;
the Bloom strength parameter and the opening method of the threshold value are respectively as follows: firstly, declaring a first variable of a floating point type on a loader code of the material as the Bloom strength parameter, and then defining a second variable of the floating point type as a Bloom strength threshold, wherein the input value of the Bloom strength parameter is the initial Bloom strength;
the texture setting module is used for extracting an initial picture, wherein the initial picture comprises an initial texture, and the initial texture is provided with a transparent channel; creating a rendered texture of the same size as the initial texture;
the computing module is used for extracting the color value and the brightness value of each pixel of the initial picture to obtain an initial color value and an initial brightness value; multiplying the initial brightness value by a Bloom intensity value to obtain a new brightness value;
a comparison module for comparing the new luminance value with a luminance threshold;
the writing module is used for writing the Bloom strength into a transparent channel of each pixel of the material; and if the new brightness value is smaller than the brightness threshold value, writing a transparent color value into the corresponding pixel of the rendering texture, and if the new brightness value is larger than or equal to the brightness threshold value, writing the initial color value into the corresponding pixel of the rendering texture to obtain the luminous area texture.
7. A storage medium comprising a stored program, wherein the program executes the Unity-based Bloom effect improvement method of any one of claims 1 to 5.
8. A processor, wherein the processor is configured to run a program, wherein the program when run performs the Unity-based Bloom effect improvement method of any of claims 1 to 5.
CN202010292918.3A 2020-04-15 2020-04-15 Bloom effect improvement method and device based on Unity Active CN111598985B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010292918.3A CN111598985B (en) 2020-04-15 2020-04-15 Bloom effect improvement method and device based on Unity

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010292918.3A CN111598985B (en) 2020-04-15 2020-04-15 Bloom effect improvement method and device based on Unity

Publications (2)

Publication Number Publication Date
CN111598985A CN111598985A (en) 2020-08-28
CN111598985B true CN111598985B (en) 2023-05-12

Family

ID=72187516

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010292918.3A Active CN111598985B (en) 2020-04-15 2020-04-15 Bloom effect improvement method and device based on Unity

Country Status (1)

Country Link
CN (1) CN111598985B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114066719A (en) * 2021-10-27 2022-02-18 的卢技术有限公司 A method of face recognition, skin resurfacing and whitening based on Unity
CN114219737B (en) * 2021-12-21 2024-12-13 厦门极致互动网络技术股份有限公司 A tone mapping method based on Unity
CN114359466A (en) * 2021-12-27 2022-04-15 在线途游(北京)科技有限公司 Rendering method and device for realizing local Bloom effect

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1870055A (en) * 2006-06-27 2006-11-29 北京航空航天大学 High dynamic range material color applying drawing method
US7202867B1 (en) * 2003-01-31 2007-04-10 Microsoft Corporation Generation of glow effect
CN104157005A (en) * 2014-08-06 2014-11-19 无锡梵天信息技术股份有限公司 Image-based HDR (high-dynamic range) illumination rendering method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7202867B1 (en) * 2003-01-31 2007-04-10 Microsoft Corporation Generation of glow effect
CN1870055A (en) * 2006-06-27 2006-11-29 北京航空航天大学 High dynamic range material color applying drawing method
CN104157005A (en) * 2014-08-06 2014-11-19 无锡梵天信息技术股份有限公司 Image-based HDR (high-dynamic range) illumination rendering method

Also Published As

Publication number Publication date
CN111598985A (en) 2020-08-28

Similar Documents

Publication Publication Date Title
CN111598985B (en) Bloom effect improvement method and device based on Unity
US9418473B2 (en) Relightable texture for use in rendering an image
CN109035381B (en) Cartoon picture hair rendering method and storage medium based on UE4 platform
Grundland et al. Cross dissolve without cross fade: Preserving contrast, color and salience in image compositing
JP4075039B2 (en) Texture mapping method, program and apparatus
CN107256539B (en) An Image Sharpening Method Based on Local Contrast
CN105069834B (en) A kind of game image rendering intent and system
CN110288670B (en) High-performance rendering method for UI (user interface) tracing special effect
CN112837251B (en) Image processing method and device
CN103440674A (en) Method for rapidly generating crayon special effect of digital image
WO2007092138A2 (en) Correcting eye color in a digital image
CN105096370B (en) Equivalent partition anti-aliasing method for ray tracing
CN105488769B (en) A kind of real-time video defogging method
US7133052B1 (en) Morph map based simulated real-time rendering
US9064336B2 (en) Multiple texture compositing
CN109859303B (en) Image rendering method and device, terminal equipment and readable storage medium
CN108550124B (en) Illumination compensation and image enhancement method based on bionic spiral
CN104240276A (en) Screen-space-based method for simulating real skin of figure through sub-surface scattering
CN112516595A (en) Magma rendering method, device, equipment and storage medium
CN113350791A (en) Edge processing method, device, equipment and storage medium of virtual role
CN117475053A (en) Grass rendering method and device
CN104008525A (en) Low-resolution particle drawing method for improving resolution based on double buffering
CN114972648A (en) Model rendering method, device, computer equipment and storage medium
Lü et al. Image watercolorization based on visual weight-map
Chen et al. Importance-driven composition of multiple rendering styles

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant