Effect superposition method and device based on unity engine, electronic equipment, storage medium and program product
By using the coordinate information of mask texture images and color blending technology in the Unity engine, the memory waste caused by object model duplication is solved, achieving efficient effect overlay and memory optimization.
Patent Information
- Application Number
- CN202410969470.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-11-12
AI Technical Summary
In the Unity engine, there is a problem of excessive memory waste caused by copying object models to overlay effects.
By acquiring the coordinate information, color intensity adjustment factor, and preset target color of the mask texture image, effect information is superimposed based on color fusion, avoiding the copying and overlapping process of the object model.
It simplifies the effect stacking process, reduces memory overhead, and improves the flexibility and efficiency of effect stacking.
Smart Images

Figure CN118941685A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a method, device, electronic device, storage medium and program product for effect superposition based on a unity engine. Background Art
[0002] Unity engine is a widely used game development and real-time rendering platform. In Unity, Shader is a key technology used to define the appearance and lighting effects of objects. In order to create richer and more realistic visual effects, developers usually need to overlay multiple effects on the same area of the object model.
[0003] Currently, at least one object model is generally copied, and the effect of the area to be superimposed on the copied object model is replaced to obtain the copied object model after the effect is replaced, and the copied object model after the effect is replaced and the original object model are overlapped accordingly to achieve the effect superposition of the area to be superimposed on the object model. However, the object model will occupy a certain amount of memory resources, which leads to excessive memory overhead. Summary of the invention
[0004] The present application provides a method, device, electronic device, storage medium and program product for effect superposition based on the Unity engine, which is used to solve the problem of replacing the effect of the area to be superimposed on the copied object model by copying at least one object model to obtain the copied object model after the effect is replaced, and overlapping the copied object model after the effect is replaced with the original object model accordingly, thereby realizing the effect superposition of the area to be superimposed on the object model, but the object model will occupy a certain amount of memory resources, which leads to a technical problem of excessive memory overhead.
[0005] In a first aspect, the present application provides an effect superposition method based on a unity engine, comprising:
[0006] At least two mask texture images, coordinate information corresponding to each of the mask texture images, a corresponding color intensity adjustment factor, and a corresponding preset target color are obtained; the preset target color is a display color of the texture in each of the mask texture images.
[0007] Determining color information of each mask texture image based on coordinate information of each mask texture image;
[0008] Determining effect information of each mask texture image based on color information of each mask texture image, a corresponding color intensity adjustment factor, and a corresponding preset target color;
[0009] The effect information of each of the mask texture images is superimposed to obtain target effect information.
[0010] In a possible design, determining the color information of each of the mask texture images based on the coordinate information of each of the mask texture images includes:
[0011] Using a preset function and based on the coordinate information of each mask texture image, the pixel points of each mask texture image are sampled respectively to obtain color information of at least one pixel point in each mask texture image;
[0012] The color information of at least one pixel in each of the mask texture images is determined as the color information of each mask texture image.
[0013] In a possible design, determining the effect information of each mask texture image based on the color information of each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color includes:
[0014] Determining any one of the mask texture images as a main mask texture image, and determining each mask texture image except the main mask texture image as an auxiliary mask texture image;
[0015] Determining effect information of the main mask texture image based on color information of the main mask texture image, a corresponding color intensity adjustment factor, and a preset target color;
[0016] The effect information of each auxiliary mask texture image is determined based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color.
[0017] In a possible design, the color information includes color data of a preset number of color channels;
[0018] The determining the effect information of the main mask texture image based on the color information of the main mask texture image and the corresponding color intensity adjustment factor and the preset target color includes:
[0019] The preset target color of the main mask texture image, the color data of any color channel in the main mask texture image and the corresponding color intensity adjustment factor are multiplied to obtain effect information of the main mask texture image.
[0020] In a possible design, determining the effect information of each auxiliary mask texture image based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color includes:
[0021] The preset target color corresponding to each auxiliary mask texture image, the color data of any color channel in the corresponding auxiliary mask texture image, and the corresponding color intensity adjustment factor are correspondingly multiplied to obtain initial effect information of each auxiliary mask texture image;
[0022] The initial effect information of each auxiliary mask texture image is multiplied with the color data of any color channel in the main mask texture image to obtain the effect information of each auxiliary mask texture image; any color channel in the main mask texture image and any color channel in each auxiliary mask texture image are the same color channel.
[0023] In a possible design, after the effect information of each mask texture image is superimposed to obtain target effect information, the method further includes:
[0024] Acquire a target area; the target area is an area to be subjected to effect superposition;
[0025] Constructing a material ball; the material ball is used to describe target effect information;
[0026] The target effect information is added to the material ball to obtain a material ball with the target effect information; the material ball with the target effect information is bound to the area to be superimposed with the effect to obtain a target area with the target effect information.
[0027] In a second aspect, the present application provides an effect superposition device based on a unity engine, comprising:
[0028] An acquisition module, used to acquire at least two mask texture images, coordinate information corresponding to each of the mask texture images and a corresponding color intensity adjustment factor and a corresponding preset target color;
[0029] A determination module, used to determine the color information of each mask texture image based on the coordinate information of each mask texture image;
[0030] The determination module is further used to determine the effect information of each mask texture image based on the color information of each mask texture image and the corresponding color intensity adjustment factor and the corresponding preset target color;
[0031] The processing module is used to perform superposition processing on the effect information of each mask texture image to obtain target effect information.
[0032] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0033] The memory stores computer-executable instructions;
[0034] The processor executes the computer-executable instructions stored in the memory to implement the method as described in any one of the first aspects.
[0035] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method as described in any one of the first aspects.
[0036] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0037] The effect superposition method, device, electronic device, storage medium and program product based on the unity engine provided by the present application are obtained by obtaining at least two mask texture images, the coordinate information corresponding to each of the mask texture images, the corresponding color intensity adjustment factor and the corresponding preset target color; the preset target color is the display color of the texture in each of the mask texture images. The color information of each mask texture image is determined based on the coordinate information of each mask texture image; the effect information of each mask texture image is determined based on the color information of each mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color; the effect information of each mask texture image is superimposed to obtain the target effect information. Since the effect superposition is required, at least two mask texture images and the corresponding coordinate information and the corresponding color intensity adjustment factor of each mask texture image and the corresponding preset target color are obtained. The preset target color is used to set the display color of the texture in each mask texture image. By changing the preset target color, the final color of the texture in each mask texture image can be adjusted. The color intensity adjustment factor can adjust the strength of the color in the mask texture image. The coordinate information of the mask texture image contains the position information of each mask texture image. Therefore, the color information of each mask texture image is determined by the coordinate information of each mask texture image. Furthermore, since there are differences in the preset target colors and intensity adjustment factors of each mask texture image and the texture patterns in the mask texture image, the effect information of each mask texture image can be determined by the color information of each mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color, and the target effect information can be obtained by superimposing and calculating the effect information of each mask texture image, and the target effect information can be applied to any area of the corresponding object model, so that the display effect of multiple effect superposition can be achieved in the corresponding area of the corresponding object model. In the process of effect superposition, the object model is no longer copied, the effect is added to the copied object model, and the object model after the effect is added is overlapped to achieve the effect superposition, but the effect is adjusted based on the mask texture image, and the effect superposition is achieved in the form of color fusion to obtain the target effect information, thereby simplifying the effect superposition process and reducing memory overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0039] Figure 1 An application scenario diagram of an effect superposition method based on the unity engine provided in one embodiment of the present application;
[0040] Figure 2A flowchart of a method for overlaying effects based on the Unity engine provided in one embodiment of the present application;
[0041] Figure 3 A flowchart of an effect superposition method based on the unity engine provided in another embodiment of the present application;
[0042] Figure 4 A schematic diagram of the structure of an effect superposition device based on the unity engine provided in one embodiment of the present application;
[0043] Figure 5 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application.
[0044] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0045] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0046] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.
[0047] At present, when realizing multiple effect superposition in the same area, it is usually necessary to copy the object model corresponding to the area to be superimposed by the effect, copy the corresponding number of object models according to the number of superimposed effects that need to be superimposed, add new effects to the area to be superimposed of the copied object models, and after adding the corresponding effects to the area to be superimposed corresponding to each object model, overlap the object models accordingly, so as to realize the effect superposition of the object model corresponding to the area to be superimposed by the effect. However, copying each object model consumes memory resources, which leads to excessive memory overhead.
[0048] The effect superposition method based on the unity engine provided in this application is intended to solve the above technical problems of the prior art.
[0049] Therefore, in the face of the technical problems in the prior art, in order to reduce the memory overhead when the effect is superimposed, the method of copying the object model is no longer used to achieve the effect superposition, but the color fusion of the mask texture images with different effects is performed to achieve the effect superposition, obtain the target effect information, and can be applied to any area of the object model. Specifically, first obtain at least two mask texture images, the coordinate information corresponding to each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color. The mask texture image is the image to be superimposed with the effect, and the color intensity adjustment factor can adjust the color strength of each mask texture image. The preset target color is the final display color of the texture in the mask texture image. The coordinate information of the mask texture image can locate the position information of the mask texture image. Therefore, the color information of each mask texture image is determined by the coordinate information of each mask texture image. The color information contains the color data of the pixel points in each mask texture image. Therefore, the effect information of each mask texture image can be determined based on the color data of each mask texture image, the color intensity adjustment factor corresponding to each mask texture image, and the corresponding preset target color, so that the determined effect information of each mask texture image is superimposed, and then the target effect information is obtained. When you need to add multiple effects to any area of an object model, you can apply the obtained target effect information to the corresponding area of the object model. You no longer need to copy multiple object models to realize multiple effects in the corresponding area, thereby simplifying the effect superposition process and reducing system memory overhead.
[0050] Figure 1 An application scenario diagram of the effect superposition method based on the unity engine provided in one embodiment of the present application, such as Figure 1As shown. In the system corresponding to the effect superposition method based on the unity engine in the embodiment of the present application, it may include: a client device 11 and a server device 12. The server device 12 may be an electronic device. The client device 11 is used to display the client, and the client has a user operation interface. The user can select and set the mask texture image, the preset target color corresponding to each mask texture image, and the corresponding intensity adjustment factor through the user operation interface, and initiate an effect superposition request to the server device 12. The server device 12 receives the effect superposition request, obtains at least two mask texture images, the color intensity adjustment factor corresponding to each mask texture image, and the corresponding preset target color from the preset database, and obtains the corresponding coordinate information through each mask texture image. Then, the color information of each mask texture image is determined through the coordinate information of each mask texture image, and the effect information corresponding to each mask texture image is determined through the color information of each mask texture image, the intensity adjustment factor corresponding to each mask texture image, and the corresponding preset target color. Further, the target effect information is obtained by adding the effect information corresponding to each mask texture image. After the target effect information is determined, the target effect information can be saved in a preset database, and the target effect information and a prompt message indicating that the effect superposition is completed are sent to the client device 11. The user can view the target effect information on the user interface of the client device 11.
[0051] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0052] Figure 2 A flowchart of a method for effect superposition based on the unity engine provided in an embodiment of the present application, such as Figure 2 As shown, the execution subject of this embodiment is an effect superposition device based on the unity engine, and the effect superposition device based on the unity engine is located in an electronic device. The effect superposition device based on the unity engine can be implemented by a computer program, or by a medium storing relevant computer programs, such as a USB flash drive and / or a CD, etc.; or, it can also be implemented by a physical device integrated or installed with relevant computer programs, such as a chip, an electronic device, etc. Specifically, the electronic device can be a server-side device. The effect superposition method based on the unity engine provided in this embodiment includes the following steps:
[0053] S201, obtaining at least two mask texture images, coordinate information corresponding to each mask texture image and a corresponding color intensity adjustment factor and a corresponding preset target color;
[0054] Among them, the mask texture image is the image to be superimposed with effects. The coordinate information of the mask texture image is the position information of each pixel in the mask texture image, and the coordinate information of each pixel is a UV coordinate. The UV coordinate is a two-dimensional vector composed of two floating-point numbers (U, V), which correspond to the horizontal and vertical directions of the mask texture image respectively. In Unity, the origin of the UV coordinate system is located at the lower left corner of the mask texture image, the u value increases along the width direction of the mask texture image, and the v value increases along the height direction of the mask texture image. The value range of the UV coordinate is usually between 0 and 1, where (0,0) represents the pixel in the lower left corner of the mask texture image, and (1,1) represents the pixel in the upper right corner of the mask texture image.
[0055] Optionally, the color intensity adjustment factor is a factor for adjusting the color intensity in the mask texture image, which is a numerical value. The color intensity adjustment factor corresponding to each mask texture image may be a different numerical value, which is not limited in this embodiment.
[0056] Optionally, the preset target color is the display color of the texture in each mask texture image. The preset target color corresponding to each mask texture image may be a different color, which is not limited in this embodiment.
[0057] It is understandable that the Unity engine is a cross-platform game engine that is used in game development, architectural visualization, virtual reality (VR), augmented reality (AR), and the creation of more interactive 3D and 2D content.
[0058] Specifically, in this embodiment, the user can trigger an effect overlay request on the client interface and send it to the server device. The server device responds to the effect overlay request, obtains at least two mask texture images, the color intensity adjustment factors corresponding to each mask texture image, and the corresponding preset target color from a preset database, and obtains the corresponding coordinate information through each mask texture image.
[0059] S202: Determine color information of each mask texture image based on coordinate information of each mask texture image.
[0060] The color information of the mask texture image is the color information of the pixels in the mask texture image.
[0061] Specifically, in this embodiment, a preset method is used to perform color sampling at a position corresponding to the coordinate information of each mask texture image, thereby obtaining color information of each mask texture image.
[0062] Optionally, the preset method may be function sampling, etc., which is not limited in this embodiment.
[0063] S203 : Determine effect information of each mask texture image based on the color information of each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color.
[0064] The effect information of the mask texture image is data information corresponding to the visual effect displayed by the mask texture image.
[0065] Specifically, in this embodiment, the effect information of each mask texture image is determined by performing a preset calculation on the color information of each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color.
[0066] S204, superimposing the effect information of each mask texture image to obtain target effect information.
[0067] Among them, the target effect information is the effect information after the effect superposition is achieved.
[0068] Specifically, in this embodiment, the obtained effect information corresponding to each mask texture image is added, and the added effect information is used as the target effect information.
[0069] The effect superposition method based on the unity engine provided by the present application obtains at least two mask texture images, the coordinate information corresponding to each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color; the preset target color is the display color of the texture in each mask texture image. The color information of each mask texture image is determined based on the coordinate information of each mask texture image; the effect information of each mask texture image is determined based on the color information of each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color; the effect information of each mask texture image is superimposed to obtain the target effect information. Since the effect superposition is required, at least two mask texture images and the corresponding coordinate information of each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color are obtained. The preset target color is used to set the display color of the texture in each mask texture image. By changing the preset target color, the final color of the texture in each mask texture image can be adjusted. The color intensity adjustment factor can adjust the strength of the color in the mask texture image. The coordinate information of the mask texture image contains the position information of each mask texture image. Therefore, the color information of each mask texture image is determined by the coordinate information of each mask texture image. Furthermore, since there are differences in the preset target colors and intensity adjustment factors of each mask texture image and the texture patterns in the mask texture image, the effect information of each mask texture image can be determined by the color information of each mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color, and the target effect information can be obtained by superimposing and calculating the effect information of each mask texture image, and the target effect information can be applied to any area of the corresponding object model, so that the display effect of multiple effect superposition can be achieved in the corresponding area of the corresponding object model. In the process of effect superposition, the object model is no longer copied, the effect is added to the copied object model, and the object model after the effect is added is overlapped to achieve the effect superposition, but the effect is adjusted based on the mask texture image, and the effect superposition is achieved in the form of color fusion to obtain the target effect information, thereby simplifying the effect superposition process and reducing memory overhead.
[0070] As an optional implementation manner, based on the above embodiment, determining the color information of each mask texture image based on the coordinate information of each mask texture image includes:
[0071] Using a preset function and based on the coordinate information of each mask texture image, the pixel points of each mask texture image are sampled respectively to obtain color information of at least one pixel point in each mask texture image;
[0072] The color information of at least one pixel in each mask texture image is determined as the color information of each mask texture image.
[0073] Specifically, in this embodiment, according to the coordinate information of each mask texture image, the color sampling of the pixel points of each mask texture image is performed respectively through the tex2D function to obtain the color information of at least one pixel point corresponding to each mask texture image, and then the color information of at least one pixel point corresponding to each mask texture image is determined as the color information of each mask texture image.
[0074] Optionally, the preset function may be a tex2D function or other functions, which is not limited in this embodiment.
[0075] Among them, tex2D is a function in Unity, which is used to sample color from a 2D texture and obtain the color value at the coordinates of the mask texture image.
[0076] The effect superposition method based on the unity engine provided by the present application determines the color information of each mask texture image based on the coordinate information of each mask texture image, including: using a preset function and sampling the pixels of each mask texture image based on the coordinate information of each mask texture image to obtain the color information of at least one pixel in each mask texture image; determining the color information of at least one pixel in each mask texture image as the color information of each mask texture image. Since the coordinate information of the mask texture image contains the position information corresponding to the mask texture image, the color information corresponding to the pixel in each mask texture image can be obtained by using a preset function based on the coordinate information of each mask texture image, and the accuracy and completeness of the color information corresponding to the pixel in each mask texture image are ensured.
[0077] As an optional implementation, based on the above embodiment, the effect information of each mask texture image is determined based on the color information of each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color, including:
[0078] Determine any one of the mask texture images as a main mask texture image, and determine each mask texture image other than the main mask texture image as an auxiliary mask texture image;
[0079] Determining effect information of the main mask texture image based on color information of the main mask texture image, a corresponding color intensity adjustment factor, and a preset target color;
[0080] The effect information of each auxiliary mask texture image is determined based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color.
[0081] Among them, the main mask texture image is the mask texture image that plays a leading role in the effect superposition. The auxiliary mask texture image is the mask texture image that plays an auxiliary role in the effect superposition. It can be understood that the main mask texture image is used as the basic image, and the effect of the auxiliary mask texture image is superimposed on it.
[0082] Specifically, in this embodiment, one of the mask texture images is selected as the main mask texture image, and the remaining mask texture images except the one selected as the main mask texture image are used as auxiliary mask texture images. For example, the first mask texture image read can be used as the main mask texture image, and then the mask texture images read subsequently are used as auxiliary mask texture images. The effect information of the main mask texture image is obtained by performing a preset calculation on the color information of the main mask texture image, the corresponding color intensity factor, and the corresponding preset target color, and the color information of the main mask texture image, so as to obtain the effect information of the auxiliary mask texture image. Similarly, the color information of the auxiliary mask texture image, the corresponding color intensity factor, the corresponding preset target color, and the color information of the main mask texture image are calculated in a preset manner, so as to obtain the effect information of the auxiliary mask texture image.
[0083] The effect superposition method based on the unity engine provided by the present application determines the effect information of each mask texture image based on the color information of each mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color, including: determining any one of the mask texture images as the main mask texture image, and determining each mask texture image other than the main mask texture image as the auxiliary mask texture image; determining the effect information of the main mask texture image based on the color information of the main mask texture image, the corresponding color intensity adjustment factor and the preset target color; determining the effect information of each auxiliary mask texture image based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image and the corresponding preset target color. Since the effect information of each mask texture image is superimposed, in order to simplify the effect control, the mask texture image is divided into a main mask texture image and an auxiliary mask texture image, and the effect information to be set for the main mask texture image is determined by the color information corresponding to the main mask texture image, the corresponding color intensity adjustment factor and the preset target color, and then the effect information to be set for each auxiliary mask texture image is determined by the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image and the corresponding preset target color, thereby realizing independent control of each mask texture image, and different effects can be set for different mask texture images according to needs, thereby enhancing the flexibility of effect setting of each mask texture image.
[0084] As an optional implementation, based on the above embodiment, the color information includes color data of a preset number of color channels;
[0085] The effect information of the main mask texture image is determined based on the color information of the main mask texture image, the corresponding color intensity adjustment factor and the preset target color, including:
[0086] The preset target color of the main mask texture image, the color data of any color channel in the main mask texture image and the corresponding color intensity adjustment factor are multiplied to obtain the effect information of the main mask texture image.
[0087] Optionally, the preset number may be 3, or a positive integer less than 3, which is not limited in this embodiment.
[0088] Among them, when the color information contains 3 color channels, they are red, green, and blue color channels, and the red, green, and blue color channels are each responsible for the color information of the pixels in the mask texture image. When the color channels in the color information are less than 3, its color channels are included in the red, green, and blue channels.
[0089] Specifically, in this embodiment, the preset target color in the main mask texture image and any color channel data and the color intensity adjustment factor in the main mask texture image are multiplied, and the multiplied data is used as the effect information of the main mask texture image.
[0090] The effect superposition method based on the unity engine provided by the present application comprises color information including color data of a preset number of color channels; the effect information of the main mask texture image is determined based on the color information of the main mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color, including: multiplying the corresponding preset target color of the main mask texture image, the color data of any color channel in the main mask texture image and the corresponding color intensity adjustment factor to obtain the effect information of the main mask texture image. Since the corresponding preset target color of the main mask texture image, the color data of any color channel in the main mask texture image and the corresponding color intensity adjustment factor are multiplied, the effect corresponding to the main mask texture image can be finely controlled by the preset target color and the color intensity adjustment factor, thereby realizing the autonomous adjustment of the main mask texture image and improving the flexibility of effect adjustment.
[0091] As an optional implementation manner, on the basis of the above embodiment, the effect information of each auxiliary mask texture image is determined based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color, including:
[0092] The preset target color corresponding to each auxiliary mask texture image, the color data of any color channel in the corresponding auxiliary mask texture image, and the corresponding color intensity adjustment factor are correspondingly multiplied to obtain the initial effect information of each auxiliary mask texture image;
[0093] The initial effect information of each auxiliary mask texture image is multiplied with the color data of any color channel in the main mask texture image to obtain the effect information of each auxiliary mask texture image.
[0094] Among them, any color channel in the main mask texture image and any color channel in each auxiliary mask texture image are the same color channel. If the main mask texture image uses the red channel value when calculating the effect information, then each auxiliary mask texture image also uses the red channel value for calculation when calculating the corresponding effect information.
[0095] Specifically, in this embodiment, the preset target color corresponding to each mask texture image, the color data of the color channel with the same color information as the calculated effect information of the main mask texture image corresponding to each auxiliary mask texture image, and the intensity adjustment factor corresponding to each mask texture image are obtained for multiplication calculation to obtain the initial effect information of each auxiliary mask texture image. Further, the initial effect information obtained by each mask texture image is multiplied with the color data of the color channel with the calculated effect information of the main mask texture image, so as to obtain the effect information of each mask texture image.
[0096] The effect superposition method based on the unity engine provided by the present application determines the effect information of each auxiliary mask texture image based on the color information of each auxiliary mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color, including: correspondingly multiplying the preset target color corresponding to each auxiliary mask texture image, the color data of any color channel in the corresponding auxiliary mask texture image and the corresponding color intensity adjustment factor to obtain the initial effect information of each auxiliary mask texture image; respectively multiplying the initial effect information of each auxiliary mask texture image with the color data of any color channel in the main mask texture image to obtain the effect information of each auxiliary mask texture image; any color channel in the main mask texture image and any color channel in each auxiliary mask texture image are the same color channel. Since the preset target color corresponding to each auxiliary mask texture image, the color data of any color channel in the corresponding auxiliary mask texture image and the corresponding color intensity adjustment factor are correspondingly multiplied, the color to be displayed by each mask texture image can be adjusted by the preset target color, and the intensity of the color channel in the auxiliary mask texture image can be adjusted by the intensity adjustment factor, so as to realize the initial effect adjustment of the auxiliary mask texture image and improve the flexibility of effect adjustment. Furthermore, by multiplying the main mask texture image, the uniformity of the data when the main mask texture image and the auxiliary mask texture image are superimposed during the effect superposition process is ensured.
[0097] As an optional implementation manner, based on the above embodiment, after the effect information of each mask texture image is superimposed to obtain the target effect information, the method further includes:
[0098] Get the target area;
[0099] Build the material ball;
[0100] Adding the target effect information to the material ball to obtain the material ball having the target effect information;
[0101] The material ball with the target effect information is bound to the target area to be overlaid with the effect to obtain the target area with the target effect information.
[0102] The target area is the area to be superimposed with effects, which can be any area corresponding to the object model in Unity. The object model is the model to which effects need to be added, which can be a 3D model.
[0103] Among them, the material ball is used to describe the target effect information. In Unity, the material ball is a visualization tool for representing and previewing material properties. The material ball integrates all material-related parameters and properties, allowing these properties to be intuitively edited and applied to 3D models.
[0104] It is understandable that color, reflectivity, etc. are all numerical parameters of the material appearance. A material ball is essentially a data structure containing a set of attributes and parameters that control the rendering effect of a 3D model.
[0105] Specifically, in this embodiment, the server device obtains a preset target area to which target effect information is to be added from a preset database, creates a material ball in Unity, and adds the data in the target effect information to the material ball, thereby making the material ball have the same properties as the target effect information, and by referencing the material ball with the target effect information in the target area, the target area is bound to the material ball with the target effect information, thereby realizing the rendering of the target effect information for the target area.
[0106] The effect superposition method based on the unity engine provided by the present application, after superimposing the effect information of each mask texture image to obtain the target effect information, also includes: obtaining the target area; the target area is the area to be subjected to effect superposition; constructing a material ball; the material ball is used to describe the target effect information; adding the target effect information to the material ball to obtain the material ball with the target effect information; binding the material ball with the target effect information to the area to be subjected to effect superposition to obtain the target area with the target effect information. Since the target area is obtained and the material ball is constructed, the target effect information can be added to the material ball and further bound to the target area, thereby realizing the rendering of the target effect information to the target area, and then realizing the visualization of the target effect information.
[0107] Figure 3 A flowchart of an effect superposition method based on the unity engine provided in another embodiment of the present application is shown in FIG. Figure 3 As shown, the execution subject of this embodiment is an effect superposition device based on the unity engine. The effect superposition method based on the unity engine provided in this embodiment includes the following steps:
[0108] S301, obtaining at least two mask texture images, coordinate information and corresponding color intensity adjustment factors corresponding to the at least two mask texture images, and corresponding preset target colors.
[0109] S302, based on the coordinate information of each mask texture image, use a preset function to sample the pixels of each mask texture image respectively to obtain color information of at least one pixel in each mask texture image as the color information of each mask texture image.
[0110] S303: Select any one of the mask textures as a main mask texture image, and select the mask texture images other than the main mask texture image as auxiliary mask texture images.
[0111] S304: multiplying a preset target color corresponding to the main mask texture image, color data of any color channel in the main mask texture image, and a corresponding color intensity adjustment factor to obtain effect information of the main mask texture image.
[0112] S305, respectively multiplying the preset target color corresponding to each auxiliary mask texture image, the color data of any color channel in the corresponding auxiliary mask texture image, and the corresponding color intensity adjustment factor, so as to obtain the initial effect information of each auxiliary mask texture image, and respectively multiplying the initial effect information of each auxiliary mask texture image with the color data of any color channel in the main mask texture image, so as to obtain the effect information of each auxiliary mask texture image.
[0113] S306: Add the effect information of the main mask texture image and the effect information of each auxiliary mask texture image to obtain target effect information.
[0114] S307, adding a preset dynamic effect based on the coordinate information corresponding to the main mask texture image and each auxiliary mask texture image.
[0115] Among them, after obtaining the target effect information, the coordinate information corresponding to each mask texture image can be preset to add dynamic effects to each mask texture image, so that different visual effects are displayed when the target effect information is displayed.
[0116] Optionally, the preset processing may be translating, scaling or adding a time variable to the coordinates of each mask texture image, etc., which is not limited in this embodiment. The preset processing performed on each mask texture image may be different processing.
[0117] Exemplarily, if there are two mask texture images, such as mask texture image A and mask texture image B, after mask texture image A and mask texture image B have determined the target effect information, the coordinate information of mask texture image A can be multiplied by the scaling and translation parameters, and the coordinate information of mask texture image B and the time variable can be added, so that when the target effect is performed, mask texture image A can have a scaling and translation display effect and mask texture image B can have a moving display effect.
[0118] Among them, scaling is a geometric transformation that can change the size of the mask texture image without changing its shape. Translation can move the mask texture image in space without changing its size and shape. In the Unity engine, the time variable can be a pre-defined variable, which can make the mask texture image have a visual effect of changing over time.
[0119] S308, obtaining the target area and constructing a material ball.
[0120] S309, adding the target effect information to the material ball, thereby binding the material ball with the target effect information added to the target area, thereby obtaining the target area with the target effect information.
[0121] Figure 4 A schematic diagram of the structure of an effect superposition device based on the unity engine provided in an embodiment of the present application, such as Figure 4 As shown, the effect superposition device based on the unity engine provided in this embodiment is located in an electronic device, and the effect superposition device 40 based on the unity engine provided in this embodiment includes: an acquisition module 41, a determination module 42, and a processing module 43.
[0122] Among them, the acquisition module 41 is used to obtain at least two mask texture images, the coordinate information corresponding to each mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color; the preset target color is the display color of the texture in each mask texture image; the determination module 42 is used to determine the color information of each mask texture image based on the coordinate information of each mask texture image; the determination module 42 is also used to determine the effect information of each mask texture image based on the color information of each mask texture image, the corresponding color intensity adjustment factor and the corresponding preset target color; the processing module 43 is used to superimpose the effect information of each mask texture image to obtain the target effect information.
[0123] The effect superposition device based on the unity engine provided in this embodiment can be executed Figure 2 The specific implementation principles and technical effects of the method embodiments shown are similar and will not be repeated here.
[0124] Optionally, when determining the color information of each mask texture image based on the coordinate information of each mask texture image, the determination module 42 is specifically configured to:
[0125] A preset function is used and based on the coordinate information of each mask texture image, pixel points of each mask texture image are sampled respectively to obtain color information of at least one pixel point in each mask texture image; and the color information of at least one pixel point in each mask texture image is determined as the color information of each mask texture image.
[0126] Optionally, the determination module 42, when determining the effect information of each mask texture image based on the color information of each mask texture image and the corresponding color intensity adjustment factor and the corresponding preset target color, is specifically used to:
[0127] Any one of the mask texture images is determined as the main mask texture image, and each mask texture image other than the main mask texture image is determined as an auxiliary mask texture image; the effect information of the main mask texture image is determined based on the color information of the main mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color; the effect information of each auxiliary mask texture image is determined based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color.
[0128] Optionally, the color information includes color data of a preset number of color channels.
[0129] Accordingly, when determining the effect information of the main mask texture image based on the color information of the main mask texture image and the corresponding color intensity adjustment factor and the corresponding preset target color, the determination module 42 is specifically used to:
[0130] The corresponding preset target color of the main mask texture image, the color data of any color channel in the main mask texture image and the corresponding color intensity adjustment factor are multiplied to obtain the effect information of the main mask texture image.
[0131] Optionally, the determination module 42, when determining the effect information of each auxiliary mask texture image based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color, is specifically used to:
[0132] The preset target color corresponding to each auxiliary mask texture image, the color data of any color channel in the corresponding auxiliary mask texture image, and the corresponding color intensity adjustment factor are correspondingly multiplied to obtain the initial effect information of each auxiliary mask texture image; the initial effect information of each auxiliary mask texture image is respectively multiplied with the color data of any color channel in the main mask texture image to obtain the effect information of each auxiliary mask texture image; any color channel in the main mask texture image and any color channel in each auxiliary mask texture image are the same color channel.
[0133] Optionally, the effect superposition device based on the unity engine provided in this embodiment further includes: a construction module.
[0134] Correspondingly, the acquisition module 41 is also used to: after the effect information of each mask texture image is superimposed to obtain the target effect information, obtain the target area, the target area is the area to be superimposed. The construction module is specifically used to construct a material ball, the material ball is used to describe the target effect information. The processing module 43 is also used to: add the target effect information to the material ball to obtain the material ball with the target effect information. The processing module 43 is also used to bind the material ball with the target effect information with the target area to be superimposed to obtain the target area with the target effect information.
[0135] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application is as follows: Figure 5 As shown, the electronic device 50 provided in this embodiment includes: a processor 51, and a memory 52 communicatively connected to the processor.
[0136] The memory 51 stores computer-executable instructions; the processor 51 executes the computer-executable instructions stored in the memory 52 to implement the effect superposition method based on the unity engine provided in any of the above embodiments. The relevant description can be understood by referring to the relevant descriptions and effects corresponding to the steps in the accompanying drawings, and no further details are given here.
[0137] The program may include program codes, and the program codes include computer-executable instructions. The memory 52 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.
[0138] In this embodiment, the memory 52 and the processor 51 are connected via a bus. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0139] The embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the effect superposition method based on the unity engine provided in any of the above embodiments. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0140] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the effect superposition method based on the unity engine provided in any one of the above embodiments.
[0141] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0142] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0143] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0144] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0145] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not specifically stated, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not specifically stated, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0146] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0147] 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. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0148] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0149] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. An effect superposition method based on unity engine, characterized in that: include: Acquire at least two mask texture images, coordinate information corresponding to each of the mask texture images, a corresponding color intensity adjustment factor, and a corresponding preset target color; the preset target color is a display color of a texture in each of the mask texture images; Determining color information of each mask texture image based on coordinate information of each mask texture image; Determining effect information of each mask texture image based on color information of each mask texture image, a corresponding color intensity adjustment factor, and a corresponding preset target color; The effect information of each of the mask texture images is superimposed to obtain target effect information.
2. The method according to claim 1, characterized in that The step of determining the color information of each of the mask texture images based on the coordinate information of each of the mask texture images comprises: Using a preset function and based on the coordinate information of each mask texture image, the pixel points of each mask texture image are sampled respectively to obtain color information of at least one pixel point in each mask texture image; The color information of at least one pixel in each of the mask texture images is determined as the color information of each of the mask texture images.
3. The method according to claim 1, characterized in that The determining of the effect information of each mask texture image based on the color information of each mask texture image, the corresponding color intensity adjustment factor, and the corresponding preset target color includes: Determining any one of the mask texture images as a main mask texture image, and determining each mask texture image except the main mask texture image as an auxiliary mask texture image; Determining effect information of the main mask texture image based on color information of the main mask texture image, a corresponding color intensity adjustment factor, and a preset target color; The effect information of each auxiliary mask texture image is determined based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color.
4. The method according to claim 3, characterized in that The color information includes color data of a preset number of color channels; The determining the effect information of the main mask texture image based on the color information of the main mask texture image and the corresponding color intensity adjustment factor and the preset target color includes: The preset target color of the main mask texture image, the color data of any color channel in the main mask texture image and the corresponding color intensity adjustment factor are multiplied to obtain effect information of the main mask texture image.
5. The method according to claim 3, characterized in that: The determining of the effect information of each auxiliary mask texture image based on the color information of each auxiliary mask texture image, the color information of the main mask texture image, the color intensity adjustment factor corresponding to each auxiliary mask texture image, and the corresponding preset target color includes: The preset target color corresponding to each auxiliary mask texture image, the color data of any color channel in the corresponding auxiliary mask texture image, and the corresponding color intensity adjustment factor are correspondingly multiplied to obtain initial effect information of each auxiliary mask texture image; The initial effect information of each auxiliary mask texture image is multiplied with the color data of any color channel in the main mask texture image to obtain the effect information of each auxiliary mask texture image; any color channel in the main mask texture image and any color channel in each auxiliary mask texture image are the same color channel.
6. The method according to claim 1, characterized in that After the effect information of each mask texture image is superimposed to obtain target effect information, the method further includes: Acquire a target area; the target area is an area to be subjected to effect superposition; Constructing a material ball; the material ball is used to describe target effect information; Adding the target effect information to the material ball to obtain a material ball with the target effect information; The material ball with the target effect information is bound to the target area to be overlaid with the effect to obtain the target area with the target effect information.
7. An effect superposition device based on unity engine, characterized in that: include: An acquisition module, used to acquire at least two mask texture images, coordinate information corresponding to each of the mask texture images, a corresponding color intensity adjustment factor, and a corresponding preset target color; the preset target color is a display color of a texture in each of the mask texture images; A determination module, used to determine the color information of each mask texture image based on the coordinate information of each mask texture image; The determination module is further used to determine the effect information of each mask texture image based on the color information of each mask texture image and the corresponding color intensity adjustment factor and the corresponding preset target color; The processing module is used to perform superposition processing on the effect information of each mask texture image to obtain target effect information.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.
