Image processing method and device, storage medium and electronic device

By acquiring mask image reading information and determining the index of the target array element, the mask image in the mask texture array is dynamically read, which solves the problem of low mask image reading efficiency and improves game performance and resource utilization efficiency.

CN119888044BActive Publication Date: 2025-11-07NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing technologies have low efficiency in reading mask images, which leads to a decrease in game performance. Furthermore, existing methods increase the number of shader branches or image resources, affecting rendering performance and download time.

Method used

By obtaining the mask image reading information of the target texture image, the target array element index of the mask texture array is determined, and the mask image on the target color channel is read in the mask texture array. Dynamic indexing is used to reduce the amount of image resources and avoid thread divergence and branching statements.

Benefits of technology

It effectively reduces the amount of masking image resources in game resources, improves the efficiency of masking image reading, avoids rendering performance degradation, and improves game running efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888044B_ABST
    Figure CN119888044B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose an image processing method and device, a storage medium and an electronic device. The method comprises: obtaining mask map reading information of a target texture image, the target texture image comprising mask maps on a plurality of color channels; determining a target array element index of a mask texture array according to the mask map reading information, wherein one array element in the mask texture array corresponds to a mask map of the target texture image on one color channel; determining a target array element corresponding to the target array element index in the mask texture array; and reading a mask map corresponding to the target texture image on a target color channel from the target array element. In this way, the target array element index of the mask texture array corresponding to the target texture image is determined according to the mask map reading information, and 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, thereby improving the reading efficiency of the mask map in a game.
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, in particular to an image processing method and device, a storage medium and an electronic device. BACKGROUND

[0002] With the rapid development of life and technology, people often entertain themselves through game applications. In game production, a large number of mask images are often used to achieve various game effects. In the development process of a shader, a point operator is generally used to read a mask texture. A single channel mask image is read fixedly at a time, or a mask image is read in the form of a black and white image or an alpha image.

[0003] In the research and practice of the prior art, it is found that if the point operator is used to read the mask image, conditional judgment (if) statements need to be added to control the selection of multiple channels respectively, thereby increasing the Shader branches and reducing the rendering performance. If the mask image is read in the form of a black and white image or an alpha image, the amount of picture resources required will be doubled, which reduces the game performance. It can be seen that the reading efficiency of the mask image is low in the existing image processing method. SUMMARY

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

[0005] The embodiments of the present application provide an image processing method, comprising:

[0006] obtaining mask image reading information for a target texture image, the target texture image comprising mask images on multiple color channels;

[0007] determining a target array element index for a 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 the target texture image on one color channel;

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

[0009] reading a mask image corresponding to a target color channel of the target texture image from the target array element.

[0010] Correspondingly, the embodiments of the present application provide an image processing device, comprising:

[0011] an obtaining unit configured to obtain mask image reading information for a target texture image, the target texture image comprising mask images on multiple color channels;

[0012] a first determining unit, configured to determine, according to the mask map reading information, a target array element index of a mask texture array, wherein one array element in the mask texture array corresponds to a mask map of the target texture image on one 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] a reading unit, configured to read, from the target array element, a mask map corresponding to the target texture image on a target color channel.

[0015] Further, an embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is adapted to be loaded by a processor to execute steps of any one of the image processing methods provided by the embodiments of the present application.

[0016] Further, an embodiment of the present application further provides an electronic device, which comprises a processor and a memory, and 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 by the embodiments of the present application.

[0017] An embodiment of the present application further provides a computer program product, which comprises a computer program 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 steps of the image processing method provided by the embodiments of the present application.

[0018] An embodiment of the present application acquires mask map reading information for a target texture image, the target texture image comprises mask maps on multiple color channels; determines, according to the mask map reading information, a target array element index of a mask texture array, wherein one array element in the mask texture array corresponds to a mask map of the target texture image on one color channel; determines, in the mask texture array, a target array element corresponding to the target array element index; and reads, from the target array element, a mask map corresponding to the target texture image on a target color channel. In this way, by determining, according to the mask map reading information, a target array element index of a mask texture array corresponding to a mask map of the target texture image, and then reading, according to the target array element index, a mask map of the target texture image on a target color channel in the mask texture array, the mask maps on the color channels in the target texture image are dynamically read, the picture resource amount of the mask maps in the game resources is effectively reduced, and at the same time, the rendering performance is prevented from being reduced due to the mask map reading by the point operator and the shader branching, and the reading efficiency of the mask maps in the game is effectively improved. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a schematic diagram illustrating an implementation scenario of an image processing method provided in this application.

[0021] Figure 2 This is a schematic flowchart of an image processing method provided in an embodiment of this application;

[0022] Figure 3 This is a schematic diagram of layer overlay for an image processing method provided in an embodiment of this application;

[0023] Figure 4 This is a schematic diagram of the structure of the image processing apparatus provided in the embodiments of this application;

[0024] Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0026] This application provides an image processing method, apparatus, storage medium, and electronic device. The image processing apparatus can be integrated into an electronic device, which may be a server or a terminal, etc.

[0027] The server can be a standalone physical server, a server cluster or a distributed system formed by multiple physical servers, a cloud server providing cloud services, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, content delivery network (CDN), and basic cloud computing services such as big data and artificial intelligence platform. The terminal can include but is not limited to a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and the like. The terminal and the server can be connected directly or indirectly through wired or wireless communication, which is not limited in the present application.

[0028] Referring to Figure 1 For example, the image processing device is integrated in an electronic device, Figure 1 The implementation scenario of the image processing method provided by the embodiment of the present application is shown in the figure, wherein the electronic device can be a terminal or a server, the electronic device can obtain mask map reading information for a target texture image, the target texture image includes a mask map on multiple color channels; determine a target array element index for a mask texture array according to the mask map reading information, wherein one array element in the mask texture array corresponds to the mask map of the target texture image on one color channel; determine a target array element corresponding to the target array element index in the mask texture array; read the mask map corresponding to the target color channel of the target texture image from the target array element.

[0029] It should be noted that Figure 1 The implementation environment scenario of the image processing method shown in the figure is only an example, and the implementation environment scenario of the image processing method described in the embodiment of the present application is used 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. Those skilled in the art can know 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 scheme provided by the embodiment of the present application is described in detail by the following embodiments. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.

[0031] This embodiment will be described from the perspective of an image processing device, which can be integrated in an electronic device. The electronic device can be a terminal and / or a server, which is not limited in the present application.

[0032] Referring to Figure 2 , Figure 2 is a flowchart of the image processing method provided by the embodiment of the present application. The image processing method comprises:

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

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

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

[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 picture resources required by a game, thereby reducing the download time of game data for a user and improving the running efficiency of the game.

[0037] For example, referring to Figure 3 , Figure 3 is a layer superimposition diagram of an image processing method provided by an embodiment of the present application. It is assumed that the color channels include an R channel, a G channel, and a B channel. Three black and white mask images can be acquired, and the three mask images can be stored in the R channel, the G channel, and the B channel of an image respectively, so that a single RGBA image (or RGB image) can be obtained, that is, a target texture image. The single image can include information of the three mask images.

[0038] Optionally, before the mask image reading information for the target texture image is acquired, a mask reading parameter can be set in a target buffer. The mask reading parameter is configured as an integer type, and a value range of the mask reading parameter belongs to a value range corresponding to an array element index of a mask texture array corresponding to the target texture image. The mask image reading information input for the target texture image is received, and the mask image reading information is assigned to the mask reading parameter.

[0039] Correspondingly, the step of acquiring the mask image reading information for the target texture image can include reading a parameter value of the mask reading parameter in the target buffer to obtain the mask image reading information for the target texture image.

[0040] The target buffer can be a buffer for storing the mask map reading information corresponding to the target texture image. For example, the target buffer can be a constant buffer, which can be used to store constant data in a shader program. The constant buffer can be declared by a constant buffer keyword (cbuffer), which is a keyword in a High-Level Shading Language (HLSL) for defining a constant buffer. The HLSL is a programming language for shaders. The mask reading parameter can be a parameter for obtaining the mask map reading information, the mask reading parameter is configured as an integer type (IntSlider), and the value range of the mask reading parameter belongs to the value range of the array element index of the mask texture array corresponding to the target texture image. The mask texture array can be an array for storing the mask maps of each color channel in the target texture image. The mask map 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 in the mask texture array. The index can be a number for locating and accessing a specific element in an array. Any element in the array can be directly accessed or modified by the index. For example, assuming that the mask texture array stores the mask maps of the R channel, the G channel, and the B channel of the target texture image in sequence, the array element index corresponding to the R channel in the mask texture array corresponding to the target texture image 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. In this way, the value range of the mask reading parameter belongs to the value range of the array element index of the mask texture array, that is, the value range [0, 2] corresponding to 0 to 2, that is, the value of the mask reading parameter can include 0, 1, or 2.

[0041] The parameter value of the mask reading parameter in the target buffer can be obtained in various ways. For example, the mask map reading information for the target texture image can be obtained in the target buffer by a target shader associated with the target buffer.

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

[0043] Optionally, data that can be changed in the game editing process can be stored in the target buffer cbuffer, which can be transmitted to the graphics processor GPU and used in the vertex shader or the pixel shader. Among these parameters, an integer parameter (int parameter) can be placed, that is, a mask reading parameter, which is transmitted to the index bracket [] of the code reading the texture channel to confirm which color channel of 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 of the game picture.

[0044] In an embodiment, the mask reading parameter can be set as an integer parameter in the cbuffer, and the range and step of the value of the user input mask reading parameter can be clamped to ensure that the value corresponding to the user input mask reading parameter corresponds to the value corresponding to the array element index of the mask texture array corresponding to the target texture image. Otherwise, the mask texture array stored in the mask texture array cannot be positioned according to the information read from the mask image, and invalid values are avoided. Therefore, the array index method for the target texture image can be used to determine the parameter value of the mask reading parameter by filling the integer type mask reading information in the index box by the user, and the channel information corresponding to each mask picture in the target texture image can be obtained by transmitting the integer parameter value.

[0045] For example, assuming that the array element index of the mask texture array corresponding to the target texture image includes 0, 1, and 2, the following code can be used to set the mask reading parameter in the target buffer, and the mask reading 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:

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

[0047] Precis ion="0";>=0

[0048] Wherein, parameter can represent the mask reading parameter, IntSl ider can represent the integer type, Min can represent the minimum value in the value range of the mask reading parameter, that is, 0, Max can represent the maximum value in the value range of the mask reading parameter, that is, 2, and Step can represent the step in the value range of the mask reading parameter. Therefore, the mask reading parameter in the target buffer can be 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 (0, 1, and 2).

[0049] In an embodiment, a plurality of mask images can be stored in a plurality of color channels in the same image to obtain a target texture image. For example, at least two mask images can be obtained; color channels corresponding to the mask images are determined; color settings are performed on the mask images corresponding to the color channels based on color values of the color channels, to obtain set mask images; and the set mask images are combined to obtain the target texture image.

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

[0051] The set mask images can be combined in various ways to obtain the target texture image. For example, a mixing order of the color channels in a target superimposition mode can be determined; and the set mask images are subjected to layer superimposition processing based on the mixing order to obtain the target texture image.

[0052] The target superimposition mode can be a mode of combining the set mask images, such as a screen mode. The mixing order can be an order of layer superimposition of the mask images corresponding to the color channels.

[0053] The set mask images can be combined in various ways to obtain the target texture image. For example, a mixing order of the color channels in a target superimposition mode can be determined; and the set mask images are subjected to layer superimposition processing based on the mixing order to obtain the target texture image.

[0054] For example, to meet the rendering needs of a game, three black and white mask images can be created in graphics and video processing software (After Effects, AE). Areas with an alpha of 1 correspond to white, and areas with an alpha of 0 correspond to black. The three mask images can be overlapped. Then, using the software's coloring function, each mask image can be colored according to its corresponding color channel. For example, the mask image corresponding to the red channel can be colored red, the mask image corresponding to the green channel can be colored green, and the mask image corresponding to the blue channel can be colored blue, etc. This allows the overlay mode of all three mask images to be set to the target overlay mode (Screen). When calculating color values, the color values ​​of each mask image need to be normalized. Finally, the three overlaid mask images can be exported as a single image to obtain the target texture image.

[0055] The Screen blending mode is a layer blending mode that creates an effect similar to the overlay projection of two slides. The formula for calculating the Screen blending mode value is: Output = 1 - (1 - Top) * (1 - Bottom), where Output represents the color value of the overlaid layers, and Top and Bottom represent the color values ​​of the upper and lower layers (between 0 and 1), respectively. When using Screen mode to overlay mask images from the red, green, and blue channels, this formula allows for the blending of color values ​​from each mask image on the same color channel, resulting in the overlaid color value. This produces an image containing complete RGB information because in Screen mode, each color channel is calculated independently. For example, if a color channel has a value of 1 in the upper image (meaning it's the brightest), then regardless of the lower image's value in that color channel, the output image will also have a value of 1. Therefore, the color values ​​of each RGB channel can be extracted from the merged target texture image.

[0056] In step 102, the target array element index for the mask texture array is determined based on the mask image reading information.

[0057] One array element in the mask texture array corresponds to the mask image of the target texture image on one color channel.

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

[0059] The target array element index of the mask texture array can be determined in various ways according to the mask image reading information. For example, the mask image reading information can be a numerical value, 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 can be a numerical value corresponding to the array element index of the mask texture array, so that the corresponding target array element index can be determined in the array element index of the mask texture array according to the mask image reading information.

[0061] Optionally, the mask texture array corresponding to the target texture image can be obtained in various ways. For example, the target texture image can be obtained, the mask images on each color channel of the target texture image can be read, and the mask images on each color channel can be stored as an array element in the mask texture array, and each array element can be set with a corresponding array element index, wherein the array element indexes corresponding to different color channels are different.

[0062] The mask images on each color channel of the target texture image can be read and stored as an array element in the mask texture array in various ways. For example, a mask texture array containing a plurality of array elements can be set, and the number of array elements is consistent with the number of color channels of the target texture image. The target texture image can be sampled based on the sampling coordinates corresponding to the target texture image. The sampling color information corresponding to the mask image of each color channel can be obtained according to the sampling result. The sampling color information of the mask image on each color channel can be written into an array element of the mask texture array.

[0063] The sampling coordinates can be coordinates for texture sampling of the target texture image, which can be UV coordinates, the UV coordinates can be coordinates in a two-dimensional coordinate system, used for mapping a texture map to the surface of a three-dimensional model, and U and V can represent horizontal and vertical coordinate axes respectively. The UV coordinates can define information about the position of each point on the texture map, which is related to the three-dimensional model, so as to correspond each point on the texture map to the surface of the model. The sampling result can be a result of sampling the target texture image according to the sampling coordinates corresponding to the target texture image. The sampling color information can be color values sampled on the mask map of each color channel. For example, after storing the target texture image in the game engine directory, the target texture image can be read based on the sampling coordinates of the target texture image using a Shader.

[0064] The mask texture array containing a plurality of array elements can be set in various ways, for example, a structure can be defined according to the color channels to be stored, which is used to store the mask map 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 mask texture array containing a plurality of array elements can be set as follows:

[0065]

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

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

[0068]

[0069] Texture2dSampler can be a 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 sampling color information of each color channel of the mask map can be written into an array element of the mask texture array, for example, the sampling color information of each color channel of the mask map can be written into an array element of the mask texture array as follows:

[0071]

[0072] In this way, the sampled color information color.r of the mask image in the R channel can be stored in the r element of the tmask mask texture array, the sampled color information color.g of the mask image in the G channel can be stored in the g element of the tmask mask texture array, and the sampled color information color.b of the mask image in the B channel 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 the like, and the mask texture array corresponding to the target texture image is obtained.

[0073] In an embodiment, the texture data corresponding to the target texture image can be loaded in a central processing unit (CPU) stage. Specifically, the texture data is stored in a corresponding disk directory, and then loaded from the disk to the memory, and from the memory to the video memory, so that the target texture image can be seen in the editor. Then, a rendering state can be called, and after the target texture image is read by using a Shader, the default rendering state of the Shader can be called in the editor, and then the default rendering state can be used to call a draw call to issue a draw instruction to the GPU. Thus, in the geometry stage of the GPU stage, there can be a preset geometry primitive in the game editor, and screen mapping is performed to correctly display the perspective relationship of the patch on the display. Then, in the rasterization stage, triangle traversal and perspective correction can be completed to calculate the color of the patch. In the per-patch operation stage, per-patch drawing can be performed to draw the target texture image in the viewport of the game editor.

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

[0075] The target array element can be an array element in the mask texture array corresponding 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, and 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 a target color channel of the target texture image is read from the target array element.

[0077] The target color channel can 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], where color.r represents a mask image of the target texture image in the R channel, color.g represents a mask image of the target texture image in the G channel, and color.b represents a mask image of the target texture image in the B channel, and the target array element is color.g, the mask image of the target texture image in the G channel can be read through the target array element.

[0078] The target texture image in the target color channel can be read from the target array element in various ways. For example, the target texture image in the target color channel can be read from the target array element through a target shader. In this way, the user input mask image reading information can be stored in the target buffer, so that the target shader can obtain the mask image reading information stored in the target buffer based on the association between the target shader and the target buffer, determine the target array element index of the mask texture array based on the mask image reading information, determine the target array element corresponding to the target array element index in the mask texture array, and then read the mask image of the target texture image in the target color channel from the target array element.

[0079] In an embodiment, the implementation program code of the dynamic array index can be written in the Shader, and the parameters passed in can be filled in the parameters. The actual parameters, i.e., the mask reading parameters, passed into the Shader can be set by the game editor, and the final file can 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 parameters passed in, and display the accurate picture on the display according to the CPU-GPU rendering process.

[0080] In this way, the artist can call the corresponding Shader (i.e., the target shader) in the game engine editor, so that when setting the mask image of the target texture image for reading, the integer value in the value range of the mask reading parameter (parameter) can be input in the corresponding index box, so as to realize the reading of the mask image of the corresponding array element in the mask texture array of the target texture image, and realize the flexible reading of the mask image of each color channel of the target texture image.

[0081] In the existing mask image reading method, the point operator is generally used to read the mask texture, and a single fixed reading of a channel mask image is performed. The point operator can be used to access each component of a vector, for example, texture.r can be used to access the information of the red channel in the picture. Alternatively, the mask image is read in the form of a black and white image or an alpha image. However, if the point operator is used to read the mask image, an if statement is needed to control the selection of multiple channels, thereby increasing the Shader branch and reducing the rendering performance. The Shader branch refers to the branching in the Shader programming, which can cause thread divergence, that is, different threads select different execution paths, which breaks the parallelism of the GPU, and thus causes the rendering performance to decrease. If the mask image is directly read in the form of a black and white image or an alpha image, the required picture resource amount will be doubled. For games, the more picture resources required, the longer the download time of the players, and thus the game running efficiency will be reduced, and the game performance will be reduced. It can be seen that in the existing image processing method, the reading efficiency of the mask image is low.

[0082] Therefore, the embodiment of the present application provides an image processing method, which determines the target array element index corresponding to the mask texture array corresponding to the target texture image according to the mask image reading information, and reads the mask image 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, the three channels of the target texture image are flexibly called by using the dynamic index of the texture in the Shader, which can effectively reduce the picture resource amount of the mask image in the game resource. The related art personnel or developer only needs to select the integer parameter (0, 1, 2, etc.) corresponding to the array element index to flexibly call the mask image in each color channel of the target texture image, which greatly improves the reading flexibility of the mask image, and meets the needs of the art personnel or developer to flexibly call a mask image. In addition, each mask image is read by using the array method, which can avoid using the branch statement, and thus can avoid thread divergence caused by reading the mask image by using the point operator and the decrease of the rendering performance caused by the Shader branch, and effectively improves the reading efficiency of the mask image in the game.

[0083] From the above, the embodiment of the application reads the information of the mask image for the target texture image, the target texture image including the mask image on multiple color channels; determines the target array element index of the mask texture array according to the mask image reading information, wherein one array element in the mask texture array corresponds to the mask image of the target texture image on one color channel; determines the target array element corresponding to the target array element index in the mask texture array; and reads the mask image corresponding to the target color channel of the target texture image from the target array element. In this way, by determining the target array element index of the mask texture array corresponding to the target texture image according to the mask image reading information, the mask image of the target color channel of the target texture image is read in the mask texture array according to the target array element index, which can effectively reduce the picture resource amount of the mask image in the game resource, and at the same time, avoid the rendering performance decline caused by the shader branch when the mask image is read through the dot operator, and effectively improve the reading efficiency of the mask image in the game.

[0084] In order to better implement the above method, the embodiment of the application further provides an image processing device, which can be integrated in an electronic device, which can be a terminal or a server.

[0085] For example, as shown in Figure 4 Fig. 1 is a structural schematic diagram of an image processing device provided by the embodiment of the application, which can include an acquisition unit 201, a first determination unit 202, a second determination unit 203 and a reading unit 204, as follows:

[0086] The acquisition unit 201 is configured to acquire mask image reading information for a target texture image, the target texture image including mask images on multiple color channels.

[0087] The first determination unit 202 is configured to determine a target array element index of a mask texture array according to the mask image reading information, wherein one array element in the mask texture array corresponds to the mask image of the target texture image on one color channel.

[0088] The second determination unit 203 is configured to determine a target array element corresponding to the target array element index in the mask texture array.

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

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

[0091] determine the mask image reading information as the target array element index of the mask texture array corresponding to the target texture image.

[0092] In some embodiments, the image processing apparatus further comprises an array obtaining unit, specifically comprising:

[0093] an image obtaining sub-unit, configured to obtain a target texture image;

[0094] a mask map reading sub-unit, configured to read mask maps of color channels in the target texture image, and store the mask maps of the color channels into a mask texture array as array elements respectively, and set an 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 map reading sub-unit is configured to:

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

[0097] sample the target texture image based on a sampling coordinate corresponding to the target texture image;

[0098] obtain sampling color information corresponding to the mask map of each color channel according to the sampling result;

[0099] write the sampling color information of the mask map of each color channel into an array element of the mask texture array respectively.

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

[0101] setting a mask reading parameter in the target buffer, and the mask reading parameter is configured as an integer type, and the value range belongs to the numerical 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 input for the target texture image, and assigning the mask map reading information to the mask reading parameter;

[0103] the obtaining unit 201 comprises:

[0104] a parameter obtaining sub-unit, configured to read the parameter value of the mask reading parameter in the target buffer, and obtain the mask map reading information for the target texture image.

[0105] In some embodiments, the parameter obtaining sub-unit is configured to:

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

[0107] the reading unit 204 is configured to:

[0108] reading, by the target shader, a mask image corresponding to the target texture image in a target color channel from a target array element in the target array.

[0109] In some embodiments, the image processing apparatus further comprises an image merging unit configured to:

[0110] obtain at least two mask images;

[0111] determine a color channel corresponding to each mask image;

[0112] perform color setting on each mask image corresponding to each color channel based on a color value corresponding to each color channel, to obtain a set mask image;

[0113] merge the set mask images to obtain a target texture image.

[0114] In some embodiments, the above-mentioned merging the set mask images to obtain a target texture image is specifically configured to:

[0115] determine a mixing order of the color channels in a target overlay mode;

[0116] perform layer superimposition processing on the set mask images based on the mixing order, to obtain a target texture image.

[0117] In implementation, each of the above units can be implemented as an independent entity, or can be combined as the same or several entities, and the specific implementation of each of the above units can be referred to the method embodiments above, which will not be described here.

[0118] As can be seen from the above, the embodiment of the present application obtains, by the obtaining unit 201, mask image reading information for a target texture image, the target texture image including mask images on multiple color channels; the first determining unit 202 determines, according to the mask image reading information, a target array element index for a mask texture array, wherein one array element in the mask texture array corresponds to a mask image of the target texture image on one color channel; the second determining unit 203 determines, in the mask texture array, a target array element corresponding to the target array element index; and the reading unit 204 reads, from the target array element, a mask image corresponding to the target texture image in a target color channel. In this way, by determining, according to the mask image reading information, a target array element index of a mask texture array corresponding to a target texture image, and then reading, according to the target array element index, a mask image of the target texture image in a target color channel from the mask texture array, the picture resource amount of the mask images in the game resources can be effectively reduced, and at the same time, the rendering performance caused by the shader branch due to reading the mask image through the dot operator can be avoided, and the reading efficiency of the mask image in the game can be effectively improved.

[0119] The embodiments of the present application also provide an electronic device, such as Figure 5 As shown in FIG. 1, which shows a structural schematic diagram of an electronic device related to the embodiments of the present application, the electronic device can be a terminal or a server, and 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 on the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art can understand that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than shown, or combine certain components, or different component arrangements.

[0121] The processor 301 is the control center of the electronic device 300, and connects various parts of the entire electronic device 300 through various interfaces and lines. By running or loading the software program and / or module stored in the memory 302 and calling the data stored in the memory 302, the processor 301 performs various functions and processes data of the electronic device 300, thereby overall monitoring the electronic device 300.

[0122] In the embodiments of the present application, the processor 301 in the electronic device 300 will load the instructions corresponding to the processes of one or more application programs into the memory 302, and run the application programs stored in the memory 302 by the processor 301, thereby realizing various functions:

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

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

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

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

[0127] The scheme can read information through an obtained mask map for a target texture image, the target texture image including 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 one array element in the mask texture array corresponds to a mask map of the target texture image on one color channel; determine a target array element corresponding to the target array element index in the mask texture array; and read a mask map corresponding to the target color channel of the target texture image from the target array element. In this way, the target array element index corresponding to the mask texture array corresponding to the target texture image is determined according to the mask map reading information, and the mask map of the target color channel of the target texture image is read in the mask texture array according to the target array element index, which can effectively reduce the picture resource amount of the mask map in the game resource, and avoid the rendering performance decline caused by the shader branch through the point operator to read the mask map, and effectively improve the reading efficiency of the mask map in the game.

[0128] The specific implementation of each operation can refer to the foregoing embodiments, which will not be described here.

[0129] Optionally, as shown in Figure 5 The electronic device 300 further includes a touch display 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 with the touch display 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 the electronic device structure shown in the Figure 5 The electronic device structure shown in the

[0130] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by user acting on the graphical user interface. The touch display screen 303 can include a display panel and a touch panel. The display panel can be used to display information input by the user or provided to the user and various graphical user interfaces of the electronic device, which 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), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect touch operations (such as user operations on or near the touch panel using a finger, a stylus or any suitable object or accessory) of the user thereon or therearound, and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel can include two parts of a touch detection device and a touch controller. The touch detection device detects the touch position of the user and detects signals generated by the touch operation, and transmits the signals to the touch controller; the touch controller receives the touch information from the touch detection device, and converts it into touch coordinates, and then sends it to the processor 301, and can also receive commands from the processor 301 and execute them. The touch panel can cover the display panel, and when the touch panel detects a touch operation thereon or therearound, it transmits to the processor 301 to determine the type of the touch event, and then the processor 301 provides corresponding visual output on the display panel according to the type of the touch event. In the embodiments 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 realize the input and output functions as two independent components. That is, the touch display screen 303 can also realize the input function as part of the input unit 306.

[0131] The radio frequency circuit 304 can be used to transceive radio frequency signals to establish wireless communication with network devices or other electronic devices, and transceive signals between network devices 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 the speaker and the microphone. The audio circuit 305 can convert the received audio data into an electrical signal and transmit it to the speaker, which converts it into a sound signal output. On the other hand, the microphone collects sound signals and converts them into electrical signals, which are received by the audio circuit 305 and converted into audio data. After the audio data is processed by the processor 301, it is transmitted to another electronic device through the radio frequency circuit 304, or output to the memory 302 for further processing. The audio circuit 305 can also include an earphone jack to provide communication between an external earphone and the electronic device.

[0133] The input unit 306 can be configured to receive inputted digital, character information or user feature information (e.g. fingerprint, iris, face 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 configured 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 as to realize functions such as management of charging, discharging and power consumption management through the power management system. The power supply 307 can also include one or more than one direct current or alternating current power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, etc.

[0135] Although Figure 5 The electronic device 300 can also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc. which are not shown in the embodiments and will not be described herein.

[0136] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments. It should be noted that the electronic device provided in the embodiments of the present application and the image processing method suitable for the above embodiments belong to the same concept, and the specific implementation process is described in detail in the above method embodiments, which will not be described here.

[0137] As can be seen from the above, the electronic device provided in the embodiments of the present application can obtain the mask map reading information for the target texture image, the target texture image includes the mask map on a plurality of color channels; determine the target array element index for the mask texture array according to the mask map reading information, wherein one array element in the mask texture array corresponds to the mask map of the target texture image on one color channel; determine the target array element corresponding to the target array element index in the mask texture array; read the mask map corresponding to the target color channel of the target texture image 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 reading the mask map of the target color channel of the target texture image in the mask texture array according to the target array element index, the picture resource amount of the mask map in the game resource can be effectively reduced, and at the same time, the rendering performance caused by the branching of the shader due to the reading of the mask map through the dot operator is avoided, and the reading efficiency of the mask map in the game is effectively improved.

[0138] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by a computer program, or by a computer program controlling related hardware, which can 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, which stores a computer program capable of being loaded by a processor to execute the steps in any of the image processing methods provided by the embodiments 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, the target texture image including mask maps on multiple color channels;

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

[0142] Determining, in the mask texture array, a target array element corresponding to the target array element index;

[0143] Reading, from the target array element, a mask map corresponding to the target color channel of the target texture image.

[0144] The present solution can obtain mask map reading information for a target texture image, the target texture image including mask maps on multiple color channels; determine, according to the mask map reading information, a target array element index for a mask texture array, wherein one array element in the mask texture array corresponds to a mask map of the target texture image on one color channel; determine, in the mask texture array, a target array element corresponding to the target array element index; and read, from the target array element, a mask map corresponding to the target color channel of the target texture image. In this way, by determining, according to the mask map reading information, a target array element index of a mask texture array corresponding to a target texture image, and then reading, according to the target array element index, a mask map of the target texture image on a target color channel in the mask texture array, the picture resource amount of the mask map in the game resource can be effectively reduced, and the rendering performance caused by the branching of the shader due to the reading of the mask map through the dot operator can be avoided, thereby effectively improving the reading efficiency of the mask map in the game.

[0145] The specific implementation of each operation can be referred to the foregoing embodiments, which will not be described here.

[0146] The computer readable storage medium can include a read only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0147] The computer program stored in the computer readable storage medium can execute the steps of any of the image processing methods provided by the embodiments of the present application, thus achieving the beneficial effects of any of the image processing methods provided by the embodiments of the present application. Details are described above, and will not be repeated here.

[0148] According to an aspect of the present application, a computer program product is provided, which includes a computer program 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 method provided in any of the various optional implementation manners provided by the embodiments described above.

[0149] The above describes in detail the image processing method, device, storage medium and electronic device provided by the embodiments of the present application. The principles and implementation manners of the present application are described by applying specific examples. The above description of the embodiments is only used to help understand the method of the present application and its core idea. Meanwhile, for those skilled in the art, the specific implementation manner and application range can be changed according to the idea of the present application. In summary, the content of the specification should not be understood as a limitation of the present application.

Claims

1. An image processing method, characterized by, The method comprises the following steps: obtaining mask map reading information of a target texture image, the target texture image comprising mask maps on multiple color channels; determining a target array element index of a mask texture array according to the mask map reading information, wherein one array element in the mask texture array corresponds to a mask map of the target texture image on one color channel; determining a target array element corresponding to the target array element index in the mask texture array; reading a mask map corresponding to a target color channel of the target texture image from the target array element.

2. The image processing method of claim 1, wherein, The mask map reading information is a numerical value, and the determination of the target array element index of the mask texture array according to the mask map reading information comprises: determining the mask map reading information as the target array element index of the mask texture array corresponding to the target texture image.

3. The image processing method of claim 2, wherein, Before the step of obtaining the mask map reading information of the target texture image, the method further comprises the following steps: obtaining a target texture image; reading mask maps of each color channel in the target texture image, and storing the mask maps of each color channel as an array element in a mask texture array respectively, and setting a corresponding array element index for each array element, wherein the array element indexes corresponding to different color channels are different.

4. The image processing method of claim 3, wherein, The step of reading the mask maps of each color channel in the target texture image and storing the mask maps of each color channel as an array element in a mask texture array comprises: setting a mask texture array comprising a plurality of array elements, the number of array elements being consistent with the number of color channels of the target texture image; sampling the target texture image based on a sampling coordinate corresponding to the target texture image; obtaining sampling color information corresponding to the mask map of each color channel according to the sampling result; writing the sampling color information of the mask map of each color channel into an array element of the mask texture array respectively.

5. The image processing method of claim 1, wherein, Before the step of obtaining the mask map reading information of the target texture image, the method further comprises the following steps: setting a mask reading parameter in a target buffer, the mask reading parameter being configured as an integer type and having a value range belonging to a numerical value range corresponding to the array element index of the mask texture array corresponding to the target texture image; receiving the mask map reading information input for the target texture image, and assigning the mask map reading information to the mask reading parameter; The step of obtaining the mask map reading information of the target texture image comprises: reading the parameter value of the mask reading parameter in the target buffer to obtain the mask map reading information of the target texture image.

6. The image processing method of claim 5, wherein, The step of reading the parameter value of the mask reading parameter in the target buffer to obtain the mask map reading information of the target texture image comprises: obtaining the mask map reading information of the target texture image in the target buffer through a target shader associated with the target buffer; The step of reading the mask map corresponding to the target color channel of the target texture image from the target array element comprises: read, by the target shader, a mask corresponding to a target color channel of the target texture image from the target array element.

7. The image processing method of any one of claims 1 to 6, wherein, Before the obtaining the mask reading information for the target texture image, the method comprises: obtaining at least two mask images; determining a color channel corresponding to each of the mask images; performing color setting on each of the mask images corresponding to each of the color channels based on a color value corresponding to each of the color channels, to obtain a set mask image; merging the set mask images to obtain the target texture image.

8. The image processing method of claim 7, wherein, The merging the set mask images to obtain the target texture image comprises: determining a mixing order of the color channels in a target superimposition mode; performing layer superimposition processing on the set mask images based on the mixing order, to obtain the target texture image.

9. An image processing apparatus characterized by comprising: The method comprises: an obtaining unit configured to obtain mask reading information for a target texture image, the target texture image comprising mask images on multiple color channels; a first determining unit configured to determine, according to the mask reading information, a target array element index for a mask texture array, wherein one array element in the mask texture array corresponds to a mask image of the target texture image on one 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; a reading unit configured to read, from the target array element, a mask corresponding to a target color channel of the target texture image.

10. An electronic device, comprising: The device 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 the method in any one of claims 1-8.

11. A computer readable storage medium, characterized in that, The computer program is used to make the electronic device execute the steps of the method in any one of claims 1-8 when the computer program runs on the electronic device.

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