Image processing method and device, storage medium and electronic equipment

By dynamically determining the target array element index of the mask texture array based on the mask image reading information in the game, the problem of low reading efficiency of mask image in the prior art is solved, and the effect of reducing image resources and improving rendering performance is achieved.

CN119888044AActive Publication Date: 2025-04-25NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510031835.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-04-25
Estimated Expiration
2045-01-08

AI Technical Summary

Technical Problem

The prior art has low reading efficiency of masked images in games, resulting in a decrease in rendering performance and an increase in image resources.

Method used

By obtaining the mask image reading information for the target texture image, the target array element index of the mask texture array is determined based on the mask image reading information, so that the mask image on the target color channel of the target texture image is read in the mask texture array.

Benefits of technology

It effectively reduces the amount of image resources of mask diagrams in game resources, avoids the degradation of shader branches and rendering performance caused by reading mask diagrams through point operators, and improves the reading efficiency of mask diagrams in game.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888044A_ABST
    Figure CN119888044A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an image processing method and device, a storage medium and electronic equipment. The method comprises the following steps: acquiring mask image reading information for a target texture image, wherein the target texture image comprises mask images on a plurality of color channels; a target array element index for the mask texture array is determined according to the mask image reading information, and one array element in the mask texture array corresponds to a mask image of the target texture image on one color channel; in the mask texture array, determining a target array element corresponding to the target array element index; and reading a mask image corresponding to the target texture image on the target color channel from the target array element. Therefore, the target array element index corresponding to the mask texture array corresponding to the target texture image is determined according to the mask image reading information, so that the mask image of the target texture image on the target color channel is read from the mask texture array according to the target array element index, and the reading efficiency of the mask image in a game is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, 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 production, a large number of mask images are often needed to achieve various game effects. In the process of shader development, the mask texture is generally read by point operators, and the mask image of one channel is read at a time, or the mask image is directly read in the form of black and white images or transparency (alpha) images.

[0003] In the process of research and practice of existing technologies, it is found that if the dot operator is used to read the mask image, it is necessary to add conditional judgment (if) statements to control the selection of multiple channels respectively, thereby increasing the shader branch and reducing the rendering performance. If the mask image is read directly in the form of a black and white image or an alpha image, the required image resources will double, reducing the game performance. It can be seen that in the existing image processing methods, the efficiency of reading the mask image is low. Summary of the invention

[0004] The embodiments of the present application provide an image processing method, device, storage medium and electronic device, which can effectively improve the reading efficiency of mask images in games.

[0005] The present application provides an image processing method, including:

[0006] Obtaining mask map reading information for a target texture image, wherein the target texture image includes mask maps on multiple color channels;

[0007] Determine a target array element index for a mask texture array according to the mask image reading information, wherein an array element in the mask texture array corresponds to a mask image of the target texture image on a color channel;

[0008] In the mask texture array, determining a target array element corresponding to the target array element index;

[0009] The mask image corresponding to the target texture image on the target color channel is read from the target array element.

[0010] Accordingly, an embodiment of the present application provides an image processing device, including:

[0011] An acquisition unit, configured to acquire mask map reading information for a target texture image, wherein the target texture image includes mask maps on multiple color channels;

[0012] A first determining unit is used to determine a target array element index for a mask texture array according to the mask image reading information, wherein an array element in the mask texture array corresponds to a mask image of the target texture image on a color channel;

[0013] A second determining unit, configured to determine, in the mask texture array, a target array element corresponding to the target array element index;

[0014] The reading unit is used to read the mask image corresponding to the target texture image on the target color channel from the target array element.

[0015] 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.

[0016] 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.

[0017] 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.

[0018] The embodiment of the present application obtains mask map reading information for a target texture image, wherein the target texture image includes mask maps on multiple color channels; determines the target array element index for the mask texture array according to the mask map reading information, wherein an array element in the mask texture array corresponds to the mask map of the target texture image on a color channel; determines the target array element corresponding to the target array element index in the mask texture array; and reads the mask map corresponding to the target texture image on the target color channel from the target array element. In this way, by determining the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask map reading information, the mask map of the target texture image on the target color channel is read in the mask texture array according to the target array element index, and the mask map on each color channel in the target texture image is dynamically read, which can effectively reduce the amount of image resources of the mask map in the game resources, and at the same time, avoid the shader branch caused by reading the mask map through the dot operator, which leads to a decrease in rendering performance, and effectively improves the reading efficiency of the mask map in the game. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] 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.

[0020] Figure 1 It is a schematic diagram of an implementation scenario of an image processing method provided in an embodiment of the present application;

[0021] Figure 2 It is a flowchart of an image processing method provided in an embodiment of the present application;

[0022] Figure 3 It is a schematic diagram of layer overlay of an image processing method provided in an embodiment of the present application;

[0023] Figure 4 is a schematic diagram of the structure of an image processing device provided in an embodiment of the present application;

[0024] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] 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.

[0026] 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.

[0027] 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.

[0028] See also Figure 1 , taking the image processing device integrated into an electronic device as an example, Figure 1 A 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 terminal or a server, and the electronic device may obtain mask map reading information for a target texture image, wherein the target texture image includes mask maps on multiple color channels; determine a target array element index for a mask texture array according to the mask map reading information, wherein an array element in the mask texture array corresponds to a mask map of the target texture image on a color channel; in the mask texture array, determine a target array element corresponding to the target array element index; and read the mask map corresponding to the target texture image on the target color channel from the target array element.

[0029] 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.

[0030] 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.

[0031] 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.

[0032] 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:

[0033] In step 101, mask map reading information for a target texture image is obtained.

[0034] The target texture image may include mask images on multiple color channels.

[0035] The target texture image may be an image with a mask image stored on a color channel. The color channel may be a channel for storing image color information. The color channels of images in different color modes are different. For example, in an RGB color mode, the color channels of the target texture image may include a red (R) channel, a green (G) channel, and a blue (B) channel. The mask image may be a mask-type image, which may be used to control or limit the display range of certain effects during the rendering process, or may be used to adjust the display effects of certain rendering effects, etc. The mask image reading information may be information for reading a mask image on a specific color channel of the target texture image.

[0036] Optionally, a mask image can be stored on each color channel of the target texture image, so that multiple mask images can be combined into one texture image, reducing the amount of image resources required for the game, thereby reducing the time it takes users to download game data and improving the running efficiency of the game.

[0037] For example, see Figure 3 , Figure 3 This is a layer overlay diagram of an image processing method provided in an embodiment of the present application. Assuming that the color channels include R channel, G channel, and B channel, three black-and-white mask images can be obtained, and these three mask images are respectively stored in the R channel, G channel, and B channel of the image, so that a single RGBA image (or RGB image), that is, the target texture image, can be obtained. This single image can include the information of the three mask images.

[0038] Optionally, before obtaining the mask map read information for the target texture image, a mask read parameter can be set in the target buffer, the mask read parameter is configured as an integer type, and the value range belongs to the numerical range corresponding to the array element index of the mask texture array corresponding to the target texture image; receive the mask map read information input for the target texture image, and assign the mask map read information to the mask read parameter.

[0039] Correspondingly, the step of obtaining the mask map reading information for the target texture image may include: reading the parameter value of the mask reading parameter in the target buffer to obtain the mask map reading information for the target texture image.

[0040] The target buffer may be a buffer for storing mask map reading information corresponding to the target texture image. For example, the target buffer may be a constant buffer, which may be used to store constant data in a shader program. A constant buffer may be declared using a constant buffer keyword (cbuffer), which is a keyword in a high-level shader language (HLSL) for defining a constant buffer. HLSL is a programming language for shaders. The mask reading parameter can be a parameter used to obtain the mask image reading information. The mask reading parameter is configured as an integer type (IntSl ider), and the value range of the mask reading parameter belongs to the numerical range corresponding to the array element index of the mask texture array corresponding to the target texture image. The mask texture array can be an array that stores the mask images of each color channel in the target texture image. The mask image of each color channel is an array element in the mask texture array. The array element can be an element in the mask texture array. The array element index can be an array index corresponding to the element of the mask texture array. The index can be a number used to locate and access a specific element in the array. Any element in the array can be directly accessed or modified through the index. For example, assuming that the mask texture array stores the mask images of the target texture image in the R channel, G channel and B channel respectively, then in the mask texture array corresponding to the target texture image, the array element index corresponding to the R channel can be 0, the array element index corresponding to the G channel can be 1, and the array element index corresponding to the B channel can be 2. Therefore, the value range of the mask reading parameter belongs to the numerical range corresponding to the array element index of the mask texture array, that is, the numerical range corresponding to 0 to 2 [0, 2], that is, the value of the mask reading parameter can include 0, 1 or 2.

[0041] Among them, there are many ways to read the parameter values ​​of the mask read parameters in the target buffer and obtain the mask map read information for the target texture image. For example, the mask map read information for the target texture image can be obtained in the target buffer through the target shader associated with the target buffer.

[0042] The target shader may be a shader associated with a target buffer. For example, the target shader may be bound to the target buffer, or the target buffer may be defined in the shader code, so that the target shader may obtain data in the target buffer.

[0043] Optionally, the target buffer cbuffer can store data that will change during the game editing process. These data can be transmitted to the graphics processor GPU and used in the vertex shader or pixel shader. Among these parameters, an integer parameter (int parameter) can be placed, that is, the mask reading parameter. This parameter will be transmitted to the index bracket [] of the line of code that reads the texture channel to confirm which color channel mask map in the target texture image needs to be read. This setting can be used to set the rendering state of the Shader, and finally used for rendering the game screen.

[0044] In one embodiment, the mask reading parameter can be set as an integer parameter in the cbuffer, and the range and stride of the value of the mask reading parameter input by the user are clamped to ensure that the value corresponding to the mask reading parameter input by the user is the value corresponding to the array element index of the mask texture array corresponding to the target texture image. Otherwise, it is impossible to locate the mask images of each color channel stored in the mask texture array according to the mask image reading information, so as to avoid inputting some invalid values. In this way, the method of using array index for the target texture image can determine the parameter value of the mask reading parameter by filling in the integer type mask image reading information in the index box by the user, and obtain the channel information corresponding to each mask image in the target texture image by transmitting the integer parameter value.

[0045] For example, assuming that the array element indexes of the mask texture array corresponding to the target texture image include 0, 1, and 2, the following code can be used to set the mask read parameters in the target buffer. The mask read parameters are configured as integer types, and the value range belongs to the numerical range corresponding to the array element index of the mask texture array corresponding to the target texture image:

[0046] int parameter <Widget="IntSl ider";Min="0";Max="2";Step="1";

[0047] Precision = "0"; > = 0

[0048] Among them, parameter can be represented as a mask read parameter, IntSl ider can be represented as an integer type, Min represents the minimum value in the value range of the mask read parameter, that is, 0, Max can represent the maximum value in the value range of the mask read parameter, that is, 2, and Step can represent the step length in the value range of the mask read parameter. In this way, the mask read parameter in the target buffer can be configured as an integer type, and the value range belongs to the numerical range (0, 1, 2) corresponding to the array element index of the mask texture array corresponding to the target texture image.

[0049] In one embodiment, multiple mask images can be stored in multiple color channels in the same image to obtain a target texture image. For example, at least two mask images can be obtained; the color channel corresponding to each mask image can be determined; the color of the mask image corresponding to each color channel is set based on the color value corresponding to each color channel to obtain a set mask image, and the set mask images are merged to obtain the target texture image.

[0050] Among them, the color value corresponding to each color channel can be the color value set for each color channel. For example, when a mask image corresponds to the R channel, its corresponding color value can be the color value of the R channel is a, and the color values ​​of other channels are 0. For another example, when a mask image corresponds to the G channel, its corresponding color value can be the color value of the G channel is b, and the color values ​​of other channels are 0. For another example, when a mask image corresponds to the B channel, its corresponding color value can be the color value of the B channel is c, and the color values ​​of other channels are 0. Among them, a, b, and c can be preset color values, for example, they can be 100, 200, 255, etc. The values ​​of a, b, and c can be the same or different. The specific values ​​can be set according to actual conditions, and the embodiments of the present application are not limited here. The mask image after setting can be a mask image after color setting. For each mask image after setting, its color value on the corresponding color channel is not 0, and its value on other color channels is 0.

[0051] There are many ways to merge the post-setting mask images to obtain the target texture image. For example, the mixing order of color channels in the target overlay mode can be determined; based on the mixing order, multiple post-setting mask images are layered to obtain the target texture image.

[0052] The target overlay mode may be a mode for merging the mask images after each setting, for example, a color filter (Screen) mode. The mixing order may be an order for overlaying the mask images corresponding to the color channels.

[0053] Among them, based on the mixing order, multiple post-setting mask images are layered and processed to obtain the target texture image in various ways. For example, the post-setting mask images corresponding to the first two color channels can be layered and processed to obtain a first superimposed image. Based on the mixing order, one color channel to be superimposed is determined each time, and the post-setting mask image corresponding to the color channel to be superimposed is layered and processed with the latest first superimposed image to obtain a new first superimposed image, until the post-setting mask images of all color channels are superimposed to obtain the target texture image.

[0054] For example, according to the needs of game rendering, three black and white mask images can be made in the graphics video processing software (AfterEffects, referred to as AE), where the part with transparency (Alpha) of 1 corresponds to white, and the part with Alpha of 0 corresponds to black. The three mask images can be overlapped, and then, the three mask images can be dyed separately according to the color channels corresponding to each mask image through the dyeing function of the software, for example, the mask image corresponding to the red channel is dyed red, the mask image corresponding to the green channel is dyed green, and the mask image corresponding to the blue channel is dyed blue, etc., so that the overlay mode of the three mask images can be set to the target overlay mode (Screen). When calculating the color value, the color value of each mask image needs to be normalized. Then, the three mask images after superposition can be exported into one picture to obtain the target texture image.

[0055] Among them, Screen overlay mode is a layer blending mode, and its effect is similar to the overlay projection of two slides. The calculation formula of Screen mode can be: Output = 1-(1-Top)*(1-Bottom), where Output can represent the color value after the upper and lower layers are superimposed, and Top and Bottom represent the color values ​​of the upper and lower layers respectively (between 0 and 1). When using Screen mode to superimpose the mask images under the three channels of red, green, and blue, the color values ​​of each mask image on the same color channel can be mixed through this calculation formula to obtain the superimposed color value, so as to obtain an image containing complete information of the three RGB channels. This is because in Screen mode, the color value of each color channel is calculated independently. For example, if the color value of a color channel in the upper image is 1 (that is, the color of the color channel is the brightest), then no matter what the color value of the lower image in the color channel is, the color value of the output image in the color channel will be 1. In this way, the color values ​​in each RGB color channel in the target texture image obtained after merging can be re-extracted.

[0056] In step 102, a target array element index for a mask texture array is determined according to the mask map read information.

[0057] Among them, an array element in the mask texture array corresponds to a mask image of the target texture image on a color channel.

[0058] The mask texture array may be an array storing mask images on each color channel of the target texture image, and the mask images of the target texture image on each color channel are used as an array element of the mask texture array. The array element may be an element in the array, and each array element has a corresponding array element index, that is, the mask images of the target texture image on the color channel each correspond to an array element index, and the array element index may be the subscript corresponding to the array element in the mask texture array. The target array element index may be the array element index corresponding to the mask image reading information. An array is a composite data type, which is composed of a series of elements of the same type, and the storage space of the elements in the array may be adjacent.

[0059] Among them, there can be multiple ways to determine the target array element index for the mask texture array based on the mask image reading information. For example, the mask image reading information can be numerical type information, and the mask image reading information can be determined as the target array element index of the mask texture array corresponding to the target texture image.

[0060] For example, the mask image reading information may be a numerical value corresponding to a data element index of the mask texture array, so that the corresponding target array element index may be determined in the array element index of the mask texture array according to the mask image reading information.

[0061] Optionally, there may be multiple ways to obtain the mask texture array corresponding to the target texture image. For example, the target texture image may be obtained; the mask image of each color channel in the target texture image may be read, and the mask image of each color channel may be stored as an array element in the mask texture array, and a corresponding array element index may be set for each array element, wherein different array element indexes correspond to different color channels.

[0062] There are many ways to read the mask image of each color channel in the target texture image and store the mask image of each color channel as an array element in the mask texture array. For example, a mask texture array including multiple array elements can be set, and the number of array elements is consistent with the number of color channels of the target texture image; based on the sampling coordinates corresponding to the target texture image, the target texture image is sampled; according to the sampling results, the sampling color information corresponding to the mask image of each color channel is obtained; and the sampling color information of the mask image of each color channel is written into an array element of the mask texture array.

[0063] Among them, the sampling coordinates can be coordinates for texture sampling of the target texture image, and can be UV coordinates. The UV coordinates can be coordinates in a two-dimensional coordinate system, which are used to map the texture map to the surface of the three-dimensional model. U and V can represent the horizontal and vertical coordinate axes respectively. The UV coordinates can define the position information of each point on the texture map, and these points are interconnected with the three-dimensional model to achieve the correspondence of each point on the texture map to the surface of the model. The sampling result can be the result of sampling the target texture image according to the sampling coordinates corresponding to the target texture image. The sampling color information can be the color value sampled on the mask map of each color channel. For example, after the target texture image is stored in the game engine directory, Shader can be used to read the target texture image based on the sampling coordinates of the target texture image.

[0064] There are many ways to set a mask texture array containing multiple array elements. For example, a structure can be defined according to the color channels to be stored to store the mask images of each color channel in the target texture image. For example, when the color channels to be stored include R channel, G channel and B channel, the following code can be used to set a mask texture array containing multiple array elements:

[0065]

[0066] Among them, RGBArray can be the name of the structure, r, g, b can be the elements in the structure, and tmask can be an instance of the structure, which can be used to obtain a mask texture array containing multiple array elements.

[0067] Then, based on the sampling coordinates corresponding to the target texture image, the target texture image can be sampled, and the sampling color information corresponding to the mask image of each color channel can be obtained according to the sampling result. For example, the following code can be used to sample the target texture image:

[0068]

[0069] Among them, Texture2dSampler can be the set sampler, UV can be the sampling coordinates corresponding to the target texture image, Texture can be the texture resource of the target texture image, and tmask can be the sampling result.

[0070] Then, the sampled color information of the mask image of each color channel can be written into an array element of the mask texture array respectively. For example, the following code can be used to write the sampled color information of the mask image of each color channel into an array element of the mask texture array respectively:

[0071]

[0072] In this way, the sampling color information color.r corresponding to the sampled R channel mask image can be stored in the r element of the tmask mask texture array, the sampling color information color.g corresponding to the sampled G channel mask image can be stored in the g element of the tmask mask texture array, and the sampling color information color.b corresponding to the sampled B channel mask image can be stored in the b element of the tmask structure, so that the array element index corresponding to the r element is 0, the array element index corresponding to the g element is 1, the array element index corresponding to the b element is 2, and so on, to obtain the mask texture array corresponding to the target texture image.

[0073] In one embodiment, the texture data corresponding to the target texture image can be loaded at the central processing unit (CPU) stage, specifically, the texture data is stored in the corresponding disk directory, and then the data is loaded from the disk to the memory, and from the memory to the video memory, and the target texture image can be seen in the editor. Then, the rendering state can be called. After using Shader to read the target texture image, the default rendering state of Shader can be called in the editor, and then the draw call function (DrawCal l) can be called through the preset default rendering state to issue a drawing instruction to the GPU. Thus, in the geometry stage of the GPU stage, there can be preset geometric primitives in the game editor, and screen mapping will be done here to allow the face to correctly display the perspective relationship on the display. Then in the rasterization stage, triangle traversal and perspective correction can be completed, and the color of the fragment can be calculated. In the fragment-by-fragment operation stage, fragment-by-fragment drawing can be done to draw this target texture image in the viewport of the game editor.

[0074] In step 103, in the mask texture array, a target array element corresponding to the target array element index is determined.

[0075] The target array element may be an array element in the mask texture array that corresponds to the target array element index. For example, assuming that the target array element index is 1, the mask texture array includes three array elements [color.r, color.g, color.b], color.r represents the mask image of the target texture image in the R channel, color.g represents the mask image of the target texture image in the G channel, and color.b represents the mask image of the target texture image in the B channel, wherein the array element index corresponding to color.r is 0, the array element index corresponding to color.g is 1, and the array element index corresponding to color.b is 2, then it can be determined that the target array element corresponding to the target array element index is color.g.

[0076] In step 104, a mask image corresponding to the target texture image on the target color channel is read from the target array element.

[0077] The target color channel may be a color channel corresponding to the target array element. For example, assuming that the mask texture array includes three array elements [color.r, color.g, color.b], color.r represents the mask image of the target texture image in the R channel, color.g represents the mask image of the target texture image in the G channel, and color.b represents the mask image of the target texture image in the B channel. At the same time, the target array element is color.g, and the mask image corresponding to the target texture image on the G channel can be read through the target array element.

[0078] There are many ways to read the mask map corresponding to the target texture image on the target color channel from the target array element. For example, the mask map corresponding to the target texture image on the target color channel can be read from the target array element through the target shader. In this way, the mask map reading information input by the user can be stored through the target buffer, so that based on the association between the target shader and the target buffer, the target shader can obtain the mask map reading information stored in the target buffer, and then the target array element index for the mask texture array can be determined based on the mask map reading information, so that the target array element corresponding to the target array element index can be determined in the mask texture array, and then the mask map corresponding to the target texture image on the target color channel can be read from the target array element.

[0079] In one embodiment, the implementation program code of the dynamic array index can be written in the Shader, and the parameters of the parameter passing can be filled in. The relevant technicians can set the actual parameters passed into the Shader through the game editor, that is, the mask reading parameters, and pass them into the Shader. Finally, this file will be packaged into the game package. When the game package reads this file, it will modify the actual rendering state in the Shader according to the passed parameters, and display the accurate picture on the display according to the CPU-GPU rendering process.

[0080] In this way, artists can call the corresponding Shader (i.e., target shader) in the game engine editor, and when setting the reading of the mask map of the target texture image, they can enter an integer value in the value range of the mask reading parameter in the corresponding index box, thereby realizing the reading of the mask map of the corresponding array element in the mask texture array of the target texture image, and realizing flexible reading of the mask map of each color channel in the target texture image.

[0081] In the existing mask map reading method, the mask texture is generally read by the dot operator, and the mask map of one channel is read at a time. The dot operator can be used to access the components of the vector. For example, texture.r can be used to access the information of the red channel in the picture. Alternatively, the mask map is directly read in the form of a black and white image or a transparency (alpha) image. However, if the mask map is read by the dot operator, it is necessary to add conditional judgment (if) statements to control the selection of multiple channels respectively, thereby increasing the shader branch and reducing the rendering performance. Among them, the shader branch refers to the branch in shader programming that may cause thread divergence, that is, different threads choose different execution paths, which will break the parallelism of the graphics processing unit (GPU) and lead to a decrease in rendering performance. If the mask map is read directly in the form of a black and white image or an alpha image, the amount of image resources required will double. For games, the more image resources are required, the longer the player's download time will be, which will reduce the game running efficiency and reduce the game performance. It can be seen that in the existing image processing method, the efficiency of reading the mask map is low.

[0082] To this end, an embodiment of the present application provides an image processing method, by determining the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask map reading information, and then reading the mask map of the target texture image on the target color channel in the mask texture array according to the target array element index. In this way, by using the dynamic index of the texture in the Shader to flexibly call the three channels of the target texture image, the amount of image resources of the mask map in the game resources can be effectively reduced. The relevant artists or developers only need to select the integer parameters (0, 1, 2, etc.) corresponding to the array element index to realize the flexible call of the mask map in each color channel of the target texture image, which greatly improves the flexibility of reading the mask map. At the same time, it meets the needs of artists or developers to flexibly call a certain mask map. In addition, by reading each mask map in an array manner, there is no need to use a branch statement, so that no thread divergence will occur, and it can be avoided that the shader branch caused by reading the mask map through the dot operator will lead to a decrease in rendering performance, thereby effectively improving the reading efficiency of the mask map in the game.

[0083] As can be seen from the above, the embodiment of the present application obtains the mask map reading information for the target texture image, and the target texture image includes mask maps on multiple color channels; determines the target array element index for the mask texture array according to the mask map reading information, wherein an array element in the mask texture array corresponds to the mask map of the target texture image on a color channel; in the mask texture array, determines the target array element corresponding to the target array element index; and reads the mask map corresponding to the target texture image on the target color channel from the target array element. In this way, by determining the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask map reading information, and then reading the mask map of the target texture image on the target color channel in the mask texture array according to the target array element index, the amount of image resources of the mask map in the game resources can be effectively reduced. At the same time, it can avoid the degradation of rendering performance caused by shader branching due to reading the mask map through the dot operator, and effectively improve the reading efficiency of the mask map in the game.

[0084] 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 terminal or a server.

[0085] For example, Figure 4 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 first determination unit 202, a second determination unit 203 and a reading unit 204, as follows:

[0086] An acquisition unit 201 is used to acquire mask map reading information for a target texture image, where the target texture image includes mask maps on multiple color channels;

[0087] A first determining unit 202 is used to determine a target array element index for a mask texture array according to the mask image reading information, wherein an array element in the mask texture array corresponds to a mask image of a target texture image on a color channel;

[0088] A second determining unit 203 is used to determine the target array element corresponding to the target array element index in the mask texture array;

[0089] The reading unit 204 is used to read the mask image corresponding to the target texture image on the target color channel from the target array element.

[0090] In some embodiments, the mask image reading information is a numerical value, and the first determining unit 202 is used to:

[0091] The mask image is read to determine the target array element index of the mask texture array corresponding to the target texture image.

[0092] In some embodiments, the image processing device further includes an array acquisition unit, specifically including:

[0093] An image acquisition subunit, used for acquiring a target texture image;

[0094] The mask image reading subunit is used to read the mask image of each color channel in the target texture image, and store the mask image of each color channel as an array element in the mask texture array, and set the corresponding array element index for each array element, wherein the array element indexes corresponding to different color channels are different.

[0095] In some embodiments, the mask image reading subunit is used to:

[0096] Set a mask texture array containing multiple array elements, the number of array elements is consistent with the number of color channels of the target texture image;

[0097] Based on the sampling coordinates corresponding to the target texture image, sampling the target texture image;

[0098] According to the sampling result, the sampling color information corresponding to the mask image of each color channel is obtained;

[0099] The sampled color information of the mask image of each color channel is written into an array element of the mask texture array respectively.

[0100] In some embodiments, the image processing apparatus further includes: a parameter storage unit including:

[0101] Setting a mask read parameter in the target buffer, the mask read parameter is configured as an integer type, and the value range belongs to the value range corresponding to the array element index of the mask texture array corresponding to the target texture image;

[0102] Receiving mask map reading information inputted for the target texture image, and assigning the mask map reading information to the mask reading parameter;

[0103] The acquisition unit 201 includes:

[0104] The parameter acquisition subunit is used to read the parameter value of the mask reading parameter in the target buffer to obtain the mask map reading information for the target texture image.

[0105] In some embodiments, the parameter acquisition subunit is used to:

[0106] Obtaining mask map reading information for a target texture image in the target buffer through a target shader associated with the target buffer;

[0107] The reading unit 204 is used for:

[0108] Through the target shader, the mask map corresponding to the target texture image on the target color channel is read from the target array element.

[0109] In some embodiments, the image processing apparatus further includes an image merging unit, which is used to:

[0110] Get at least two mask images;

[0111] Determine the color channel corresponding to each mask image;

[0112] Based on the color value corresponding to each color channel, the color of the mask image corresponding to each color channel is set respectively to obtain the set mask image;

[0113] Merge the mask images after setting to get the target texture image.

[0114] In some embodiments, the above-mentioned setting of the mask images is combined to obtain a target texture image, which is specifically used for:

[0115] Determines the blending order of color channels in target overlay mode;

[0116] Based on the blending order, multiple mask images after setting are layered and processed to obtain the target texture image.

[0117] 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.

[0118] As can be seen from the above, the embodiment of the present application obtains the mask map reading information for the target texture image through the acquisition unit 201, and the target texture image includes mask maps on multiple color channels; the first determination unit 202 determines the target array element index for the mask texture array according to the mask map reading information, wherein an array element in the mask texture array corresponds to the mask map of the target texture image on a color channel; the second determination unit 203 determines the target array element corresponding to the target array element index in the mask texture array; the reading unit 204 reads the mask map corresponding to the target texture image on the target color channel from the target array element. In this way, by determining the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask map reading information, and then reading the mask map of the target texture image on the target color channel in the mask texture array according to the target array element index, the amount of image resources of the mask map in the game resources can be effectively reduced, and at the same time, the shader branch caused by reading the mask map through the dot operator is avoided, which leads to a decrease in rendering performance, and effectively improves the reading efficiency of the mask map in the game.

[0119] The present application also provides an electronic device, such as Figure 5 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 terminal or a server. Specifically:

[0120] 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.

[0121] 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.

[0122] 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:

[0123] Obtaining mask map reading information for a target texture image, where the target texture image includes mask maps on multiple color channels;

[0124] Determine a target array element index for the mask texture array according to the mask image reading information, wherein one array element in the mask texture array corresponds to a mask image of a target texture image on one color channel;

[0125] In the mask texture array, determine the target array element corresponding to the target array element index;

[0126] Read the mask map corresponding to the target texture image on the target color channel from the target array element.

[0127] This solution can obtain the mask map reading information for the target texture image, the target texture image includes mask maps on multiple color channels; determine the target array element index for the mask texture array according to the mask map reading information, wherein an array element in the mask texture array corresponds to the mask map of the target texture image on a color channel; in the mask texture array, determine the target array element corresponding to the target array element index; and read the mask map corresponding to the target texture image on the target color channel from the target array element. In this way, by determining the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask map reading information, and then reading the mask map of the target texture image on the target color channel in the mask texture array according to the target array element index, the amount of image resources of the mask map in the game resources can be effectively reduced, and at the same time, avoiding the degradation of rendering performance caused by shader branching caused by reading the mask map through the dot operator, and effectively improving the reading efficiency of the mask map in the game.

[0128] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0129] Optional, such as Figure 5 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 5 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.

[0130] 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.

[0131] 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.

[0132] 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.

[0133] 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.

[0134] 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.

[0135] although Figure 5 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.

[0136] 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.

[0137] As can be seen from the above, the electronic device provided by the embodiment of the present application can obtain the mask map reading information for the target texture image, wherein the target texture image includes mask maps on multiple color channels; determine the target array element index for the mask texture array according to the mask map reading information, wherein an array element in the mask texture array corresponds to the mask map of the target texture image on a color channel; in the mask texture array, determine the target array element corresponding to the target array element index; and read the mask map corresponding to the target texture image on the target color channel from the target array element. In this way, by determining the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask map reading information, and then reading the mask map of the target texture image on the target color channel in the mask texture array according to the target array element index, the amount of image resources of the mask map in the game resources can be effectively reduced, and at the same time, avoiding the degradation of rendering performance caused by shader branching due to reading the mask map through the dot operator, and effectively improving the reading efficiency of the mask map in the game.

[0138] 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.

[0139] 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:

[0140] Obtaining mask map reading information for a target texture image, where the target texture image includes mask maps on multiple color channels;

[0141] Determine a target array element index for the mask texture array according to the mask image reading information, wherein one array element in the mask texture array corresponds to a mask image of a target texture image on one color channel;

[0142] In the mask texture array, determine the target array element corresponding to the target array element index;

[0143] Read the mask map corresponding to the target texture image on the target color channel from the target array element.

[0144] This solution can obtain the mask map reading information for the target texture image, the target texture image includes mask maps on multiple color channels; determine the target array element index for the mask texture array according to the mask map reading information, wherein an array element in the mask texture array corresponds to the mask map of the target texture image on a color channel; in the mask texture array, determine the target array element corresponding to the target array element index; and read the mask map corresponding to the target texture image on the target color channel from the target array element. In this way, by determining the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask map reading information, and then reading the mask map of the target texture image on the target color channel in the mask texture array according to the target array element index, the amount of image resources of the mask map in the game resources can be effectively reduced, and at the same time, avoiding the degradation of rendering performance caused by shader branching caused by reading the mask map through the dot operator, and effectively improving the reading efficiency of the mask map in the game.

[0145] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0146] 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.

[0147] 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.

[0148] 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.

[0149] 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: Obtaining mask map reading information for a target texture image, wherein the target texture image includes mask maps on multiple color channels; Determine a target array element index for a mask texture array according to the mask image reading information, wherein an array element in the mask texture array corresponds to a mask image of the target texture image on a color channel; In the mask texture array, determining a target array element corresponding to the target array element index; The mask image corresponding to the target texture image on the target color channel is read from the target array element.

2. The image processing method according to claim 1, characterized in that: The mask image reading information is a numerical value, and determining the target array element index for the mask texture array according to the mask image reading information includes: The mask image is read to determine the target array element index of the mask texture array corresponding to the target texture image.

3. The image processing method according to claim 2, characterized in that: Before obtaining the mask map reading information for the target texture image, the method further includes: Get the target texture image; The mask image of each color channel in the target texture image is read, and the mask image of each color channel is stored as an array element in the mask texture array, and a corresponding array element index is set for each array element, wherein the array element indexes corresponding to different color channels are different.

4. The image processing method according to claim 3, characterized in that: The step of reading the mask image of each color channel in the target texture image and storing the mask image of each color channel as an array element in the mask texture array comprises: Setting a mask texture array comprising a plurality of array elements, wherein the number of the array elements is consistent with the number of color channels of the target texture image; Based on the sampling coordinates corresponding to the target texture image, sampling the target texture image; According to the sampling result, the sampling color information corresponding to the mask image of each color channel is obtained; The sampled color information of the mask image of each color channel is written into an array element of the mask texture array respectively.

5. The image processing method according to claim 1, wherein: Before obtaining the mask map reading information for the target texture image, the method further includes: Setting a mask reading parameter in a target buffer, wherein the mask reading parameter is configured as an integer type and a value range belongs to a numerical range corresponding to an array element index of a mask texture array corresponding to the target texture image; Receiving mask map reading information input for a target texture image, and assigning the mask map reading information to the mask reading parameter; The step of obtaining mask image reading information for a target texture image includes: The parameter value of the mask reading parameter in the target buffer is read to obtain the mask map reading information for the target texture image.

6. The image processing method according to claim 5, characterized in that: The step of reading the parameter value of the mask reading parameter in the target buffer to obtain the mask map reading information for the target texture image includes: Obtaining, in the target buffer through a target shader associated with the target buffer, mask map read information for the target texture image; The step of reading a mask image corresponding to the target texture image on a target color channel from the target array element comprises: The mask image corresponding to the target texture image on the target color channel is read from the target array element through the target shader.

7. The image processing method according to any one of claims 1 to 6, characterized in that: Before obtaining the mask map reading information for the target texture image, the method includes: Get at least two mask images; Determine the color channel corresponding to each of the mask images; Based on the color values ​​corresponding to the color channels, the mask images corresponding to the color channels are respectively set to obtain the set mask images; The set mask images are merged to obtain a target texture image.

8. The image processing method according to claim 7, characterized in that: The step of merging the set mask images to obtain a target texture image comprises: Determine the blending order of the color channels in the target overlay mode; Based on the mixing order, a plurality of the set mask images are subjected to layer overlay processing to obtain a target texture image.

9. An image processing device, characterized in that: include: An acquisition unit, configured to acquire mask map reading information for a target texture image, wherein the target texture image includes mask maps on multiple color channels; A first determining unit is used to determine a target array element index for a mask texture array according to the mask image reading information, wherein an array element in the mask texture array corresponds to a mask image of the target texture image on a color channel; A second determining unit, configured to determine, in the mask texture array, a target array element corresponding to the target array element index; The reading unit is used to read the mask image corresponding to the target texture image on the target color channel from the target array element.

10. 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 8.

11. A computer-readable storage medium, characterized in that: It includes 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 8.

Citation Information

Patent Citations

  • Detail texture processing method and device

    CN111951369A

  • Animation data encoding method and device, animation data decoding method and device, storage medium and computer equipment

    CN112070866A

  • Model generation method and device, computer equipment and storage medium

    CN114419233A

  • Method and system for multi-pass rendering

    US5977977A