Image processing method and device, storage medium and electronic equipment
By acquiring and processing screen UV information and normal and light and dark information of the target model, and adjusting the display parameters of the special effect identification, the problem that the prior art cannot realize the simulated comic printing effect in the real-time rendering engine, and efficient image processing is achieved.
Patent Information
- Application Number
- CN202411533321.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-11
AI Technical Summary
Existing image processing methods cannot achieve simulated comic printing effects in real-time rendering engines for games or real-time interactive related content, resulting in poor image processing efficiency.
By obtaining the screen UV information of the target image to be rendered, the initial pixel value of the special effect identification is determined, and the display parameters of the special effect identification are adjusted according to the normal information and light and dark information of the target model to generate a target image with a comic printing effect.
It realizes the real-time rendering of images that simulates comic printing effects in the real-time rendering engine, improving image processing efficiency.
Smart Images

Figure CN119417966A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image processing method, device, storage medium and electronic device. Background Art
[0002] With the rapid development of life and technology, people often use game applications for entertainment. In game development, it is often necessary to simulate comic printing effects to process image screens so that the images have comic printing effects. In existing image processing methods, offline rendering is generally performed first, and then textures such as dots and parallel lines that simulate comic printing effects are added to the offline rendered screen to obtain images with comic printing effects.
[0003] In the process of research and practice of existing technologies, it was found that the existing image processing method of simulating comic printing effects through offline rendering cannot achieve simulated comic printing effects in real-time rendering engines such as games and real-time interactive content, resulting in poor image processing efficiency. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, device, storage medium and electronic device, which can realize real-time rendering of an image simulating a comic printing effect in a real-time rendering engine, thereby improving image processing efficiency.
[0005] The present application provides an image processing method, including:
[0006] Get the screen UV information of the screen space corresponding to the target image to be rendered;
[0007] Based on the screen UV information, determining an initial pixel value of a special effect identifier corresponding to each screen UV coordinate of the screen space, wherein the special effect identifier is used to be added to a target model to be rendered to simulate a comic printing effect;
[0008] Calculating target brightness and darkness information of the target model according to normal information of the target model to be rendered;
[0009] Adjusting the initial pixel value of the special effect identifier corresponding to the target model based on the target brightness information to obtain a first target pixel value of the special effect identifier corresponding to the screen UV coordinate;
[0010] A target image with a comic printing effect corresponding to the target model is generated according to the first target pixel value.
[0011] Accordingly, an embodiment of the present application provides an image processing device, including:
[0012] An acquisition unit, used for acquiring screen UV information of a screen space corresponding to a target image to be rendered;
[0013] a determining unit, configured to determine, based on the screen UV information, an initial pixel value of a special effect identifier corresponding to each screen UV coordinate of the screen space, wherein the special effect identifier is used to be added to a target model to be rendered to simulate a comic printing effect;
[0014] A calculation unit, used for calculating target brightness and darkness information of the target model to be rendered according to normal information of the target model;
[0015] an adjusting unit, configured to adjust an initial pixel value of the special effect identifier corresponding to the target model based on the target brightness information, so as to obtain a first target pixel value of the special effect identifier corresponding to the screen UV coordinate;
[0016] A generating unit is used to generate a target image with a comic printing effect corresponding to the target model according to the first target pixel value.
[0017] In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program is suitable for loading by a processor to execute the steps in any image processing method provided in the embodiment of the present application.
[0018] In addition, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the image processing method provided in the embodiment of the present application.
[0019] An embodiment of the present application also provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps in the image processing method provided in the embodiment of the present application.
[0020] The embodiment of the present application obtains the screen UV information of the screen space corresponding to the target image to be rendered; based on the screen UV information, determines the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space, and the special effect identifier is used to be added to the target model to be rendered to simulate the comic printing effect; according to the normal information of the target model to be rendered, calculates the target light and dark information of the target model; based on the target light and dark information, adjusts the initial pixel value of the special effect identifier corresponding to the target model to obtain the first target pixel value of the special effect identifier corresponding to the screen UV coordinate; generates the target image with the comic printing effect corresponding to the target model according to the first target pixel value. In this way, by calculating the initial pixel value of the special effect identifier to be mixed into the target model according to the screen UV information of the screen space corresponding to the target image to be rendered, the display parameters of the special effect identifier corresponding to the target model to be rendered are adjusted according to the target light and dark information of the target model to be rendered, and the first target pixel value corresponding to the screen UV coordinate of the adjusted special effect identifier is obtained, so that the target image with the simulated comic printing effect corresponding to the target model is generated according to the first target pixel value, so as to achieve real-time rendering of the image simulating the comic printing effect in the real-time rendering engine, thereby improving the image processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 It is a schematic diagram of an implementation scenario of an image processing method provided in an embodiment of the present application;
[0023] Figure 2 It is a flowchart of an image processing method provided in an embodiment of the present application;
[0024] Figure 3a is an image processing schematic diagram of an image processing method provided by an embodiment of the present application;
[0025] Figure 3b It is a material node schematic diagram of an image processing method provided in an embodiment of the present application;
[0026] Figure 3c is another image processing schematic diagram of an image processing method provided by an embodiment of the present application;
[0027] Figure 3d is another image processing schematic diagram of an image processing method provided in an embodiment of the present application;
[0028] Figure 3e is a light and dark schematic diagram of an image processing method provided in an embodiment of the present application;
[0029] Figure 3f It is a schematic diagram of adjusting a special effect mark of an image processing method provided in an embodiment of the present application;
[0030] Figure 4a is a schematic diagram of a target image of an image processing method provided in an embodiment of the present application;
[0031] Figure 4b is another target image schematic diagram of an image processing method provided by an embodiment of the present application;
[0032] Figure 5 is a schematic diagram of the structure of an image processing device provided in an embodiment of the present application;
[0033] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0035] The embodiments of the present application provide an image processing method, device, storage medium and electronic device. The image processing device can be integrated in an electronic device, which can be a server or a terminal.
[0036] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals may include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Terminals and servers can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.
[0037] See also Figure 1 , taking the image processing device integrated into an electronic device as an example, Figure 1A schematic diagram of an implementation scenario of the image processing method provided in an embodiment of the present application, wherein the electronic device may be a server or a terminal, and the electronic device may obtain screen UV information of a screen space corresponding to a target image to be rendered; based on the screen UV information, determine an initial pixel value of a special effect identifier corresponding to each screen UV coordinate of the screen space, the special effect identifier being used to be added to a target model to be rendered to simulate a comic printing effect; calculate target light and dark information of the target model according to normal information of the target model to be rendered; adjust the initial pixel value of the special effect identifier corresponding to the target model based on the target light and dark information, and obtain a first target pixel value of the special effect identifier corresponding to the screen UV coordinate; and generate a target image with a comic printing effect corresponding to the target model according to the first target pixel value.
[0038] It should be noted that Figure 1 The implementation environment scenario diagram of the image processing method shown is only an example. The implementation environment scenario of the image processing method described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0039] The solutions provided by the embodiments of the present application are specifically described by the following embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0040] This embodiment will be described from the perspective of an image processing device. The image processing device may be integrated into an electronic device. The electronic device may be a terminal and / or a server, and this application does not limit this.
[0041] See also Figure 2 , Figure 2 : is a flow chart of an image processing method provided in an embodiment of the present application. The image processing method comprises:
[0042] In step 101, screen UV information of a screen space corresponding to a target image to be rendered is obtained.
[0043] Among them, the screen space can be the display area of the rendered picture on the screen. It is a two-dimensional coordinate system used to describe the position and size of the rendered picture. In the screen space, the coordinate origin is usually located in the upper left corner of the screen, the u axis extends to the right, and the v axis extends downward. The screen space is the final stage of the rendering pipeline, mapping the vertices in the clipping space to the two-dimensional screen to generate the final pixel color. The screen UV information can be information containing the screen UV of the screen space, which can be used to draw special effect patterns in the screen space. The screen UV can be a UV coordinate system in the screen space, which is used for texture sampling and effect rendering on the screen. The screen UV information can include the screen UV coordinates of the screen space, and the screen UV coordinates can be the UV coordinates under the screen UV of the screen space. The value range of the screen UV coordinates on the U coordinate axis and the V coordinate axis can be [0, 1].
[0044] Among them, the screen UV information of the screen space is obtained, which can be used to superimpose special effect patterns such as the dots in the model rendering result. Optionally, in order to ensure that the screen ratio does not affect the screen UV result, the screen UV can be scaled and calculated according to the aspect ratio of the viewport size (ViewSize) of the actual displayed picture to obtain the screen UV information that is not affected by the viewport size, so as to superimpose special effect patterns on the model rendering result based on the screen UV information, so that the superimposed special effect patterns are not affected by different picture ratios and can be correctly superimposed on the picture to be displayed, thereby improving the image processing effect.
[0045] There are many ways to obtain the screen UV information of the screen space corresponding to the target image to be rendered. For example, the viewport UV information and the viewport size of the screen space corresponding to the target image to be rendered can be obtained, the viewport UV information can be translated so that the origin in the viewport UV information is moved to the center of the viewport screen to obtain the first viewport UV information, the first viewport UV information can be scaled according to the viewport size to obtain the second viewport UV information, the origin position of the second viewport UV information can be restored to obtain the screen UV information of the screen space.
[0046] The viewport UV information (ViewPortUV) may be the UV coordinates of the pixel being rendered in the screen space, and the range may be [0,1]. The viewport size (ViewSize) may be the aspect ratio of the viewport, and the viewport (ViewPort) may be the screen area that displays the rendering result.
[0047] In a specific embodiment, the screen UV information of the screen space can be calculated using the following formula:
[0048] (((ViewportUV-0.5)*2)*(1,ViewSize.v / ViewSize.u)+1)*0.5
[0049] Among them, the viewport UV information ViewportUV and the viewport size ViewSize of the screen space can be obtained. ViewSize can include ViewSize.v and ViewSize.u. ViewSize.v can be expressed as the height of the viewport on the V axis, and ViewSize.u can be expressed as the width of the viewport on the U axis. Therefore, the viewport UV information ViewportUV can be translated by 0.5 to move the origin in the viewport UV information to the center of the viewport screen, and the first viewport UV information (ViewportUV-0.5) can be obtained, so that the first viewport UV information can be scaled according to the viewport size. For example, the first viewport UV information can be multiplied by 2 to convert the ViewportUV coordinates from the [0,1] range to the [-1,1] range, and then multiplied by the viewport aspect ratio ViewSize.v / ViewSize.u according to the viewport size ViewSize to ensure the conversion The converted UV coordinates correctly reflect the actual size of the viewport in the vertical direction, thereby obtaining the second viewport UV information. Then, one is added to the second viewport UV information to convert the UV coordinate range from [-1, 1] back to [0, 2], and then multiplied by 0.5 to achieve the scaling of the UV coordinate range from [0, 2] to [0, 1] in consideration of the aspect ratio of the viewport, and then the origin position of the second viewport UV information is restored to obtain the screen UV information of the screen space that is not affected by the aspect ratio of the screen, thereby completing the conversion of the UV coordinates in the viewport into a new UV coordinate that takes into account the aspect ratio of the viewport, namely, the screen UV information.
[0050] In step 102, based on the screen UV information, the initial pixel value of the special effect identifier corresponding to each screen UV coordinate in the screen space is determined.
[0051] Among them, the special effect identifier can be an identifier used to be added to the target model to be rendered to simulate the comic printing effect. For example, the special effect identifier can be a special effect pattern used to simulate the comic printing effect, for example, it can be a pattern of shapes such as dots, parallel lines and textures. The initial pixel value can be the pixel value corresponding to each screen UV coordinate of multiple special effect identifiers calculated according to the screen UV information. The pixel value can be information describing the brightness or color intensity of each pixel in the digital image, and can include parameters such as color, brightness, depth corresponding to the pixel. Optionally, the pixel value can be the color value corresponding to the pixel, that is, the channel value of the color channel contained in the pixel. The special effect identifier is used to be added to the target model currently being rendered to simulate the effect of comic printing. The target model can be a three-dimensional model to which the comic printing effect is to be added, and can be at least one of a character model and a scene model.
[0052] Ben Day dots come from the Ben Day printing process, which is a printing and photoengraving technology that uses fine ink patterns to print gray areas or (four-color printing) various colors on paper. The process is usually described by Ben Day dots, but other shapes, such as parallel lines or textures, can also be used. Ben Day dots are used intentionally, usually to remind people of their use in color comics. Therefore, in order to render an image with a comic printing effect corresponding to the target model, the embodiment of the present application calculates the pixel value corresponding to the special effect identifier, which is used to mix with the pixel value of the target model in the subsequent rendering pipeline, so as to obtain an image with special effect identifiers such as Ben Day dots superimposed on the target model, that is, an image corresponding to the target model that simulates the comic printing effect is obtained.
[0053] In the process of rendering the target model, in the pixel shader stage, the pixel value of the target model corresponding to each screen UV coordinate and the pixel value of the special effect logo corresponding to each screen UV coordinate in the rendered picture of each frame are calculated, so that in the output merge stage (Output Merger), various pixel values corresponding to each screen UV coordinate outputted in the previous stage (i.e., the pixel shader stage) are mixed, and the final color used for display is outputted in combination with the depth information of each pixel, thereby displaying the rendered picture of the target model superimposed with the special effect logo, i.e., obtaining an image with a comic printing effect corresponding to the target model.
[0054] Since the initial pixel value of the special effect logo is calculated by the screen UV information, the target model also calculates the pixel value displayed on the screen based on the screen UV information. Therefore, by mixing the pixel value corresponding to the calculated special effect logo and the pixel value of the calculated target model, a picture with the special effect logo superimposed on the rendering result of the target model can be obtained, thereby obtaining an image corresponding to the target model that simulates the comic printing effect.
[0055] Among them, there can be multiple ways to determine the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space based on the screen UV information, for example, determining the display parameters; calculating the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space based on the display parameters and the screen UV information through a preset gradient function.
[0056] The display parameter may be a parameter for determining the display style of the special effect logo to be generated, and the display style may include parameters such as the radius, width, density or transparency of the special effect logo. For example, the display parameter may include the number of special effect logos to be generated and the display size, and the display size may include information such as the radius and width of the special effect logo. Based on the initial pixel value, a special effect logo matching the number and display size indicated by the display parameter may be generated in the screen space. The preset gradient function can be a function that performs calculations based on the input display parameters and screen UV information to obtain the initial pixel value corresponding to each screen UV coordinate. For example, when the special effect identifier is a circular Ben Dai point, the preset gradient function can be an exponential radial gradient function (RadialGradientExponential) provided in Unreal Engine (UE). The exponential radial gradient function can use the position of the UV channel origin to generate a radial gradient and output a gradient value of 0-1. For example, the value at the origin (0, 0) of the UV coordinate is 0, and the value at the UV coordinate (1, 1) is 1. At the same time, the user can adjust the radius and offset center point to calculate the initial pixel value corresponding to the circular special effect identifier. When the special effect identifier is a special effect line of the parallel line type, the preset gradient function can be a line drawing function (LinearGradient) to calculate the initial pixel value corresponding to the special effect identifier of the parallel line type.
[0057] There are many ways to determine the display parameters. For example, when the special effect logo is a circular point, the display parameters can be determined by obtaining the size control parameters and the density parameters. The size control parameters can be used to determine the display size of the special effect logo to be generated, and the density parameters are used to control the number of special effect logos to be generated. In this way, based on the screen UV coordinates, size control parameters and density parameters in the screen UV information, the input of the preset gradient function is determined, so as to obtain the initial pixel value of the special effect logo corresponding to each screen UV coordinate in the screen space based on the preset gradient function.
[0058] There are multiple ways to calculate the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space based on the preset gradient function, display parameters and screen UV information. For example, when the special effect identifier is a circular special effect identifier, the display size can be the radius of the special effect identifier. Therefore, assuming that the number of special effect identifiers to be generated is 1, the screen UV information can be translated so that the origin in the translated screen UV information is moved to the center position of the screen UV information before the translation, so that the translated screen UV information is input into the preset gradient function, so that the preset gradient function can output a value that gradually changes from the center point of the screen UV to the surrounding areas, that is, the value of the UV coordinate located at the center point is 0 and gradually changes radially, and based on the radius determined by the input size control parameter, the gradient function can output the value corresponding to the screen UV coordinate in the circular area formed by the center point to the radius as 0, and the value corresponding to the screen UV coordinate outside the circular area as 1, so that the value corresponding to each screen UV coordinate can be output as the value of the color channel to obtain the initial pixel value of the special effect identifier corresponding to each screen UV coordinate. Among them, the pixel value of 1 corresponds to white, and the pixel value of 0 corresponds to black. Therefore, based on the initial pixel value, a picture with a black circular area in the middle and white surroundings can be generated, that is, the drawn special effect logo.
[0059] Correspondingly, when there are multiple special effect logos to be generated, in order to realize the drawing of multiple special effect logos in the screen space, the screen UV information after translation can be expanded based on the density parameter, and the decimal part of each UV coordinate in the expanded screen UV information is taken, so as to obtain multiple UV coordinates in the range of 0-1, and then based on the multiple UV coordinates in the range of 0-1 and the size control parameters input into the preset gradient function, the initial pixel values of multiple special effect logos corresponding to the same number as indicated by the density parameter on each screen UV coordinate of the screen space can be obtained.
[0060] The density parameter may be a parameter for expanding the screen UV information, and may be determined according to the number of special effect markers to be drawn. The larger the value of the density parameter, the greater the density of the generated special effect markers, that is, the more special effect markers are generated. For example, assuming that 10 circles need to be drawn based on a set of screen UV information, the density parameter may be 10, so that the UV coordinate range of the screen UV information may be converted from [0,1] to [0,10]. The target UV coordinate may be the value of the decimal part extracted from the expanded screen UV information. For example, assuming that the density parameter is 10, the target UV coordinate may be 10 UV coordinates in the range of [0,1] from 0 to 10.
[0061] In a specific embodiment, the following code can be used to calculate the circle to be drawn in the screen space based on the screen UV information, that is, the special effect mark of the point type, so that the initial pixel value of the special effect mark on each screen UV coordinate can be output:
[0062] real DrawDisc(real2 uv,real scale) / / Input screen UV information (uv) and size control parameters (scale)
[0063] {
[0064] uv=uv-real2(0.5,0.5); / / u-0.5, v-0.5 moves the screen UV coordinate system to the center
[0065] real sdf = length (uv); / / Calculate the length of screen UV information (sdf)
[0066] return step(sdf,scale); / / Limit the color value of each position on the screen UV according to the size control parameter to obtain a circle
[0067] }
[0068] For example, see Figure 3a , Figure 3a This is an image processing schematic diagram of an image processing method provided in an embodiment of the present application. Based on a set of screen UV information, a circle can be drawn according to the above method, so that the screen UV information can be expanded according to the density parameter, so that a plurality of circular special effect logos can be drawn according to the UV coordinates of the decimal part in the expanded screen UV information in the range of [0,1], so that the initial pixel values of the plurality of special effect logos corresponding to each screen UV coordinate can be output.
[0069] Optionally, the size control parameter can be a spot radius control variable (Spot Size), the density parameter can be determined by a spot density function, and the density control can also be obtained by calculating a decimal function (Frac, which can be used to output the decimal part of a parameter, and the output range is [0,1]). Combined with the spot radius control variable and the exponential radial gradient function provided in the Unreal Engine, the initial pixel value of the special effect marker corresponding to each screen UV coordinate in the screen space can be output.
[0070] For example, see Figure 3b , Figure 3bIt is a material node schematic diagram of an image processing method provided in an embodiment of the present application. The screen UV information input based on the screen UV node (ScreenUV) and the density parameter (for example, 10) determined by the wave spot density node can be obtained, so that the result of multiplying the screen UV information and the density parameter can be calculated through the multiplication node (Multiply), and then the decimal part of each UV coordinate in the expanded screen UV information is taken through the Frac function node to obtain multiple UV coordinates in the [0,1] range, and the multiple UV coordinates in the [0,1] range are input into the coordinate input interface (UVs) of the exponential radial gradient function RadialGradientExponential node, and the size control parameter is obtained through the spot radius control variable (Spot Size) node to determine the display size of the circle to be drawn, so that the size control parameter can be input into the radius input interface (Radius) of the RadialGradientExponential node, so that the initial pixel value of the special effect identifier corresponding to each screen UV coordinate in the screen space can be output through the result output interface (RadialGradientExponential) of the RadialGradientExponential node.
[0071] Optionally, when the special effect mark is a special effect line in the form of parallel lines, the line drawing function (LinearGradient) can be used to draw the line in the same way as the calculation method of the special effect mark in the form of a point, and the calculation method of other parts can be similar to the drawing method of the point. For example, the line drawing method is as follows:
[0072] real DrawLine(real2 uv,real width) / / Input screen UV information and size control parameters (width, used to control the width of the line)
[0073] {
[0074] return step(uv.u,width); / / Use the 0-1 value of the u axis in the screen UV information to directly perform binary processing to obtain two black and white lines
[0075] }
[0076] For example, see Figure 3c , Figure 3c This is another image processing schematic diagram of an image processing method provided in an embodiment of the present application. Through the above method, two black and white lines can be obtained according to the input screen UV information and size control parameters.
[0077] Therefore, in order to use special effect lines to simulate the comic printing effect, it is necessary to repeatedly draw multiple parallel lines. The method of drawing multiple lines can be similar to the method of drawing multiple base points mentioned above. The input screen UV information is multiplied by the density parameter, and then the Frac function is calculated to obtain the decimal part of the controlled screen UV information to obtain a repeated UV coordinate, and then the 0-1 value of the u axis in each repeated UV coordinate is binarized to obtain black and white lines, so that multiple lines can be obtained. For example, please refer to Figure 3d , Figure 3d This is another image processing schematic diagram of an image processing method provided in an embodiment of the present application. The pixel values corresponding to multiple special effect lines can be calculated based on the expanded screen UV information.
[0078] In one embodiment, there are multiple ways to determine the initial pixel value of the special effect mark on each screen UV coordinate of the screen space based on the screen UV information. For example, a pre-drawn special effect map can be directly used, so that the special effect map can be sampled through the screen UV information to obtain the initial pixel value of the special effect mark on each screen UV coordinate of the screen space. Among them, the initial pixel value corresponding to each screen UV coordinate can be the pixel value sampled in the special effect map according to each screen UV coordinate. The special effect map can display multiple special effect marks according to actual needs. For example, when 20 circular Ben Dai points need to be generated, the special effect map can be an image with 20 circular Ben Dai points distributed.
[0079] In step 103, target brightness and shading information of the target model is calculated according to the normal information of the target model to be rendered.
[0080] The normal information may include information containing normal vectors corresponding to the target model, for example, may include vertex normal vectors (VertexNormal) of vertices of the target model, or pixel normal vectors (PixelNormal) corresponding to the target model. The target brightness information may be brightness information received by the surface of the target model to be rendered, and the brightness information may indicate the brightness of each position on the surface of the target model in the image to be rendered.
[0081] Due to the characteristics of the Ben Dai printing process, these special effect marks such as Ben Dai points or special effect lines mainly appear at the intersection of light and dark, and the size of the Ben Dai points, or the thickness or light and dark of parallel lines and other display parameters will be affected by the transition between light and dark. The specific properties that are affected can actually be affected by the art style. Therefore, in order to simulate a better and more realistic comic printing effect, the display parameter changes of the special effect marks calculated based on the screen UV coordinates can be adjusted according to the light and dark changes received by the target model surface, so as to obtain a better image with comic printing effect.
[0082] Since the comic printing effect simulated in the embodiment of the present application comes from printing, and printing is a pure plane result, special effect marks such as dots or parallel lines in the picture will not be deformed along with the surface of the target model. Therefore, the calculation of these simulated effects can be after the lighting calculation, that is, the simulation of the comic printing effect can be based on the calculation of the screen space, that is, the pixel information of the special effect mark can be calculated in the pixel shader stage, so that in the merged output stage, the pixel information of the special effect mark can be mixed with the pixel information of the target model, so that based on the mixed pixel value, the image with the comic printing effect superimposed with the special effect mark corresponding to the target model can be obtained.
[0083] Among them, there may be multiple ways to calculate the target light and shade information of the target model based on the normal information of the target model to be rendered. For example, the normal information may include the vertex normal vectors of the vertices of the target model. The preset light direction vector may be determined, the vertex normal vectors of the vertices in the target model to be rendered are obtained, and the first angle value between the light direction vector and the vertex normal vector is calculated. Based on the first angle value, the target light and shade information of each vertex of the target model in the picture to be rendered is determined.
[0084] The light direction vector may be a vector of a virtual light, and the light direction vector may be any vector. For example, a vector input by a user may be directly obtained as the light direction vector, or a virtual light may be set, and the vector of the light direction of the virtual light may be determined as the required light direction vector, etc. The first angle value may be an angle between the light direction vector and the vertex normal vector. The angle between the light direction vector and the vertex normal vector may be used to measure the lighting effect of each vertex on the surface of the target model, so as to determine the target brightness information of each vertex on the surface of the target model in the image to be rendered.
[0085] There are many ways to calculate the first angle value between the light direction vector and the vertex normal vector, and determine the target brightness information of each vertex of the target model in the to-be-rendered picture based on the first angle value. For example, the target brightness information of each vertex of the target model in the to-be-rendered picture can be calculated using the following formula:
[0086] LightChange=Saturate(Dot(LightDirection,VertexNormal))
[0087] Among them, the dot product between the light direction vector and the vertex normal vector can be calculated to obtain the first angle value between 0 and 180 degrees. When the first angle value is 0 degrees, the backlight side is black on the target model, and when the first angle value is 180 degrees, the light-facing side is white on the target model. For example, please refer to Figure 3e, Figure 3e This is a light and shade diagram of an image processing method provided by an embodiment of the present application. In the spherical model, the upper left area is the light-facing surface, and its corresponding light and shade is brighter, and the lower right area is the backlit surface, and its corresponding light and shade is darker. Then, the color adjustment function (saturate) can be used to limit the first angle value to 0-1 to obtain the target light and shade information (LightChange), so that when the first angle value corresponding to the vertex is 0°, the light and shade corresponding to the vertex is the darkest, and the corresponding target light and shade information is 0, that is, the brightness is the smallest, and when the first angle value corresponding to the vertex is 180°, the light and shade corresponding to the vertex is the brightest, and the corresponding target light and shade information is 1, that is, the brightness is the largest. In this way, the light and shade changes of the target model surface in the picture to be rendered can be determined according to the target light and shade information in the range of 0-1 corresponding to each vertex on the target model surface.
[0088] In step 104, the initial pixel value of the special effect mark corresponding to the target model is adjusted based on the target brightness information to obtain the first target pixel value of the special effect mark corresponding to the screen UV coordinate.
[0089] Among them, the first target pixel value can be the pixel value of the special effect identifier corresponding to each screen UV coordinate after the initial pixel value of the special effect identifier is adjusted based on the target brightness information, that is, the first target pixel value can be the result obtained by adjusting the initial pixel value based on the brightness changes of the target model in the picture to be rendered.
[0090] There are many ways to adjust the initial pixel value of the special effect logo corresponding to the target model based on the target light and dark information to obtain the first target pixel value of the special effect logo corresponding to the screen UV coordinate. For example, a target size range interval of the special effect logo can be obtained, and the target size range interval includes a minimum display size and a maximum display size. A mapping relationship between the light and dark information and the size range interval is obtained, and the display size value of the special effect logo corresponding to the target light and dark information is adjusted based on the mapping relationship, the target light and dark information, and the target size range interval, so as to update the initial pixel value of the special effect logo corresponding to the screen UV coordinate based on the adjusted display size value through a preset gradient function to obtain a first target pixel value, wherein the adjusted display size of the special effect logo is between the minimum display size and the maximum display size.
[0091] Among them, the target size range interval can be information indicating the size range of the special effect mark to be obtained, and can be a range between the minimum display size and the maximum display size. The minimum display size can be the minimum display size of the set special effect mark, and the maximum display size can be the maximum display size of the set special effect mark. The display size can be parameters such as radius, width, density, etc. For example, when the special effect mark is a point, the display size can be a display radius, and when the special effect mark is a special effect line, the display size can be a display width. The mapping relationship can be a mapping relationship between light and dark information and a size range interval. For example, when the light and dark information is between 0 and 1, the minimum light and dark information 0 can be set to correspond to the minimum display size, and the maximum light and dark information 1 can be set to correspond to the maximum display size.
[0092] Among them, based on the mapping relationship, the target brightness information, and the target size range, the display size value of the special effect logo corresponding to the target brightness information is adjusted, so that the initial pixel value of the special effect logo corresponding to the screen UV coordinate is updated based on the adjusted display size value through a preset gradient function. There are many ways to obtain the first target pixel value. For example, the following formula can be used to determine the adjusted display size value of the special effect logo corresponding to the target brightness information based on the mapping relationship, the target brightness information, and the target size range:
[0093] SmoothStep(Ben-Day Dots,Ben-Day Dots*2,LightChange)
[0094] Among them, the target light and dark information can be used as a mask, and the mapping relationship between the light and dark information and the size range interval can be obtained through a smooth transition function (smoothstep), so that the display size of the special effect logo can be adjusted according to the target light and dark information (LightChange) corresponding to each vertex on the surface of the target model, the minimum display size (Ben-Day Dots) of the special effect logo, the maximum display size (Ben-DayDots*2, whose value can be twice the minimum display size Ben-Day Dots), and the mapping relationship determined by the smooth transition function (smoothstep), so as to obtain the value of the display size of each special effect logo adjusted based on the target light and dark information, so as to update the value of the size control parameter according to the adjusted display size, so as to output a new pixel value based on the input density parameter, the screen UV information, and the value of the adjusted display size indicated by the size control parameter through a preset gradient function, so as to update the initial pixel value corresponding to each screen UV coordinate, and obtain the first target pixel value corresponding to each screen UV coordinate of the special effect logo adjusted based on the target light and dark information.
[0095] For example, see Figure 3f , Figure 3f This is a schematic diagram of adjusting a special effect mark of an image processing method provided by an embodiment of the present application. In the rendered image, a position with greater brightness on the target model displays a larger special effect mark, and a position with less brightness on the target model displays a smaller special effect mark. In this way, the size of the special effect mark can be adjusted according to the brightness change indicated by the target brightness information corresponding to the target model, so that the size of the special effect mark changes with the brightness change of the target model, thereby obtaining a special effect mark distributed with the brightness change of the target model, thereby improving the simulation effect of the comic printing effect.
[0096] In one embodiment, the special effect mark may include at least one of a point and a special effect line.
[0097] Among them, for the special effect mark of the native point type, the target size range interval may include a display radius range interval, the greater the brightness indicated by the target light and dark information, the greater the display radius obtained by mapping the target light and dark information based on the mapping relationship, and the smaller the brightness indicated by the target light and dark information, the smaller the display radius obtained by mapping the target light and dark information based on the mapping relationship. In this way, in the image corresponding to the target model rendered based on the first target pixel value, the radius of the native point displayed in the bright area of the target model is larger, and the radius of the native point displayed in the dark area of the target model is smaller.
[0098] For special effect identifiers of the special effect line type, the target size range includes a display width range. The greater the brightness indicated by the target brightness information, the smaller the display width obtained by mapping the target brightness information based on the mapping relationship. The smaller the brightness indicated by the target brightness information, the larger the display width obtained by mapping the target brightness information based on the mapping relationship. In this way, in the image corresponding to the target model rendered based on the first target pixel value, the width of the special effect line displayed in the bright area of the target model is smaller, and the width of the special effect line displayed in the dark area of the target model is larger.
[0099] In one embodiment, the first target pixel value corresponding to the special effect identifier of the point type and the first target pixel value corresponding to the special effect identifier of the special effect line type can be obtained, so that the point and the special effect line can be superimposed on the target model according to the first target pixel value corresponding to the special effect identifier of the point type and the first target pixel value corresponding to the special effect identifier of the special effect line type, so as to further enhance the simulation effect of the comic printing effect.
[0100] In step 105, a target image with a comic printing effect corresponding to the target model is generated according to the first target pixel value.
[0101] The target image may be an image with a comic book printing effect corresponding to the target model, in which a special effect mark is added to the target model. For example, when the special effect mark is a Ben Dai point, in the target image generated by rendering, a Ben Dai point with a smaller radius is displayed in a darker area of the target model, and a Ben Dai point with a larger radius is displayed in a brighter area of the target model. For example, please refer to Figure 4a , Figure 4a is a target image schematic diagram of an image processing method provided by an embodiment of the present application. When the special effect is identified as a special effect line, in the target image generated by rendering, a special effect line with a larger width is displayed in the darker area of the target model, and a special effect line with a smaller width is displayed in the brighter area of the target model. For another example, please refer to Figure 4b , Figure 4b This is another target image schematic diagram of an image processing method provided in an embodiment of the present application. When the special effect marker is a grid texture, in the target image generated by rendering, a more obvious special effect marker is displayed in the brighter area of the target model, and no obvious special effect marker is displayed in the darker area of the target model.
[0102] There are many ways to generate a target image with a comic printing effect corresponding to the target model based on the first target pixel value. For example, the second target pixel value of the target model corresponding to each screen UV coordinate in the screen space can be obtained; the first target pixel value and the second target pixel value are mixed to obtain a target image superimposed with the target model and special effect logo.
[0103] The second target pixel value may be a pixel value corresponding to a target model rendered in the screen space.
[0104] In this way, in the process of rendering the target model, the pixel value of the target model corresponding to each screen UV coordinate in the rendered picture of each frame to which the target obviously corresponds can be calculated in the pixel shader stage, and the first target pixel value of the special effect identifier corresponding to each screen UV coordinate can be calculated based on the target brightness information of the target model in the current picture to be rendered. Therefore, in the merged output stage, various types of pixel values corresponding to each screen UV coordinate outputted in the pixel shader stage can be mixed, and the final color for display can be output in real time in combination with the depth information of each pixel on the screen, so that the rendered picture of the target model including the superimposed special effect identifier is displayed on the screen, and the target image with a comic printing effect corresponding to the target model is obtained.
[0105] Among them, there can be many ways to mix the first target pixel value and the second target pixel value. For example, the second target pixel value of the target model corresponding to each screen UV coordinate can be added to the first target pixel value to obtain the final pixel value used for display, or the second target pixel value of the target model corresponding to each screen UV coordinate can be multiplied with the first target pixel value to obtain the final pixel value used for display, etc., so that a target image superimposed with a target model and a special effect logo can be generated based on the mixed pixel value. The specific mixing method can be set according to actual conditions, and the embodiments of the present application are not limited here.
[0106] In one embodiment, the edge light effect of the target model can be set. Specifically, the camera vector of the virtual camera corresponding to the target model to be rendered can be obtained; the dot product between the vertex normal vector of the vertex in the target model and the camera vector is calculated to obtain the second angle value; based on the second angle value and the preset edge light range parameter, the edge light pixel value corresponding to the screen UV coordinate of the target model to be rendered is determined. Therefore, according to the first target pixel value and the edge light pixel value, a target image with a comic printing effect and an edge light effect corresponding to the target model can be generated.
[0107] The camera vector may be a vector of the camera direction of the virtual camera, the second angle value may be an angle between a vertex normal vector of a vertex in the target model and the camera vector, and the edge light pixel value may be a pixel value for generating an edge light effect of the target model in the rendered image. The edge light range parameter may be a parameter for controlling the range of the edge light effect in the target image to be generated, and a material node (RimLightRange) for controlling the edge light range may be set to determine the value of the input preset edge light range parameter, so that the edge light pixel value corresponding to each screen UV coordinate may be calculated.
[0108] Optionally, the first target pixel value corresponding to the special effect logo may be mixed with the pixel calculation result of the target model corresponding to the background and the character, and other effects may be superimposed to obtain a more stylish artistic effect, thereby improving the image processing effect.
[0109] Optionally, the embodiment of the present application uses physically based rendering (PBR) materials to illustrate the simulation of comic printing effects, and more art styles can be adjusted based on different materials.
[0110] Therefore, in order to realize the rendering of comic printing effect in the material of real-time rendering engine, the embodiment of the present application is based on the basic principle of simulating comic printing effect by using this point, by calculating the bright and dark areas of the target model in the picture before rendering, and calculating the pixel value of this point or parallel line or other custom texture based on the calculated light and dark information, that is, in the real-time rendering engine, the calculation principle is implemented in the character or scene material calculation, and a method similar to offline rendering is implemented in the screen space. The two calculation methods are superimposed, and finally a solution that can simulate comic printing effect in real time is provided, which can provide new art style effects for real-time content, thereby improving image processing efficiency.
[0111] In the existing image processing method, offline rendering is generally performed first, and then textures such as dots and parallel lines simulating comic printing effects are added to the offline rendered screen to obtain an image with a comic printing effect. This method cannot realize the simulated comic printing effect in real-time rendering engines such as games and real-time interactive related content, resulting in poor image processing efficiency. To this end, the embodiment of the present application proposes an image processing method, which calculates the initial pixel value of the special effect identifier to be mixed into the target model according to the screen UV information of the screen space, thereby adjusting the display parameters of the special effect identifier corresponding to the target model to be rendered according to the target light and dark information of the target model to be rendered, and obtaining the first target pixel value corresponding to the screen UV coordinate of the adjusted special effect identifier, thereby generating a target image with a simulated comic printing effect corresponding to the target model according to the first target pixel value, realizing the reproduction of the simulated comic printing effect used in movies in the real-time rendering engine, and providing a solution for simulating the comic printing effect in real time for games or real-time interactive content that need to simulate the comic printing effect, thereby providing a new art style effect for real-time content, thereby improving image processing efficiency.
[0112] As can be seen from the above, the embodiment of the present application obtains the screen UV information of the screen space corresponding to the target image to be rendered; based on the screen UV information, determines the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space, and the special effect identifier is used to be added to the target model to be rendered to simulate the comic printing effect; according to the normal information of the target model to be rendered, calculates the target light and dark information of the target model; based on the target light and dark information, adjusts the initial pixel value of the special effect identifier corresponding to the target model to obtain the first target pixel value of the special effect identifier corresponding to the screen UV coordinate; generates the target image with the comic printing effect corresponding to the target model according to the first target pixel value. In this way, by calculating the initial pixel value of the special effect identifier to be mixed into the target model according to the screen UV information of the screen space corresponding to the target image to be rendered, and adjusting the display parameters of the special effect identifier corresponding to the target model to be rendered according to the target light and dark information of the target model to be rendered, obtaining the first target pixel value corresponding to the screen UV coordinate of the adjusted special effect identifier, and generating the target image with the simulated comic printing effect corresponding to the target model according to the first target pixel value, it is realized that the image simulating the comic printing effect is rendered in real time in the real-time rendering engine, thereby improving the image processing efficiency.
[0113] In order to better implement the above method, an embodiment of the present invention further provides an image processing device, which can be integrated in an electronic device, and the electronic device can be a server or a terminal.
[0114] For example, Figure 5 As shown, it is a schematic diagram of the structure of the image processing device provided in an embodiment of the present application. The image processing device may include an acquisition unit 201, a determination unit 202, a calculation unit 203, an adjustment unit 204 and a generation unit 205, as follows:
[0115] An acquisition unit 201 is used to acquire screen UV information of a screen space corresponding to a target image to be rendered;
[0116] A determination unit 202 is used to determine the initial pixel value of the special effect mark corresponding to each screen UV coordinate of the screen space based on the screen UV information, and the special effect mark is used to be added to the target model to be rendered to simulate the comic printing effect;
[0117] A calculation unit 203, used to calculate target brightness information of the target model according to normal information of the target model to be rendered;
[0118] An adjusting unit 204 is used to adjust the initial pixel value of the special effect mark corresponding to the target model based on the target brightness information to obtain a first target pixel value of the special effect mark corresponding to the screen UV coordinate;
[0119] The generating unit 205 is configured to generate a target image with a comic printing effect corresponding to the target model according to the first target pixel value.
[0120] In some embodiments, the normal information includes a vertex normal vector, and the calculation unit 203 is used to:
[0121] Determine the preset light direction vector;
[0122] Get the vertex normal vector of the vertex in the target model to be rendered;
[0123] Calculate the first angle between the light direction vector and the vertex normal vector;
[0124] Based on the first angle value, target light and dark information of each vertex of the target model in the picture to be rendered is determined.
[0125] In some embodiments, the determining unit 202 is configured to:
[0126] Determine display parameters, including the number of special effect logos to be generated and display size;
[0127] By using a preset gradient function, based on display parameters and screen UV information, the initial pixel value of the special effect identifier corresponding to each screen UV coordinate in the screen space is calculated.
[0128] In some embodiments, the adjustment unit 204 is used to:
[0129] Get the target size range of the special effect logo, where the target size range includes the minimum display size and the maximum display size;
[0130] Obtaining the mapping relationship between light and dark information and size range intervals;
[0131] Based on the mapping relationship, target brightness information and target size range, the display size value of the special effect logo corresponding to the target brightness information is adjusted, so as to update the initial pixel value of the special effect logo corresponding to the screen UV coordinate based on the adjusted display size value through a preset gradient function to obtain a first target pixel value, wherein the adjusted display size of the special effect logo is between the minimum display size and the maximum display size.
[0132] In some embodiments, the special effect mark includes at least one of a point and a special effect line.
[0133] In some embodiments, for special effect logos of the dot type, the target size range interval includes a display radius range interval. The greater the brightness indicated by the target light and dark information, the larger the display radius obtained by mapping the target light and dark information based on the mapping relationship; for special effect logos of the special effect line type, the target size range interval includes a display width range interval. The greater the brightness indicated by the target light and dark information, the smaller the display width obtained by mapping the target light and dark information based on the mapping relationship.
[0134] In some embodiments, the acquisition unit 201 is configured to:
[0135] Get the viewport UV information and viewport size of the screen space corresponding to the target image to be rendered;
[0136] The viewport UV information is translated so that the origin in the viewport UV information is moved to the center of the viewport screen to obtain the first viewport UV information;
[0137] Scale the first viewport UV information according to the viewport size to obtain the second viewport UV information;
[0138] The origin position of the second viewport UV information is restored to obtain the screen UV information of the screen space.
[0139] In some embodiments, the image processing device further includes an edge light processing unit, which is used to:
[0140] Get the camera vector of the virtual camera corresponding to the target model to be rendered;
[0141] Calculate the dot product between the vertex normal vector of the vertex in the target model and the camera vector to obtain a second angle value;
[0142] Based on the second angle value and the preset edge light range parameter, determine the edge light pixel value corresponding to the screen UV coordinate of the target model to be rendered;
[0143] The generating unit 205 is used for:
[0144] A target image having a comic printing effect and an edge light effect corresponding to the target model is generated according to the first target pixel value and the edge light pixel value.
[0145] In one embodiment, the generating unit 205 is configured to:
[0146] Obtain a second target pixel value of the target model corresponding to each screen UV coordinate in the screen space;
[0147] The first target pixel value and the second target pixel value are mixed to obtain a target image superimposed with a target model and a special effect mark.
[0148] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0149] As can be seen from the above, in the embodiment of the present application, the acquisition unit 201 acquires the screen UV information of the screen space corresponding to the target image to be rendered; the determination unit 202 determines the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space based on the screen UV information, and the special effect identifier is used to be added to the target model to be rendered to simulate the comic printing effect; the calculation unit 203 calculates the target light and dark information of the target model according to the normal information of the target model to be rendered; the adjustment unit 204 adjusts the initial pixel value of the special effect identifier corresponding to the target model based on the target light and dark information, and obtains the first target pixel value of the special effect identifier corresponding to the screen UV coordinate; the generation unit 205 generates the target image with the comic printing effect corresponding to the target model according to the first target pixel value. In this way, the initial pixel value of the special effect logo to be mixed into the target model is calculated according to the screen UV information of the screen space, and the display parameters of the special effect logo corresponding to the target model to be rendered are adjusted according to the target brightness information of the target model to be rendered, so as to obtain the first target pixel value corresponding to the screen UV coordinate of the adjusted special effect logo, and then generate the target image of the simulated comic printing effect corresponding to the target model according to the first target pixel value, so as to achieve real-time rendering of the image simulating the comic printing effect in the real-time rendering engine, thereby improving the image processing efficiency.
[0150] The present application also provides an electronic device, such as Figure 6 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application, and the electronic device may be a server or a terminal. Specifically:
[0151] The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0152] The processor 301 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device 300, executes various functions of the electronic device 300 and processes data by running or loading software programs and / or modules stored in the memory 302, and calling data stored in the memory 302, thereby monitoring the electronic device 300 as a whole.
[0153] In the embodiment of the present application, the processor 301 in the electronic device 300 will load instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions:
[0154] Get the screen UV information of the screen space corresponding to the target image to be rendered;
[0155] Based on the screen UV information, determine the initial pixel value of the special effect mark corresponding to each screen UV coordinate in the screen space, and the special effect mark is used to be added to the target model to be rendered to simulate the comic printing effect;
[0156] Calculate target brightness and shading information of the target model according to the normal information of the target model to be rendered;
[0157] Adjusting the initial pixel value of the special effect mark corresponding to the target model based on the target brightness information to obtain a first target pixel value of the special effect mark corresponding to the screen UV coordinate;
[0158] A target image with a comic printing effect corresponding to the target model is generated according to the first target pixel value.
[0159] This solution can obtain the screen UV information of the screen space corresponding to the target image to be rendered; based on the screen UV information, determine the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space, the special effect identifier is used to be added to the target model to be rendered to simulate the comic printing effect; according to the normal information of the target model to be rendered, calculate the target light and dark information of the target model; based on the target light and dark information, adjust the initial pixel value of the special effect identifier corresponding to the target model to obtain the first target pixel value of the special effect identifier corresponding to the screen UV coordinate; generate the target image with comic printing effect corresponding to the target model according to the first target pixel value. In this way, by calculating the initial pixel value of the special effect identifier to be mixed into the target model according to the screen UV information of the screen space, the display parameters of the special effect identifier corresponding to the target model to be rendered are adjusted according to the target light and dark information of the target model to be rendered, and the first target pixel value corresponding to the screen UV coordinate of the adjusted special effect identifier is obtained, so as to generate the target image corresponding to the target model with the simulated comic printing effect according to the first target pixel value, so as to achieve real-time rendering of the image simulating the comic printing effect in the real-time rendering engine, thereby improving the image processing efficiency.
[0160] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0161] Optional, such as Figure 6 As shown, the electronic device 300 further includes: a touch screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306 and a power supply 307. The processor 301 is electrically connected to the touch screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306 and the power supply 307 respectively. Those skilled in the art can understand that Figure 6 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0162] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 303 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 301, and can receive the command sent by the processor 301 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 301 to determine the type of touch event, and then the processor 301 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 303 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 303 can also be used as a part of the input unit 306 to realize the input function.
[0163] The radio frequency circuit 304 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
[0164] The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 305 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 305 and converted into audio data, and then the audio data is output to the processor 301 for processing, and then sent to another electronic device through the radio frequency circuit 304, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earplug jack to provide communication between an external headset and the electronic device.
[0165] The input unit 306 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0166] The power supply 307 is used to supply power to various components of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 307 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0167] although Figure 6 Not shown, the electronic device 300 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0168] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. It should be noted that the electronic device provided in the embodiment of the present application and the image processing method in the above embodiment belong to the same concept. The specific implementation process is detailed in the above method embodiment and will not be repeated here.
[0169] As can be seen from the above, the electronic device provided by the embodiment of the present application can obtain the screen UV information of the screen space; determine the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space based on the screen UV information corresponding to the target image to be rendered, and the special effect identifier is used to be added to the target model to be rendered to simulate the comic printing effect; calculate the target light and dark information of the target model according to the normal information of the target model to be rendered; adjust the initial pixel value of the special effect identifier corresponding to the target model based on the target light and dark information, and obtain the first target pixel value of the special effect identifier corresponding to the screen UV coordinate; generate the target image with comic printing effect corresponding to the target model according to the first target pixel value. In this way, by calculating the initial pixel value of the special effect identifier to be mixed into the target model according to the screen UV information of the screen space, the display parameters of the special effect identifier corresponding to the target model to be rendered are adjusted according to the target light and dark information of the target model to be rendered, and the first target pixel value corresponding to the screen UV coordinate of the adjusted special effect identifier is obtained, so as to generate the target image corresponding to the target model simulating the comic printing effect according to the first target pixel value, so as to achieve real-time rendering of the image simulating the comic printing effect in the real-time rendering engine, thereby improving the image processing efficiency.
[0170] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0171] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any image processing method provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0172] Get the screen UV information of the screen space corresponding to the target image to be rendered;
[0173] Based on the screen UV information, determine the initial pixel value of the special effect mark corresponding to each screen UV coordinate in the screen space, and the special effect mark is used to be added to the target model to be rendered to simulate the comic printing effect;
[0174] Calculate target brightness and shading information of the target model according to the normal information of the target model to be rendered;
[0175] Adjusting the initial pixel value of the special effect mark corresponding to the target model based on the target brightness information to obtain a first target pixel value of the special effect mark corresponding to the screen UV coordinate;
[0176] A target image with a comic printing effect corresponding to the target model is generated according to the first target pixel value.
[0177] This solution can obtain the screen UV information of the screen space corresponding to the target image to be rendered; based on the screen UV information, determine the initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space, the special effect identifier is used to be added to the target model to be rendered to simulate the comic printing effect; according to the normal information of the target model to be rendered, calculate the target light and dark information of the target model; based on the target light and dark information, adjust the initial pixel value of the special effect identifier corresponding to the target model to obtain the first target pixel value of the special effect identifier corresponding to the screen UV coordinate; generate the target image with comic printing effect corresponding to the target model according to the first target pixel value. In this way, by calculating the initial pixel value of the special effect identifier to be mixed into the target model according to the screen UV information of the screen space, the display parameters of the special effect identifier corresponding to the target model to be rendered are adjusted according to the target light and dark information of the target model to be rendered, and the first target pixel value corresponding to the screen UV coordinate of the adjusted special effect identifier is obtained, so as to generate the target image corresponding to the target model with the simulated comic printing effect according to the first target pixel value, so as to achieve real-time rendering of the image simulating the comic printing effect in the real-time rendering engine, thereby improving the image processing efficiency.
[0178] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0179] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0180] Since the computer program stored in the computer-readable storage medium can execute the steps in any image processing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any image processing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0181] Among them, according to one aspect of the present application, a computer program product is provided, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the methods provided in the various optional implementations provided in the above embodiments.
[0182] The above is a detailed introduction to an image processing method, device, storage medium and electronic device provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. An image processing method, characterized in that: include: Get the screen UV information of the screen space corresponding to the target image to be rendered; Based on the screen UV information, determining an initial pixel value of a special effect identifier corresponding to each screen UV coordinate of the screen space, wherein the special effect identifier is used to be added to a target model to be rendered to simulate a comic printing effect; Calculating target brightness and darkness information of the target model according to normal information of the target model to be rendered; Adjusting the initial pixel value of the special effect identifier corresponding to the target model based on the target brightness information to obtain a first target pixel value of the special effect identifier corresponding to the screen UV coordinate; A target image with a comic printing effect corresponding to the target model is generated according to the first target pixel value.
2. The image processing method according to claim 1, characterized in that: The normal information includes vertex normal vectors, and the step of calculating target brightness information of the target model according to the normal information of the target model to be rendered includes: Determine the preset light direction vector; Get the vertex normal vector of the vertex in the target model to be rendered; Calculating a first angle value between the light direction vector and the vertex normal vector; Based on the first angle value, target brightness and darkness information of each vertex of the target model in the picture to be rendered is determined.
3. The image processing method according to claim 1, characterized in that: The determining, based on the screen UV information, an initial pixel value of a special effect identifier corresponding to each screen UV coordinate of the screen space includes: Determining display parameters, wherein the display parameters include the number of special effect logos to be generated and a display size; The initial pixel value of the special effect identifier corresponding to each screen UV coordinate of the screen space is calculated based on the display parameters and the screen UV information by using a preset gradient function.
4. The image processing method according to claim 3, characterized in that: The step of adjusting the initial pixel value of the special effect identifier corresponding to the target model based on the target brightness information to obtain the first target pixel value of the special effect identifier corresponding to the screen UV coordinate includes: Obtaining a target size range of the special effect identifier, wherein the target size range includes a minimum display size and a maximum display size; Obtaining the mapping relationship between light and dark information and size range intervals; Based on the mapping relationship, the target brightness information and the target size range, the display size value of the special effect logo corresponding to the target brightness information is adjusted, so as to update the initial pixel value of the special effect logo corresponding to the screen UV coordinate based on the adjusted display size value through the preset gradient function to obtain a first target pixel value, wherein the adjusted display size of the special effect logo is between the minimum display size and the maximum display size.
5. The image processing method according to claim 4, characterized in that: The special effect mark includes at least one of a special effect point and a special effect line.
6. The image processing method according to claim 5, characterized in that: For special effect markers of the dot type, the target size range interval includes a display radius range interval. The greater the brightness indicated by the target light and dark information, the larger the display radius obtained by mapping the target light and dark information based on the mapping relationship; for special effect markers of the special effect line type, the target size range interval includes a display width range interval. The greater the brightness indicated by the target light and dark information, the smaller the display width obtained by mapping the target light and dark information based on the mapping relationship.
7. The image processing method according to any one of claims 1 to 6, characterized in that: The obtaining of screen UV information of the screen space corresponding to the target image to be rendered includes: Get the viewport UV information and viewport size of the screen space corresponding to the target image to be rendered; The viewport UV information is translated so that the origin in the viewport UV information is moved to the center of the viewport screen, thereby obtaining the first viewport UV information; Scaling the first viewport UV information according to the viewport size to obtain second viewport UV information; The origin position of the second viewport UV information is restored to obtain the screen UV information of the screen space.
8. The image processing method according to any one of claims 1 to 6, characterized in that: The method further comprises: Get the camera vector of the virtual camera corresponding to the target model to be rendered; Calculate the dot product between the vertex normal vector of the vertex in the target model and the camera vector to obtain a second angle value; Based on the second angle value and a preset edge light range parameter, determine an edge light pixel value of the target model to be rendered corresponding to the screen UV coordinate; The step of generating a target image with a comic printing effect corresponding to the target model according to the first target pixel value includes: A target image having a comic printing effect and an edge light effect corresponding to the target model is generated according to the first target pixel value and the edge light pixel value.
9. The image processing method according to any one of claims 1 to 6, characterized in that: The step of generating a target image with a comic printing effect corresponding to the target model according to the first target pixel value includes: Obtaining a second target pixel value of the target model corresponding to each screen UV coordinate in the screen space; The first target pixel value and the second target pixel value are mixed to obtain a target image superimposed with the target model and the special effect mark.
10. An image processing device, characterized in that: include: An acquisition unit, used for acquiring screen UV information of a screen space corresponding to a target image to be rendered; a determining unit, configured to determine, based on the screen UV information, an initial pixel value of a special effect identifier corresponding to each screen UV coordinate of the screen space, wherein the special effect identifier is used to be added to a target model to be rendered to simulate a comic printing effect; A calculation unit, used for calculating target brightness and darkness information of the target model to be rendered according to normal information of the target model; an adjusting unit, configured to adjust an initial pixel value of the special effect identifier corresponding to the target model based on the target brightness information, so as to obtain a first target pixel value of the special effect identifier corresponding to the screen UV coordinate; A generating unit is used to generate a target image with a comic printing effect corresponding to the target model according to the first target pixel value.
11. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: It comprises a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any method described in claims 1 to 9.