Fuzzy region feathering method and device, storage medium and electronic device
By acquiring and loading images, and combining blur parameters to perform feathering rendering, the problem in the existing technology that the edge pixels of the blurred area are too stiff is solved, and the feathering of the blurred area with advanced UI effects is achieved.
Patent Information
- Application Number
- CN202410917387.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2025-01-21
AI Technical Summary
The prior art cannot effectively realize the feathering effect of the blurred area, resulting in the edge pixels in the blurred area and the background contact with the background being too stiff and cannot meet the needs of advanced UI effects.
By obtaining the fuzzy parameters of the fuzzy area, loading foreground images and background images, and determining the fuzzy area according to the overlapping area, using fuzzy parameters to render the fuzzy area to achieve the flexible control and diversified effects of the fuzzy area.
The soft mixing and gradient effects of the fuzzy area are realized, the marginal pixels are avoided, and the needs of the high -end UI effect are met, and the materials are not needed to improve efficiency and generality.
Smart Images

Figure CN119338715A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a fuzzy area feathering method and device, a storage medium, and an electronic device. Background Art
[0002] In the related technology, the project has high requirements for UI effects. In some UI areas, blur effects are required and the edge pixels where the blurred area and the background are in contact are feathered, that is, the blurred area color and the background color must be mixed and the mixing intensity must have a gradient effect, and the speed of the gradient of the mixing intensity can be adjusted. Because the UE engine's own UMG blur control can only produce an overall blur effect, that is, an overall consistent blur within a square. The foreground color and background color of the edge pixels of the area are not mixed, not feathered, and too abrupt. It cannot meet the needs of the project. The BackgroundBlur blur control of the UE engine can only blur the pixels within the square as a whole, and the shape of the blurred area cannot be adjusted. The edge pixels where the blurred foreground and background are in contact are too abrupt and have no feathering effect.
[0003] In the related technology, the feathering of the edge pixels where the front and back of the blurred area of the UMG control in the UE engine touches the background can be achieved by applying materials to the UMG control. However, this method is more troublesome and requires the production of materials and each control must use the materials, which requires drawing materials, and has poor efficiency and versatility.
[0004] With respect to the above-mentioned problems existing in the related technologies, no effective solutions have been found so far. Summary of the invention
[0005] The embodiments of the present invention provide a fuzzy area feathering method and device, a storage medium, and an electronic device.
[0006] According to one embodiment of the present invention, a method for feathering a blurred area is provided, comprising: obtaining blur parameters of the blurred area, wherein the blur parameters are used to indicate a blur effect of the blurred area; loading a foreground image and a background image, and determining the blurred area according to an overlapping area between the foreground image and the background image; and feathering the blurred area using the blur parameters.
[0007] Optionally, before the step of obtaining the fuzzy parameters of the blurred area, the method further includes: in response to a configuration request triggered by the user interface of the editor, configuring a first fuzzy parameter and / or a second fuzzy parameter in the editor, the first fuzzy parameter being used to indicate the blur shape of the blurred area, and the second fuzzy parameter being used to indicate the color mixing gradient speed of the blurred area; storing the first fuzzy parameter and / or the second fuzzy parameter in the parameter structure of the blurred area.
[0008] Optionally, configuring the first fuzzy parameter in the editor includes: configuring the first fuzzy parameter in an enumeration type variable of the post-processing data structure of the editor; and / or, configuring the second fuzzy parameter in the editor includes: configuring the second fuzzy parameter in a floating point type variable of the post-processing data structure of the editor.
[0009] Optionally, the blur parameters include the first blur parameter and the second blur parameter, and using the blur parameters to perform feathering rendering on the blurred area includes: constructing a matching pixel shader template based on the first blur parameter, wherein the first blur parameter is used to indicate the blur shape of the blurred area, and the second blur parameter is used to indicate the color mixing gradient speed of the blurred area; using the second blur parameter to configure the pixel shader template to obtain a target pixel shader; driving the target pixel shader to perform feathering rendering on the colors within the blurred area to obtain a blurred image of the blurred area.
[0010] Optionally, driving the target pixel shader to perform feathering rendering on the colors within the blurred area includes: driving the Gaussian blur function of the target pixel shader to mix and calculate the pixel colors of the background image and the foreground image to obtain the color values of the pixels within the blurred area; driving the target pixel shader to calculate the Alpha values of the pixels within the blurred area, wherein the Alpha value is used to indicate the transparency of the color; and rendering the pixels within the blurred area based on the color value and the Alpha value.
[0011] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the first pixel value of each pixel in the blurred area in the first direction in a preset coordinate system.
[0012] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader, the first pixel value and the second pixel value; wherein the first pixel value is used for the pixel value of each pixel in the blurred area in a first direction in a preset coordinate system, and the second pixel value is used to represent the pixel value of each pixel in the blurred area in a second direction in the preset coordinate system.
[0013] Optionally, when the blur form is a blurred blended gradient feathering around the edges of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate.
[0014] Optionally, when the blur form is a blurred blended gradient feathering in the central area of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the intermediate value according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate; and using the intermediate value to calculate the Alpha value of the pixels in the blurred area.
[0015] According to one embodiment of the present invention, a feathering device for a blurred area is provided, comprising: a setting module, used to obtain blur parameters of the blurred area, wherein the blur parameters are used to indicate the blur effect of the blurred area; a processing module, used to load a foreground image and a background image, and determine the blurred area according to the overlapping area of the foreground image and the background image; and a rendering module, used to perform feathering rendering on the blurred area using the blur parameters.
[0016] Optionally, the device also includes: a configuration module, used to configure a first fuzzy parameter and / or a second fuzzy parameter in the editor before the acquisition module acquires the fuzzy parameters of the fuzzy area, the first fuzzy parameter being used to indicate the fuzzy shape of the fuzzy area, and the second fuzzy parameter being used to indicate the color mixing gradient speed of the fuzzy area; a storage module, used to store the first fuzzy parameter and / or the second fuzzy parameter in the parameter structure of the fuzzy area.
[0017] Optionally, the configuration module includes: a first configuration unit, used to configure a first fuzzy parameter in an enumeration type variable of the post-processing data structure of the editor; and / or, a second configuration unit, used to configure a second fuzzy parameter in a floating point type variable of the post-processing data structure of the editor.
[0018] Optionally, the blur parameters include the first blur parameters and the second blur parameters, and the rendering module includes: a construction unit, used to construct a matching pixel shader template according to the first blur parameters, wherein the first blur parameters are used to indicate the blur shape of the blur area, and the second blur parameters are used to indicate the color mixing gradient speed of the blur area; a configuration unit, used to configure the pixel shader template using the second blur parameters to obtain a target pixel shader; and a rendering unit, used to drive the target pixel shader to perform feathering rendering on the colors within the blur area to obtain a blurred image of the blur area.
[0019] Optionally, the rendering unit includes: a first calculation subunit, used to drive the Gaussian blur function of the target pixel shader to mix and calculate the pixel colors of the background image and the foreground image to obtain the color values of the pixels within the blurred area; a second calculation subunit, used to drive the target pixel shader to calculate the Alpha value of the pixels within the blurred area, wherein the Alpha value is used to indicate the transparency of the color; and a first rendering subunit, used to render the pixels within the blurred area based on the color value and the Alpha value.
[0020] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, the second calculation sub-unit is also used to calculate the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the first pixel value of each pixel in the blurred area in the first direction in a preset coordinate system.
[0021] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, the second calculation subunit is also used to: calculate the Alpha value of the pixel in the blurred area according to the transparency change speed of the target pixel shader, the first pixel value and the second pixel value; wherein the first pixel value is used for the pixel value of each pixel in the blurred area in the first direction in the preset coordinate system, and the second pixel value is used to represent the pixel value of each pixel in the blurred area in the second direction in the preset coordinate system.
[0022] Optionally, when the blur form is a blurred blended gradient feathering around the edges of the blurred area, the second calculation subunit is also used to calculate the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate.
[0023] Optionally, when the blur form is a blurred mixed gradient feathering in the central area of the blurred area, the second calculation subunit is also used to: calculate the intermediate value according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate; and use the intermediate value to calculate the Alpha value of the pixel in the blurred area.
[0024] According to yet another embodiment of the present invention, a storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when running.
[0025] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0026] Through the present invention, blur parameters of the blurred area are obtained, wherein the blur parameters are used to indicate the blur effect of the blurred area, a foreground image and a background image are loaded, and the blurred area is determined according to the overlapping area of the foreground image and the background image, and the blurred area is feathered rendered using the blur parameters. By setting the blur parameters for controlling the blur effect of the blurred area, the pixel blending effect of the blurred area can be flexibly controlled to achieve a variety of feathering effects without the need to produce materials, thereby solving the technical problem that the related technology can only achieve pixel feathering effects through materials. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0028] Figure 1 It is a hardware structure block diagram of a fuzzy region feathering computer according to an embodiment of the present invention;
[0029] Figure 2 is a schematic flow chart of a method for feathering a fuzzy area according to an embodiment of the present invention;
[0030] Figure 3 Schematic diagram of blurring, blending and gradually feathering the top pixels of the blurry area according to an embodiment of the present invention;
[0031] Figure 4 This is a schematic diagram of blurring, blending, and gradually feathering the bottom of a blurry area according to an embodiment of the present invention;
[0032] Figure 5 Schematic diagram of blurring, blending and gradually feathering edge pixels around a blurry area according to an embodiment of the present invention;
[0033] Figure 6 This is a schematic diagram of fuzzy blending and gradual feathering at the center of a fuzzy area according to an embodiment of the present invention;
[0034] Figure 7 is a flow chart of feathering rendering in a rendering channel according to an embodiment of the present invention;
[0035] Figure 8 is a structural block diagram of a fuzzy area feathering device according to an embodiment of the present invention;
[0036] Fig. 9 It is a structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0037] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0039] Example 1
[0040] The method embodiment provided in the first embodiment of the present application can be executed in a mobile phone, tablet, server, computer or similar electronic terminal. Taking running on a server as an example, Figure 1 FIG. 1 is a hardware structure diagram of a fuzzy region feathering server according to an embodiment of the present invention. Figure 1 As shown, the server may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the server may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0041] The memory 104 can be used to store server programs, for example, software programs and modules of application software, such as a server program corresponding to a feathering method of a fuzzy area in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the server program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. In this embodiment, the processor 104 is used to respond to human-computer interaction instructions and game strategies, and control the target virtual character to perform specified operations to complete the game task. The memory 104 is used to store program scripts, configuration information, attribute information of virtual characters, etc. of electronic games.
[0042] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0043] Optionally, the input and output device 108 further includes a human-computer interaction screen for obtaining human-computer interaction instructions through a human-computer interaction interface, and for presenting a rendered scene image;
[0044] In this embodiment, a method for feathering a blurred area is provided. Figure 2FIG. 1 is a flow chart of a method for feathering a fuzzy area according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0045] Step S202, obtaining blur parameters of the blur area, wherein the blur parameters are used to indicate blur effects of the blur area;
[0046] Optionally, this embodiment can be applied to live broadcast, virtual scene (such as game, virtual desktop, etc.), interactive animation, film and television, etc. The virtual scene can be a game, a virtual desktop, or a virtual environment built based on education or tutorials. It should be noted that the embodiment of the present disclosure can be applied to a virtual scene including a rendering area, and can also be applied to non-virtual scenes such as film and television or live broadcast.
[0047] Optionally, the blurred area is used to represent at least a partial area where the foreground image and the background image overlap. The blurred parameter is used to indicate a blur effect of the blurred area. It should be noted that the blurred parameter can be obtained by determining or obtaining a preset value according to real-time input.
[0048] Step S204, loading the foreground image and the background image, and determining the blurred area according to the overlapping area of the foreground image and the background image;
[0049] It should be noted that step S202 and step S204 are interchangeable and equally applicable. It is understood that the fuzzy parameters are obtained before or after the step of determining the fuzzy area. It is understood that the embodiment of the present disclosure does not limit the execution order of step S202 and step S204.
[0050] Step S206, feathering rendering is performed on the blurred area using blur parameters.
[0051] Through the above steps, the blur parameters of the blurred area are obtained, wherein the blur parameters are used to indicate the blur effect of the blurred area, the foreground image and the background image are loaded, and the blurred area is determined according to the overlapping area of the foreground image and the background image, and the blurred area is feathered rendered using the blur parameters. By setting the blur parameters for controlling the blur effect of the blurred area, the pixel blending effect of the blurred area can be flexibly controlled to achieve a variety of feathering effects without the need to produce materials, thereby solving the technical problem that the related technology can only achieve pixel feathering effects through materials.
[0052] In this embodiment, when setting fuzzy parameters, one or more different types of fuzzy parameters can be set in the editor. The editor can set different types of fuzzy parameters to achieve different fuzzy effects. Different editors can set the same type of fuzzy parameters with different values to achieve different fuzzy effects.
[0053] Furthermore, the editor sets different types of blur parameters to achieve different blur effects. For example, the blur parameters include at least one of the following: a first blur parameter and a second blur parameter. The first blur parameter corresponds to the EFadeType (gradient type) editing item in the editor, and the second blur parameter corresponds to the EdgeSharp (sharp edge) editing item in the editor. The first blur parameter is used to indicate the blur shape of the blur area, and the second blur parameter is used to indicate the color mixing gradient speed of the blur area. In subsequent embodiments, the first blur parameter is represented by EFadeType, and the second blur parameter is represented by EdgeSharp.
[0054] Obtaining fuzzy parameters of the fuzzy area includes: responding to a configuration request triggered by the user interface of the editor, setting a first fuzzy parameter in the editor; configuring the first fuzzy parameter and / or the second fuzzy parameter in the editor; and storing the first fuzzy parameter and / or the second fuzzy parameter in the parameter structure of the fuzzy area.
[0055] In one example, the first blur parameter (EFadeType) can be represented by an enumeration type variable. Taking the Unreal 5 UI system (UMG) as an example, an enumeration type variable is added to the Background Blur control class of UMG to represent the blur area form, including at least one of the five methods:
[0056] 1. Blur_NoFade means the native blur mode of UE engine, and there is no mixed gradient between the foreground and background edge colors;
[0057] 2. Blur_TopFade blurs the top pixels of the area and makes a blurred blending gradient feathering. The top edge pixels change from clear to blurred gradually.
[0058] 3. Blur_DowndFade The bottom pixels of the blurred area are blurred and blended with gradient feathering, and the bottom edge pixels change from clear to blurred gradually;
[0059] 4. Blur_ARoundFade blurs the edge pixels around the blurred area and performs a blurred blending gradient feathering;
[0060] 5. Blur_ARoundFade_Inv makes a blurred blending gradient feathering at the center of the blurred area and blurs the surrounding areas.
[0061] In one example, the second blur parameter (EdgeSharp) can be represented by a floating-point type variable. A floating-point type variable is added to the BackgroundBlur control class to represent the speed of the color blending gradient. The smaller the value, the slower the change of the color's Alpha transparency value from 0 to 1, the more pixels the foreground color and the background color are mixed, the larger the feathering area, and the softer the edge transition. In effect, the larger the EdgeSharp value, the stiffer the edge between the foreground color and the background color. Both EFadeType and EdgeSharp parameters are exposed to the UMG editor, and the value size can be set in the editor.
[0062] In one example, configuring a first fuzzy parameter in the editor includes: configuring the first fuzzy parameter in an enumeration type variable of a post-processing data structure of the editor; in another example, configuring a second fuzzy parameter in the editor includes: configuring a second fuzzy parameter in a floating point type variable of a post-processing data structure of the editor.
[0063] Taking the Slate editor as an example, Slate's post-processing data structure FSlatePostProcessPayload adds an enumeration type variable EFadeType and a floating-point type variable EdgeSharp. The Slate post-processing data structure is used to store the EFadeType and EdgeSharp data of the BackgroundBlur control. After that, the Slate post-processing data structure will be passed in to construct a UI element rendering batch RenderBatch for Slate.
[0064] The solution of this embodiment transforms the Slate post-processing rendering pass function, which can be the FSlateDrawElement::MakePostProcessPass function. Two variables are added to the function's incoming parameters: an enumeration type variable FadeType and a floating-point type variable EdgeSharp. When the function is called in the OnPaint function of UBackgroundBlur, the enumeration type variable FadeType and the floating-point type variable EdgeSharp in the UBackgroundBlur class are stored in FSlatePostProcessPayload (Slate post-processing data structure).
[0065] Add an enumeration type variable FadeType to the parameter data structure FShaderParams of the pixel shader. In the function FSlateElementBatcher::AddPostProcessPass of the FSlateElementBatcher class to add a post-processing rendering channel, call the pixel shader parameter constructor MakePixelShaderParams of the FShaderParams class, and pass the FadeType and EdgeSharp values in FSlatePostProcessPayload to the FadeType of FShaderParams. Store the EdgeSharp value in the component w of PixelParams2 of the FShaderParams structure. Since the PixelParams2 component is a vector of 4 floating-point numbers, namely x, y, z, and w, and the w component is not used in the UE engine, it can be used to store the EdgeSharp value. The FShaderParams parameter is used to build a RenderBatch.
[0066] The solution of this embodiment adds an EdgeFadeParameter parameter in the SlatePostProcessBlurPS class of the Slate post-blur processing, and the parameter is bound to SlatePostProcessPixelShader.usf in the constructor, and a floating-point variable EdgeFade is newly added. The SlatePostProcessBlurPS class adds a SetEdgeSharp function, which provides an interface for setting the EdgeFade value.
[0067] According to the EFadeType and EdgeSharp parameters set in the UMG editor, these parameters are stored in FSlatePostProcessPayload, and then stored in the Pixel Shadr parameter structure FShaderParams, and finally the parameters are stored in the blurred area parameter structure FBlurRectParams.
[0068] In one implementation of this embodiment, the blur parameter includes a first blur parameter and a second blur parameter, and feathering the blur area using the blur parameter includes:
[0069] S11, constructing a matching pixel shader template according to a first fuzzy parameter, wherein the first fuzzy parameter is used to indicate a fuzzy shape of the fuzzy area, and the second fuzzy parameter is used to indicate a color mixing gradient speed of the fuzzy area;
[0070] S12, configuring a pixel shader template using the second fuzzy parameter to obtain a target pixel shader;
[0071] S13, driving the target pixel shader to perform feathering rendering on the colors in the blurred area to obtain a blurred image of the blurred area.
[0072] The first blur parameter corresponds to EFadeType, and the second blur parameter corresponds to EdgeSharp. Pixel shader templates are constructed according to different EFadeType types. The alpha transparency value calculation algorithm of different pixel shader template colors is different. In the Slate blur effect rendering function FSlatePostProcessor::BlurRect, the corresponding pixel shader is selected according to the EFadeType value of the blur area parameter structure FBlurRectParams to set the specific pixel shader. The floating point EdgeSharp value of the FBlurRectParams data structure is set to the corresponding pixel shader. After the BlurRect function runs, the blur effect and the color alpha transparency corresponding to the EFadeType type are rendered. In the SlatePostProcessor::UpsampleRect function, the blending method of the blur area and the background is set according to the EFadeType type. After the UpsampleRect function runs, the blending and superposition are completed.
[0073] When constructing the pixel shader template in advance, the solution of this embodiment can inherit the parent class FSlatePostProcessBlurPS by constructing the TFSlatePostProcessBlurPS template class. Five macros related to fuzzy mixed gradient modes are defined outside the TFSlatePostProcessBlurPS template class. The meaning of each macro is a binary bit, which is used to perform bitwise AND calculations with the TFSlatePostProcessBlurPS template parameter RenderFlag in the ModifyCompilationEnvironment function. According to the bitwise AND calculation result of a certain bit of the binary being 1 corresponding to the EFadeTyper method, OutEnvironment.SetDefine is called to define the fuzzy mixed gradient macro in SlatePostProcessPixelShader.usfshader. A global floating point type EdgeFade variable can be added to SlatePostProcessPixelShader.usf. In the Gaussian blur Pixel entry function GaussianBlurMain, the alpha transparency of the color is calculated according to the macros related to different fuzzy mixed gradient types.
[0074] In one example, driving the target pixel shader to feather render the colors within the blurred area includes: driving the Gaussian blur function of the target pixel shader to mix and calculate the pixel colors of the background image and the foreground image to obtain the color values of the pixels within the blurred area; driving the target pixel shader to calculate the Alpha values of the pixels within the blurred area, wherein the Alpha value is used to indicate the transparency of the color; and rendering the pixels within the blurred area based on the color value and the Alpha value.
[0075] In this example, by modifying the FSlatePostProcessor::UpsampleRect function, add the EFadeType type variable to the parameter list. The function is to render the blurred rendering image in the blurred area and overlay it on the background according to the corresponding blending method. In the function, set the GraphicsPSOInit.BlendState blending state by the EFadeType type. If the EFadeType value does not represent the feathering method that does not blend the foreground and background edge colors, the blending method is set to semi-transparent blending, and the foreground color and background color in the blurred area are interpolated according to the color's Alpha. If the EFadeType value represents the feathering method that does not blend the foreground and background edge colors, it is rendered in the original non-transparent way of the UE engine, only the foreground color is displayed, and the background color is not blended.
[0076] In the original method of the UE engine, the blurred area and the background color are not mixed, and the Alpha transparency value of the gradient color is 1: the Alpha calculation algorithm related to the SLATE_BLUR_NOFADE macro is: return float4(OutColor.rgb,1).
[0077] In an implementation scenario, when the blurring form is a blur blending gradient feathering on one side (such as the top, bottom, left, right, etc.) of the blurring area, taking the top as an example, driving the target pixel shader to calculate the alpha value of the pixel in the blurring area includes: calculating the alpha value of the pixel in the blurring area according to the transparency change speed of the target pixel shader and the first pixel value of each pixel in the blurring area in the first direction in a preset coordinate system.
[0078] In this implementation scenario, according to the transparency change speed of the target pixel shader and the first pixel value of each pixel in the blurred area in the first direction in the preset coordinate system, calculating the Alpha value of the pixels in the blurred area includes: reading the EdgeFade parameter of the target pixel shader, wherein the EdgeFade parameter is used to characterize the speed of transparency change; reading the pixel y coordinate value of each pixel in the blurred area in the uv coordinate; passing the pixel y value into a preset exponential function; and using the following function to calculate the Alpha value of the corresponding pixel: Alpha = (exp2(Input.UV.y)-1)*EdgeFade, where exp2() is an exponential function, Input.UV.y is the first pixel value, is the pixel y value, represents the numerical value of the y component of the pixel in the uv coordinate system, and EdgeFade represents the parameter value of the second blur parameter in the formula.
[0079] Figure 3 It is a schematic diagram of the top pixels of the blurred area of the embodiment of the present invention being subjected to blurred mixed gradient feathering, and the top edge image has a gradual process from clear to blurred. In this implementation scenario, the top pixels of the blurred area are subjected to blurred mixed gradient feathering, and the top edge pixels have a gradual process from clear to blurred. Alpha transparency calculation of related colors: the value of the uv coordinate y of the pixel is passed as a parameter into an exponential function, such as an exponential function with a base of 2, and then 1 is subtracted, and the calculated value is multiplied by the transparency change speed parameter EdgeFade, and finally the calculated value is limited to between 0 and 1, such as using the saturate function to limit the value range. Alpha calculation algorithm related to the SLATE_BLUR_TOPFADE macro: return float4(OutColor.rgb, saturate((exp2(Input.UV.y)-1)*EdgeFade)), OutColor.rgb is the color value corresponding to the pixel.
[0080] In an implementation scenario, when the blurring form is a blur blending gradient feathering on one side of the blurring area (such as the top, bottom, left, right, etc.), taking the bottom as an example, driving the target pixel shader to calculate the Alpha value of the pixel in the blurring area includes: calculating the Alpha value of the pixel in the blurring area according to the transparency change speed of the target pixel shader, the first pixel value, and the second pixel value; wherein the first pixel value is used for the pixel value of each pixel in the blurring area in the first direction in the preset coordinate system, and the second pixel value is used to represent the pixel value of each pixel in the blurring area in the second direction in the preset coordinate system.
[0081] In this implementation scenario, calculating the Alpha value of the pixel in the blurred area according to the transparency change speed of the target pixel shader, the first pixel value and the second pixel value includes: reading the EdgeFade parameter of the target pixel shader, wherein the EdgeFade parameter is used to characterize the speed of transparency change; determining the area y value of the blurred area in the uv coordinate, and reading the pixel y value of each pixel in the blurred area in the uv coordinate; calculating the difference obtained by subtracting the pixel y value from the area y value; passing the difference into a preset exponential function; and using the following function to calculate the Alpha value of the corresponding pixel: Alpha = (exp2(UVSize.y-Input.UV.y)-1)*EdgeFade, exp2() is an exponential function, UVSize.y is the second pixel value, representing the component value of the blurred area in the y direction, Input.UV.y is the first pixel value, representing the value of the y component of the pixel in the uv coordinate system, and EdgeFade represents the parameter value of the second blur parameter in the formula.
[0082] Figure 4 It is a schematic diagram of the blurred area at the bottom of the embodiment of the present invention, which performs blurred mixed gradient feathering, and the bottom edge pixels have a gradual process from clear to blurred. In this implementation scenario, the blurred area at the bottom performs blurred mixed gradient feathering, and the bottom edge pixels have a gradual process from clear to blurred. Alpha transparency calculation of related colors: the y component of the length and width of the blurred area UV size, UVSize.y minus the y component of the UV coordinate of the pixel is passed as a parameter to the exponential function, such as the exponential function exp2 with base 2, the value calculated by the exponential function is subtracted by 1, and the resulting value is multiplied by the transparency change speed parameter EdgeFade, and the final value is limited to between 0 and 1, such as using the saturate function to limit the value range.
[0083] Alpha calculation algorithm related to SLATE_BLUR_DOWNDFADE macro: return float4(OutColor.rgb,saturate((exp2(UVSize.y-Input.UV.y)-1)*EdgeFade)).
[0084] In an implementation scenario, when the blurring form is a blurred blending gradient feathering around the edges of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate.
[0085] In this implementation scenario, according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate, calculating the Alpha value of the pixel in the blurred area includes: reading the EdgeFade parameter of the target pixel shader, wherein the EdgeFade parameter is used to characterize the speed of transparency change; determining the regional UV value of the blurred area at the UV coordinate, and reading the pixel UV value of each pixel in the blurred area at the UV coordinate; using the following formula to calculate the intermediate vector = Input.UV*(UVSize-Input.UV), wherein UVSize is the area uv value, Input.UV is the pixel uv value; extract the first x component and the first y component of the intermediate vector, and extract the second x component of the area uv value; use the following formula to calculate the Alpha value of the corresponding pixel: Alpha = Mask2.x*Mask2.y*EdgeFade / UVSize.x; where Mask2.x is the first x component of the intermediate vector, Mask2.y is the first y component of the intermediate vector, UVSize.x is the second x component, representing the component value of the blurred area in the x direction, and EdgeFade in the formula represents the parameter value of the second blur parameter.
[0086] The intermediate vector is a vector type of two dimensions or more, and can be a two-dimensional floating-point vector, represented by the parameter float2Mask2.
[0087] Figure 5 It is a schematic diagram of blurring and blending the edge pixels around the blurred area according to an embodiment of the present invention. In this implementation scenario, blurring and blending the edge pixels around the blurred area are subjected to gradual feathering, and the Alpha transparency of the related colors is calculated: the intermediate vector (such as a two-dimensional floating point vector Mask2Mask2) is calculated, the UV size of the blurred area of the pixel, i.e., the length and width UVSize minus the UV value of the pixel, the difference is multiplied by the UV value of the pixel, and the resulting value is named Mask2; the x component of Mask2 is multiplied by the y component of Mask2, multiplied by the transparency change speed parameter EdgeFade, and the resulting value is divided by the x component of UVSize UVSize.x, and the final calculated value is used as the Alpha transparency value of the color.
[0088] Alpha calculation algorithm related to SLATE_BLUR_AROUNDFADE macro: float2 Mask2 = Input.UV*(UVSize-Input.UV);
[0089] return float4(OutColor.rgb,Mask2.x*Mask2.y*EdgeFade / UVSize.x).
[0090] In an implementation scenario, when the blurring form is a blurred blending gradient feathering in the central area of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the intermediate value according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate; and using the intermediate value to calculate the Alpha value of the pixels in the blurred area.
[0091] In this implementation scenario, according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate, calculating the intermediate value includes: reading the EdgeFade parameter of the target pixel shader, wherein the EdgeFade parameter is used to characterize the speed of transparency change; determining the regional UV value of the blurred area at the UV coordinate, and reading the pixel UV value of each pixel in the blurred area at the UV coordinate; and using the following formula to calculate the intermediate vector = Input.UV*(UVSize-Input.UV), wherein UVSize is the regional UV value and Input.UV is the pixel UV value. The intermediate value is the intermediate vector, and using the intermediate value to calculate the Alpha value of the pixel in the blurred area includes: extracting the first x component and the first y component of the intermediate vector, and extracting the second x component of the area UV value; using the following formula to calculate the Alpha value of the corresponding pixel: Alpha = 1-(Mask2.x*Mask2.y*EdgeFade / UVSize.x); wherein, Mask2.x is the first x component of the intermediate vector, Mask2.y is the first y component of the intermediate vector, UVSize.x is the second x component, representing the component value of the blurred area in the x direction, and EdgeFade in the formula represents the parameter value of the second blur parameter.
[0092] The intermediate vector is a vector type of two dimensions or more, and can be a two-dimensional floating-point vector, represented by the parameter float2Mask2.
[0093] Figure 6 This is a schematic diagram of the embodiment of the present invention in which the center of the blurred area is subjected to fuzzy blending and gradual feathering, and the center is clear and the surroundings are blurred. In this implementation scenario, the center of the blurred area is subjected to fuzzy blending and gradual feathering, and the surroundings are blurred. The intermediate vector (such as a two-dimensional floating point vector Mask2 Mask2) is calculated by subtracting the Alpha transparency value calculated by the fourth method (implementation scenario in which the edge pixels around the blurred area are subjected to fuzzy blending and gradual feathering) mentioned above from 1.
[0094] Alpha calculation algorithm related to SLATE_BLUR_AROUNDFADE_INV macro: float2 Mask2 = Input.UV*(UVSize-Input.UV);
[0095] float Alph=1-(Mask2.x*Mask2.y*EdgeFade / UVSize.x);
[0096] return float4(OutColor.rgb,Alph).
[0097] By adopting the solution of this embodiment, the edge pixels where the UMG blurred control area and the background touch are feathered, and the foreground color and the background color are mixed according to the Alpha transparency of the colors. The speed of the blending gradient, that is, the speed of the change of the Alpha transparency value from 0 to 1, can be parameterized and adjusted; the regional shape of the regional blurred feathering can be parameterized and adjusted.
[0098] By adopting the solution of this embodiment, the shape of the blurred area is adjusted, and the edge pixels where the foreground image and the background image in the blurred area are in contact are mixed in color to achieve a feathering effect, thereby avoiding the contact edge pixels between the foreground image and the background image in the blurred area being too abrupt.
[0099] Figure 7 It is a flowchart of feathering rendering in a rendering channel in an embodiment of the present invention. The blur parameters include a first blur parameter EFadeType and a second blur parameter EdgeSharp. The process includes: determining a Pixelshader corresponding to the EFadeType type; obtaining the EdgeSharp value of the Pixelshader; calculating a color value by Gaussian blur; calculating an Alpha value of the color according to the EFadeType type; and rendering pixels in the blur area based on the color value and the Alpha value.
[0100] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0101] Example 2
[0102] In this embodiment, a fuzzy area feathering device is also provided to implement the above-mentioned embodiments and preferred embodiments, which have been described and will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0103] Figure 8 is a structural block diagram of a fuzzy region feathering device according to an embodiment of the present invention. Figure 8 As shown, the device includes: a setting module 80, a processing module 82, and a rendering module 84, wherein:
[0104] A setting module 80 is used to obtain a blur parameter of the blur area, wherein the blur parameter is used to indicate a blur effect of the blur area;
[0105] A processing module 82, used for loading a foreground image and a background image, and determining a blurred area according to an overlapping area of the foreground image and the background image;
[0106] The rendering module 84 is used to perform feathering rendering on the blurred area using the blurred parameters.
[0107] Optionally, the device also includes: a configuration module, used to configure a first fuzzy parameter and / or a second fuzzy parameter in the editor before the acquisition module acquires the fuzzy parameters of the fuzzy area, the first fuzzy parameter being used to indicate the fuzzy shape of the fuzzy area, and the second fuzzy parameter being used to indicate the color mixing gradient speed of the fuzzy area; a storage module, used to store the first fuzzy parameter and / or the second fuzzy parameter in the parameter structure of the fuzzy area.
[0108] Optionally, the configuration module includes: a first configuration unit, used to configure a first fuzzy parameter in an enumeration type variable of the post-processing data structure of the editor; and / or, a second configuration unit, used to configure a second fuzzy parameter in a floating point type variable of the post-processing data structure of the editor.
[0109] Optionally, the blur parameters include the first blur parameters and the second blur parameters, and the rendering module includes: a construction unit, used to construct a matching pixel shader template according to the first blur parameters, wherein the first blur parameters are used to indicate the blur shape of the blur area, and the second blur parameters are used to indicate the color mixing gradient speed of the blur area; a configuration unit, used to configure the pixel shader template using the second blur parameters to obtain a target pixel shader; and a rendering unit, used to drive the target pixel shader to perform feathering rendering on the colors within the blur area to obtain a blurred image of the blur area.
[0110] Optionally, the rendering unit includes: a first calculation subunit, used to drive the Gaussian blur function of the target pixel shader to mix and calculate the pixel colors of the background image and the foreground image to obtain the color values of the pixels within the blurred area; a second calculation subunit, used to drive the target pixel shader to calculate the Alpha value of the pixels within the blurred area, wherein the Alpha value is used to indicate the transparency of the color; and a first rendering subunit, used to render the pixels within the blurred area based on the color value and the Alpha value.
[0111] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, the second calculation sub-unit is also used to calculate the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the first pixel value of each pixel in the blurred area in the first direction in a preset coordinate system.
[0112] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, the second calculation sub-unit is also used to calculate the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the first pixel value of each pixel in the blurred area in the first direction in a preset coordinate system.
[0113] Optionally, when the blur form is a blurred blended gradient feathering around the edges of the blurred area, the second calculation subunit is also used to calculate the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate.
[0114] Optionally, when the blur form is a blurred mixed gradient feathering in the central area of the blurred area, the second calculation subunit is also used to: calculate the intermediate value according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate; and use the intermediate value to calculate the Alpha value of the pixel in the blurred area.
[0115] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0116] Example 3
[0117] The present application also provides an electronic device, Fig. 9 is a structural diagram of an electronic device according to an embodiment of the present invention, such as Fig. 9As shown, it includes a processor 91, a communication interface 92, a memory 93 and a communication bus 94, wherein the processor 91, the communication interface 92, and the memory 93 communicate with each other through the communication bus 94, and the memory 93 is used to store computer programs;
[0118] The processor 91, when used to execute the program stored in the memory 93, implements the following steps: obtaining blur parameters of the blurred area, wherein the blur parameters are used to indicate the blur effect of the blurred area; loading the foreground image and the background image, and determining the blurred area according to the overlapping area of the foreground image and the background image; and feathering the blurred area using the blur parameters.
[0119] Optionally, before the step of obtaining the fuzzy parameters of the blurred area, the method further includes: in response to a configuration request triggered by the user interface of the editor, configuring a first fuzzy parameter and / or a second fuzzy parameter in the editor, the first fuzzy parameter being used to indicate the blur shape of the blurred area, and the second fuzzy parameter being used to indicate the color mixing gradient speed of the blurred area; storing the first fuzzy parameter and / or the second fuzzy parameter in the parameter structure of the blurred area.
[0120] Optionally, configuring the first fuzzy parameter in the editor includes: configuring the first fuzzy parameter in an enumeration type variable of the post-processing data structure of the editor; and / or, configuring the second fuzzy parameter in the editor includes: configuring the second fuzzy parameter in a floating point type variable of the post-processing data structure of the editor.
[0121] Optionally, the blur parameters include the first blur parameter and the second blur parameter, and using the blur parameters to perform feathering rendering on the blurred area includes: constructing a matching pixel shader template based on the first blur parameter, wherein the first blur parameter is used to indicate the blur shape of the blurred area, and the second blur parameter is used to indicate the color mixing gradient speed of the blurred area; using the second blur parameter to configure the pixel shader template to obtain a target pixel shader; driving the target pixel shader to perform feathering rendering on the colors within the blurred area to obtain a blurred image of the blurred area.
[0122] Optionally, driving the target pixel shader to perform feathering rendering on the colors within the blurred area includes: driving the Gaussian blur function of the target pixel shader to mix and calculate the pixel colors of the background image and the foreground image to obtain the color values of the pixels within the blurred area; driving the target pixel shader to calculate the Alpha values of the pixels within the blurred area, wherein the Alpha value is used to indicate the transparency of the color; and rendering the pixels within the blurred area based on the color value and the Alpha value.
[0123] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the first pixel value of each pixel in the blurred area in the first direction in a preset coordinate system.
[0124] Optionally, when the blur form is a blurred blended gradient feathering on one side of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader, the first pixel value and the second pixel value; wherein the first pixel value is used for the pixel value of each pixel in the blurred area in a first direction in a preset coordinate system, and the second pixel value is used to represent the pixel value of each pixel in the blurred area in a second direction in the preset coordinate system.
[0125] Optionally, when the blur form is a blurred blended gradient feathering around the edges of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the Alpha value of the pixels in the blurred area according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate.
[0126] Optionally, when the blur form is a blurred blended gradient feathering in the central area of the blurred area, driving the target pixel shader to calculate the Alpha value of the pixels in the blurred area includes: calculating the intermediate value according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate; and using the intermediate value to calculate the Alpha value of the pixels in the blurred area.
[0127] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0128] The communication interface is used for communication between the above terminal and other devices.
[0129] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0130] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0131] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the blurred area feathering method described in any of the above embodiments.
[0132] In another embodiment provided in the present application, a computer program product including instructions is also provided. When the computer program product is run on a computer, the computer executes the blurred area feathering method described in any one of the above embodiments.
[0133] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0134] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0135] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0136] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0137] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0138] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0139] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0140] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for feathering a fuzzy area, characterized in that: include: Obtaining a blur parameter of the blur area, wherein the blur parameter is used to indicate a blur effect of the blur area; Loading a foreground image and a background image, and determining a blurred area according to an overlapping area of the foreground image and the background image; The blur parameter is used to perform feathering rendering on the blur area.
2. The method according to claim 1, characterized in that Before the step of obtaining the fuzzy parameters of the fuzzy area, the method further includes: In response to a configuration request triggered by a user interface of an editor, a first fuzzy parameter and / or a second fuzzy parameter is configured in the editor, wherein the first fuzzy parameter is used to indicate a fuzzy form of a fuzzy area, and the second fuzzy parameter is used to indicate a color mixing gradient speed of the fuzzy area; The first fuzzy parameter and / or the second fuzzy parameter are stored in a parameter structure of the fuzzy region.
3. The method according to claim 2, characterized in that Configuring the first fuzzy parameter in the editor includes: configuring the first fuzzy parameter in an enumeration type variable of a post-processing data structure of the editor; and / or, Configuring the second fuzzy parameter in the editor includes: configuring the second fuzzy parameter in a floating point type variable of a post-processing data structure of the editor.
4. The method according to claim 1, characterized in that The blur parameters include a first blur parameter and a second blur parameter, and feathering the blur area using the blur parameters includes: Constructing a matching pixel shader template according to a first blur parameter, wherein the first blur parameter is used to indicate a blur shape of a blur region, and the second blur parameter is used to indicate a color mixing gradient speed of the blur region; The pixel shader template is configured using the second blur parameter to obtain a target pixel shader; The target pixel shader is driven to perform feathering rendering on the color in the fuzzy area to obtain a fuzzy image of the fuzzy area.
5. The method according to claim 4, characterized in that Driving the target pixel shader to perform feathering rendering on the color in the blurred area includes: The Gaussian blur function of the target pixel shader is driven to mix and calculate the pixel colors of the background image and the foreground image to obtain the color values of the pixels in the blurred area; Driving the target pixel shader to calculate the Alpha value of the pixel in the blurred area, wherein the Alpha value is used to indicate the transparency of the color; Pixels within the blurred area are rendered based on the color value and the alpha value.
6. The method according to claim 5, characterized in that In the case where the blurring form is blur blending gradient feathering on one side of the blurring area, driving the target pixel shader to calculate the alpha value of the pixel in the blurring area includes: The Alpha values of the pixels in the blurred area are calculated according to the transparency change speed of the target pixel shader and the first pixel values of each pixel in the blurred area in the first direction in a preset coordinate system.
7. The method according to claim 5, characterized in that In the case where the blurring form is blur blending gradient feathering on one side of the blurring area, driving the target pixel shader to calculate the alpha value of the pixel in the blurring area includes: The Alpha values of the pixels in the blurred area are calculated according to the transparency change speed of the target pixel shader, the first pixel value and the second pixel value; wherein the first pixel value is used for the pixel value of each pixel in the blurred area in the first direction in the preset coordinate system, and the second pixel value is used to represent the pixel value of each pixel in the blurred area in the second direction in the preset coordinate system.
8. The method according to claim 5, characterized in that In the case where the blurring form is to perform blur blending gradient feathering on the edges around the blurring area, driving the target pixel shader to calculate the alpha value of the pixel in the blurring area includes: The Alpha value of the pixel in the blurred area is calculated according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the blurred area at the UV coordinate.
9. The method according to claim 5, characterized in that In the case where the blurring form is to perform blur blending gradient feathering in the central area of the blurring area, driving the target pixel shader to calculate the alpha value of the pixel in the blurring area includes: Calculate the intermediate value according to the transparency change speed of the target pixel shader and the pixel UV value of each pixel in the fuzzy area at the UV coordinate; The intermediate value is used to calculate the Alpha value of the pixels in the blurred area.
10. A fuzzy area feathering device, characterized in that: include: A setting module, used for obtaining blur parameters of the blur area, wherein the blur parameters are used for indicating blur effects of the blur area; A processing module, used for loading a foreground image and a background image, and determining a fuzzy area according to an overlapping area of the foreground image and the background image; A rendering module is used to perform feathering rendering on the blurred area using the blurred parameters.
11. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 9 when executed.
12. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 9.