Texture image generation method, device and electronic device

By performing preset direction sampling and texture coordinate superposition processing on the texture space, and combining the linear texture function to generate texture images, the problem of low texture image generation efficiency is solved, the texture effect of thin lines and high resolution is achieved, and the rendering load is reduced and game capacity.

CN113658064BActive Publication Date: 2024-11-22NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110888025.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-03
Publication Date
2024-11-22
Estimated Expiration
2041-08-03

AI Technical Summary

Technical Problem

In the prior art, texture image generation efficiency is low, making it difficult to generate texture maps with thin lines and high resolution, resulting in blurring of lines and increasing rendering load, affecting game performance.

Method used

By sampling preset directions on the texture space, noise results are obtained, and texture coordinates are superimposed according to the noise results. Texture images are generated using the preset linear texture function, texture parameters are adjusted to realize dynamic waveform texture, reducing texture sampling process and rendering load.

Benefits of technology

Improves the efficiency of texture image generation, reduces rendering load and game capacity, and achieves fine lines and high-resolution texture effects, and generates delicate waveform textures without high-resolution texture images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113658064B_ABST
    Figure CN113658064B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and electronic device for generating a texture image. The method comprises: sampling a noise texture image in a preset direction in a texture space to obtain a noise result; performing a superposition process on texture coordinates in the texture space according to the noise result to obtain a disturbed texture space; generating a texture image in the disturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust texture parameters in the texture image, and the texture image at least includes a waveform texture that changes with time. The present invention solves the technical problem of low efficiency in generating texture images in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to a method, device and electronic equipment for generating a texture image. Background Art

[0002] Visual representations of sound waves, electrocardiograms, magnetic fields, etc. are common special effect textures in games, and special effect textures are usually achieved through noise perturbation. Specifically, the noise map is first sampled to obtain noise information, and then the noise information is superimposed on the texture space of the model piece, the texture in the texture image is perturbed, and then the original texture lines are sampled using the perturbed texture coordinates to obtain the perturbed waveform texture. In the process of sampling the noise texture, the noise texture can be translated, stretched, and other operations can be performed on the noise texture, so that the noise value of each pixel can change in real time, and the final waveform texture can change dynamically.

[0003] In the above process, since the noise map is usually a single-channel (for example, a grayscale image) image or a multi-channel map (for example, containing RGB information or RGBA information) image, and the required disturbance information of the texture space is a two-dimensional vector (that is, the disturbance amount in the horizontal and vertical directions), therefore, in the process of converting the noise information into the texture space, the values ​​of the two channels are usually extracted from the noise map. In the single-channel scene, it is considered that the values ​​of the two required channels are the same, so that two values ​​ranging from 0 to 1 can be obtained, and then the two values ​​are mapped, and then the two mapped values ​​are used to form a two-dimensional vector, which is superimposed as disturbance information in the subsequent process.

[0004] However, in the above-mentioned noise texture perturbation method for generating dynamic waveform texture, after obtaining the noise information, due to the existence of disturbance information in the horizontal and vertical directions of the texture space, as a waveform effect, it is usually only desired to generate disturbance in the direction perpendicular to the waveform line, and for each point on the waveform line, the disturbance amount in this direction should preferably be exactly the same, or at least approximately the same, so as to prevent the disturbance from causing multiple closed lines, or blurring caused by pulling and widening the disturbed lines.

[0005] If the user needs to obtain a texture map with thinner waveform lines, a texture line map with thinner lines and higher resolution is required to make the lines thin enough and not blurred; if the user wants to obtain a texture map with sharper line edges, a texture line map with higher resolution is required. In addition, when making a dynamic waveform texture effect, in order to prevent the lines from being disturbed by noise information and causing unnecessary pulling, it is necessary to specially modify and make the corresponding noise map so that the vertical change of the line is small, and the disturbance parallel to the line direction is 0. This method is cumbersome to operate and has low processing efficiency. If the user wants the texture lines to be thinner or the texture line edges to be sharper, a map with higher resolution is required, which not only increases the capacity of the map in the game package, but also increases the sampling load during the rendering process, reducing the processing efficiency of the texture image.

[0006] To address the above-mentioned problems, no effective solution has been proposed yet.

[0007] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0008] The embodiments of the present invention provide a method, device and electronic device for generating a texture image, so as to at least solve the technical problem of low efficiency in generating a texture image in the prior art.

[0009] According to one aspect of an embodiment of the present invention, a method for generating a texture image is provided, comprising: sampling a noise texture image in a preset direction in a texture space to obtain a noise result; performing superposition processing on texture coordinates in the texture space according to the noise result to obtain a disturbed texture space; and generating a texture image in the disturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust texture parameters in the texture image, and the texture image at least includes a waveform texture that changes with time.

[0010] Furthermore, the texture image generation method further includes: after generating the texture image in the disturbed texture space based on a preset straight line texture function, generating a waveform animation based on the texture image, wherein the waveform animation at least includes a waveform texture that changes with time.

[0011] Furthermore, the method for generating a texture image also includes: sampling the noise texture image in a first direction in the texture space based on the sampling density to obtain a first sampling result, wherein the sampling density includes at least a first numerical value in the first direction, and the first numerical value is less than a preset value; sampling the first sampling result in a second direction in the texture space to obtain a noise result, wherein the first direction is different from the second direction.

[0012] Furthermore, the method for generating a texture image also includes: obtaining a first coordinate in the first direction and a second coordinate in the second direction for each pixel of the noise texture image in the texture space, wherein the sampling density also includes a second value in the second direction; calculating the product of the first coordinate and the first value to obtain a third coordinate; calculating the product of the second coordinate and the second value to obtain a fourth coordinate; calculating the product of a preset time parameter and a moving speed to obtain a product result, wherein the moving speed represents the speed of the moving noise texture image; and obtaining a first sampling result based on the third coordinate, the fourth coordinate and the product result.

[0013] Furthermore, the texture image generation method also includes: obtaining coordinate information corresponding to the first sampling result; mapping the coordinate information to a preset coordinate range to obtain target noise information; obtaining noise component information of the target noise information in a second direction to obtain a noise result.

[0014] Furthermore, the method for generating a texture image also includes: performing a superposition process on the coordinates of each pixel point in the texture space according to the noise component information to obtain a disturbed texture space.

[0015] Furthermore, the method for generating a texture image also includes: generating a texture image in the disturbed texture space according to width value information of the waveform texture in the texture image and / or position information of the waveform texture in the texture image and / or background color information of the texture image and / or color information of the waveform texture, wherein the preset straight line texture function includes one or more of the following information: width value information, position information, background color information and color information.

[0016] Furthermore, the method for generating a texture image also includes: obtaining a first width value and a second width value of a waveform texture, wherein the width value information of the waveform texture includes at least the first width value and the second width value, the waveform texture includes a display part and a transition part, the transition part represents the part where the waveform texture transitions to the background color of the texture image, the first width value represents the difference between the width of the display part and the width of the transition part, and the second width value represents the width of the display part; calculating the difference between the first width value and the second width value to obtain a first difference; calculating the distance between the position of the waveform texture in the texture image and the position of each pixel in the waveform texture.

[0017] A second difference is obtained according to the distance and the first width value; a first ratio is obtained according to the first difference and the second difference; and color information of the waveform texture and background color information of the texture image are adjusted according to the first ratio.

[0018] Furthermore, the method for generating a texture image also includes: obtaining a first width value and a second width value of a waveform texture, wherein the width value information of the waveform texture includes at least the first width value and the second width value, the waveform texture includes a display part and a transition part, the transition part represents the part where the waveform texture transitions to the background color of the texture image, the first width value represents the difference between the width of the display part and the width of the transition part, and the second width value represents the width of the display part; obtaining a first difference based on the first width value and the second width value; and adjusting the blurriness of the waveform texture based on the first difference.

[0019] Furthermore, the method for generating a texture image also includes: obtaining a first width value and a second width value of a waveform texture, wherein the width value information of the waveform texture includes at least the first width value and the second width value, the waveform texture includes a display part and a transition part, the transition part represents the part where the waveform texture transitions to the background color of the texture image, the first width value represents the difference between the width of the display part and the width of the transition part, and the second width value represents the width of the display part; adjusting the width of the waveform texture according to the size of the first width value and / or the second width value.

[0020] According to another aspect of an embodiment of the present invention, a texture image generation device is also provided, including: a sampling module, used to sample a noise texture image in a preset direction in a texture space to obtain a noise result; a processing module, used to perform superposition processing on texture coordinates in the texture space according to the noise result to obtain a disturbed texture space; a generation module, used to generate a texture image in the disturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust texture parameters in the texture image, and the texture image at least includes a waveform texture that changes with time.

[0021] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned method for generating a texture image when running.

[0022] According to another aspect of an embodiment of the present invention, an electronic device is also provided, which includes one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors are implemented to run the programs, wherein the programs are configured to execute the above-mentioned method for generating a texture image when running.

[0023] In an embodiment of the present invention, a texture image is disturbed by sampling a noise texture image in a preset direction in a texture space to obtain a noise result. Then, texture coordinates in the texture space are superimposed according to the noise result to obtain a disturbed texture space. Finally, a texture image is generated in the disturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust texture parameters of the texture in the texture image, and the texture image at least includes a waveform texture that changes with time.

[0024] In the above process, any noise texture image can be sampled to obtain a noise result. Any noise texture map can generate a texture image without special processing, and no additional modification process is required, thereby improving the efficiency of texture image generation. In addition, in the present application, the texture space is firstly superimposed to generate a disturbed texture space, and then a texture image is generated in the disturbed texture space based on a preset straight line texture function. This process does not involve the processing of the texture image, which reduces the texture sampling process of the texture image in the prior art, reduces the rendering load of the texture image, and increases the total capacity of the game. In addition, the texture parameters in the texture image can be adjusted through the preset straight line texture function, so that the adjustment of the waveform texture in the texture image can be achieved without the need for a higher resolution texture image.

[0025] It can be seen that the solution provided in the present application achieves the purpose of generating texture images, thereby realizing the technical effect of improving the efficiency of texture image generation, and further solving the technical problem of low texture image generation efficiency in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0027] Figure 1 is a flow chart of a method for generating a texture image according to an embodiment of the present invention;

[0028] Figure 2 is a schematic diagram of an optional texture image according to an embodiment of the present invention;

[0029] Figure 3 is a schematic diagram of a texture image of an optional waveform texture according to an embodiment of the present invention;

[0030] Figure 4 is a schematic diagram of an optional texture image according to an embodiment of the present invention;

[0031] Figure 5is a schematic diagram of an optional texture image according to an embodiment of the present invention;

[0032] Figure 6 is a schematic diagram of an optional texture image according to an embodiment of the present invention;

[0033] Figure 7 It is a schematic diagram of a device for generating a texture image according to an embodiment of the present invention. DETAILED DESCRIPTION

[0034] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0035] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0036] According to an embodiment of the present invention, an embodiment of a method for generating a texture image is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0037] In addition, it should be noted that, in this embodiment, a pixel shader can be used as an execution subject of the method provided in this embodiment, wherein the pixel shader is an instruction for rendering pixels in vertices.

[0038] Figure 1 is a flow chart of a method for generating a texture image according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:

[0039] Step S102, sampling the noise texture image in a preset direction in the texture space to obtain a noise result.

[0040] In step S102, the texture space may be a UV space, the noise texture image may be any texture image, and the noise result at least includes noise information, wherein the noise information includes but is not limited to coordinate information and color information of the noise.

[0041] In an optional embodiment, the pixel shader may sample the noise texture image according to a preset sampling density, and the pixel shader may sample the noise texture image in a preset direction according to the preset sampling density, wherein the preset direction at least includes a first direction and a second direction, and the first direction and the second direction are different directions, for example, the first direction is longitudinal, and the second direction is transverse. Optionally, in this embodiment, the first direction is longitudinal and the second direction is transverse as an example for description.

[0042] Step S104, performing superposition processing on the texture coordinates in the texture space according to the noise result to obtain a disturbed texture space.

[0043] Optionally, in step S104, the pixel shader may superimpose the noise result on the coordinate value of each pixel in the texture space, thereby disturbing the texture space and obtaining the disturbed texture space. The pixel shader may superimpose the texture space by multiplying the noise result with the coordinate value of the pixel.

[0044] Step S106: Generate a texture image in the disturbed texture space based on a preset straight line texture function, wherein the texture image at least includes a waveform texture that changes with time.

[0045] In step S106, the preset straight line texture function is used to adjust the texture parameters in the texture image, wherein the texture parameters include but are not limited to the width value information of the waveform texture, the color information of the waveform texture, the background color information of the texture image, and the position information of the waveform texture in the texture image. That is, the pixel shader adjusts the texture parameters in the texture image through the preset straight line texture function.

[0046] In addition, the above-mentioned texture image is generated by a function in the disturbed texture space, and the texture image at least includes waveform lines (the initial shape is a straight line). Since the texture space has been disturbed, the texture generated in the texture space can present a dynamically changing waveform curve, that is, the texture image contains a dynamically changing waveform texture.

[0047] It should be noted that since the texture image is generated by a function in the pixel shader instead of pulling the existing texture, it can ensure the high precision of the texture image while avoiding the problems of increased package capacity and sampling load caused by high-precision maps.

[0048] Based on the scheme defined by the above steps S102 to S106, it can be known that in an embodiment of the present invention, a method of perturbing the texture image is adopted, and a noise result is obtained by sampling the noise texture image in a preset direction in the texture space. Then, the texture coordinates in the texture space are superimposed according to the noise result to obtain the perturbed texture space. Finally, a texture image is generated in the perturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust the texture parameters in the texture image, and the texture image at least includes a waveform texture that changes with time.

[0049] It is easy to notice that in the above process, any noise texture image can be sampled to obtain a noise result. Any noise texture map can generate a texture image without special processing, and no additional modification process is required, thereby improving the efficiency of texture image generation. In addition, in the present application, the texture space is firstly superimposed to generate a disturbed texture space, and then a texture image is generated in the disturbed texture space based on a preset straight line texture function. This process does not involve the processing of the texture image, which reduces the texture sampling process of the texture image in the prior art, reduces the rendering load of the texture image, and increases the total capacity of the game. In addition, the texture parameters in the texture image can be adjusted through the preset straight line texture function, so that the adjustment of the waveform texture in the texture image can be achieved without the need for a higher resolution texture image.

[0050] It can be seen that the solution provided in the present application achieves the purpose of generating texture images, thereby realizing the technical effect of improving the efficiency of texture image generation, and further solving the technical problem of low texture image generation efficiency in the prior art.

[0051] In an optional embodiment, after generating a texture image in the disturbed texture space based on a preset straight line texture function, the pixel shader further generates a waveform animation based on the texture image, wherein the waveform animation includes at least a waveform texture that changes with time.

[0052] It should be noted that in the present application, any noise texture image can be used to generate a texture image, and waveform animation can be easily produced without special processing or modification.

[0053] In an optional embodiment, before the pixel shader performs superposition processing on the texture coordinates in the texture space according to the noise result, it is necessary to sample the noise texture image in a preset direction in the texture space to obtain the noise result. Specifically, the pixel shader first samples the noise texture image in a first direction in the texture space based on the sampling density to obtain a first sampling result, and then samples the first sampling result in a second direction in the texture space to obtain the noise result, wherein the first direction is different from the second direction. The sampling density at least includes a first value in the first direction, and the first value is less than a preset value.

[0054] It should be noted that, since the preset direction includes at least a first direction and a second direction, and the first direction and the second direction are different directions, the pixel shader may perform sampling in the first direction and in the second direction, respectively. Optionally, the pixel shader first performs sampling in the first direction, and then performs sampling in the second direction. For example, the pixel shader first samples the noise texture image in the vertical direction, and then samples the noise texture image in the horizontal direction.

[0055] In addition, it should be noted that in order to make the change of the waveform texture in the texture image in the direction perpendicular to the line as small as possible, and the disturbance in the direction parallel to the waveform texture should be small (for example, the disturbance is 0), the longitudinal sampling density (that is, the first value) needs to be reduced to an extremely low level, close to or even equal to 0. For example, the first value is adjusted to a value less than the preset value to ensure that the waveform disturbance intensity visually changes only in the horizontal direction. At the same time, when the texture space is superimposed, only the disturbance component in the longitudinal direction is taken to ensure that the texture space is not disturbed in the horizontal direction and the texture lines are not blurred.

[0056] Moreover, when the texture space is superimposed, only a disturbance component in a single direction is used to disturb the texture space, thereby avoiding the problem of texture blurring caused by disturbing the texture space in multiple directions.

[0057] In an optional embodiment, in the process of sampling the noise texture image in the first direction in the texture space based on the sampling density to obtain the first sampling result, the pixel shader first obtains the first coordinate of each pixel of the noise texture image in the texture space in the first direction and the second coordinate in the second direction, and then calculates the product of the first coordinate and the first value to obtain the third coordinate, and calculates the product of the second coordinate and the second value to obtain the fourth coordinate, and calculates the product of the preset time parameter and the moving speed to obtain the product result, and finally, according to the third coordinate and the fourth coordinate and the product result, obtains the first sampling result. Wherein, the sampling density also includes the second value in the second direction, and the moving speed represents the speed of the moving noise texture image;

[0058] Optionally, when the noise texture image is sampled in the default way, the corresponding sampling code is as follows:

[0059] float2 newNoiseUV=UV+time*speed;

[0060] fixed4 noiseColor=tex2D(noiseTexture,newNoiseUV);

[0061] It should be noted that the above code can realize the translation of the sampling process of the noise texture image, wherein newNoiseUV represents the coordinate information of the noise obtained after sampling, UV represents the coordinate information corresponding to each pixel in the original texture space, time represents the current sampling time (that is, the above-mentioned preset time parameter), speed is represented as a two-dimensional vector (that is, the above-mentioned moving speed), which represents the translation speed of the sampling; noiseColor represents the color information of the noise, noiseTexture represents the noise texture image; tex2D() function represents the sampling function.

[0062] In this embodiment, the pixel shader implements sampling of the noise texture image by multiplying the sampling ordinate (i.e., the first coordinate in the first direction) by a numerical value with a very small absolute value. That is, in this application, the noise texture image is sampled by the following function:

[0063] float2 newNoiseUV=UV*float2(1,x)+time*speed;

[0064] fixed4 noiseColor=tex2D(noiseTexture,newNoiseUV);

[0065] In the above code, UV represents the coordinate value composed of the first coordinate and the second coordinate, for example, (a, b), where a represents the second value and b represents the first value; x represents the first value and 1 represents the second value, that is, a is multiplied by 1 to obtain the third coordinate, and b is multiplied by x to obtain the fourth coordinate. The third coordinate and the fourth coordinate constitute the above-mentioned sampling coordinate newNoiseUV.

[0066] Further, after sampling the noise texture image in a first direction in the texture space based on the sampling density, the pixel shader samples the first sampling result in a second direction in the texture space to obtain a noise result. Specifically, the pixel shader first obtains coordinate information corresponding to the first sampling result, and maps the coordinate information to a preset coordinate range to obtain target noise information, and then obtains noise component information of the target noise information in the second direction to obtain a noise result.

[0067] Optionally, the pixel shader performs horizontal zeroing of the noise information, which can be achieved by the following code:

[0068] float2 noise=(noiseColor.xy–float2(0.5))*2;

[0069] float2 noiseNew=noise*float2(0,1);

[0070] In the above code, noiseColor.xy represents the coordinate information corresponding to the noise information, wherein the value range corresponding to noiseColor.xy is 0 to 1. Through the above first code, the coordinate information corresponding to the noise information can be mapped from the range of 0 to 1 to the range of -1 to 1 (that is, the preset coordinate range), so that the coordinate information corresponding to the noise information has the difference between positive and negative values, that is, the lateral disturbance can be divided into left and right directions, and the longitudinal disturbance can be divided into up and down directions. After that, the two mapped values ​​can be used to form a two-dimensional vector to obtain the target noise information noise, which is superimposed as disturbance information in the subsequent process.

[0071] In addition, in this embodiment, the pixel shader obtains the noise component information of the target noise information in the lateral direction (i.e., the second direction) by multiplying the target noise information by a numerical value that adjusts its size as a whole (i.e., the above-mentioned float2(0,1)), so as to facilitate the adjustment of the noise disturbance intensity.

[0072] Furthermore, after obtaining the noise result, the pixel shader performs superposition processing on the texture coordinates in the texture space according to the noise result to obtain the disturbed texture space. Optionally, the pixel shader performs superposition processing on the coordinates of each pixel point in the texture space according to the noise component information to obtain the disturbed texture space, which can be achieved by the following code:

[0073] float2 newUV=UV+noiseNew.

[0074] It should be noted that after generating the disturbed texture space, the pixel shader uses a function to generate a straight line texture in the disturbed texture space to obtain the target texture image. Since the texture space has been disturbed, the straight line texture in the texture space finally presents a natural and dynamically changing waveform curve.

[0075] Specifically, the pixel shader first determines the width value information of the waveform texture in the texture image and / or the position information of the waveform texture in the texture image and / or the background color information of the texture image and / or the color information of the waveform texture, and then generates a texture image in the disturbed texture space according to the width value information of the waveform texture in the texture image and / or the position information of the waveform texture in the texture image and / or the background color information of the texture image and / or the color information of the waveform texture, wherein the preset straight line texture function includes one or more of the following information: width value information, position information, background color information and color information.

[0076] It should be noted that the above-mentioned information on the width value of the waveform texture, the position information of the waveform texture in the texture image, the background color information of the texture image, and the color information of the waveform texture can be open to the user, so that the user can adjust the above information to obtain waveform lines of various thicknesses, colors, and blurriness at different heights of the model piece. Among them, when the noise intensity in the noise texture image is 0, the noise information in the noise texture image will not disturb the texture space. At this time, the texture in the texture image generated in the texture space is a straight line texture. For example, Figure 2 In the texture image shown, the white lines represent the waveform texture in the texture image. When the noise intensity in the noise texture image is greater than 0, the waveform texture will be distorted and jittered with the noise, thereby obtaining a dynamic waveform texture, such as Figure 3 Texture image of the wavy texture shown.

[0077] In an optional embodiment, in the process of adjusting the color information of the waveform texture and the background color information of the texture image, the pixel shader first obtains the first width value and the second width value of the waveform texture, and calculates the difference between the first width value and the second width value to obtain the first difference, then calculates the distance between the position of the waveform texture in the texture image and the position of each pixel in the waveform texture, and obtains the second difference based on the distance and the first width value, obtains the first ratio based on the first difference and the second difference, and finally adjusts the color information of the waveform texture and the background color information of the texture image based on the first ratio. Wherein, the width value information of the waveform texture includes at least the first width value and the second width value, the waveform texture includes a display part and a transition part, the transition part represents the part where the waveform texture transitions to the background color of the texture image, the first width value represents the difference between the width of the display part and the width of the transition part, and the second width value represents the width of the display part.

[0078] Optionally, a texture image with a background color of color01 and a line color of the waveform texture of color02 can be obtained through color = lerp(color01, color02, lineMask). For example, if color01 = (1, 0, 0, 1) (pure red) and color02 = (0, 0, 1, 1) (pure blue), a red waveform texture with a pure blue background can be obtained. If a transparent background is required, color01 can be adjusted to be transparent, that is, the alpha component of color01 = 0.

[0079] It should be noted that the distance between the position of the above waveform texture in the texture image and the position of each pixel in the waveform texture can be calculated by the following formula:

[0080] distance = |newUV.y - linePosition|

[0081] Where distance represents the above distance, newUV.y represents the longitudinal position coordinate of each pixel in the waveform texture, and linePosition represents the longitudinal position of the waveform texture in the texture image, usually represented by the longitudinal position of the center position of the waveform texture in the texture image. For example, in the Figure 4 texture image shown, linePosition is the longitudinal position of the center position of the waveform texture in the texture image.

[0082] lineMask = 1 - saturate((distance - A) / (B - A)), where B > A.

[0083] In the above formula, lineMask represents the line mask of the waveform texture, A represents half of the width of the part with the most solid color of the waveform texture, that is, A = (the first width value - the second width value) / 2; B represents half of the width when the waveform texture transitions to the same color as the background color (i.e., the widest part of the line edge), that is, B = the first width value / 2.

[0084] Optionally, a lineMask value is generated for each pixel on the virtual model, and according to the above formula:

[0085] When distance = A, LineMask = 1 - saturate((A - A) / (B - A)) = 1 - 0 = 1;

[0086] When distance = B, LineMask = 1 - saturate((B - A) / (B - A)) = 1 - 1 = 0.

[0087] It can be seen that 0 < lineMask < 1. Then:

[0088] When distance ≥ B, lineMask = 0; when distance ≤ A, lineMask = 1;

[0089] When B>distance>A, lineMask is a linear transition from 0 to 1.

[0090] Through the above process, lineMask can change with the change from linePosition to distance, where the closer the distance, the closer the value is to or equal to 1, and the farther the distance, the closer the value is to or equal to 0, thus forming the information required to generate the waveform texture, and then linear mapping is performed on the waveform texture:

[0091] color=lerp(color01,color02,lineMask).

[0092] This will create a texture image with the base color being color01 and the line color of the waveform texture being color02.

[0093] In an optional embodiment, the pixel shader can also adjust the blur level of the waveform texture. Specifically, the pixel shader first obtains the first width value and the second width value of the waveform texture, obtains a first difference value based on the first width value and the second width value, and then adjusts the blur level of the waveform texture based on the first difference value. Figure 5 In the example, when the A and B values ​​are close, the line edges of the waveform texture are sharper. At this time, lineMask quickly transitions from 1 to 0 in a very narrow area; when the A and B values ​​differ greatly, the line edges of the waveform texture are fuzzy.

[0094] In an optional embodiment, the pixel shader can also adjust the width of the texture waveform. Specifically, the pixel shader obtains the first width value and the second width value of the waveform texture, and adjusts the width of the waveform texture according to the first width value and / or the second width value. Figure 6 In the figure, when both A and B are small, the lines of the texture waveform are thinner; when both A and B are large, the lines of the texture waveform are thicker.

[0095] From the above content, it can be seen that the present application uses any noise map to quickly create a dynamic waveform effect without the need for additional modification, and can also adjust the sharpness of the waveform texture, which is flexible and controllable with high precision. In addition, the solution provided by the present application can also reduce the process of sampling texture lines, reduce the rendering load, reduce the production of texture lines and its increase in the total capacity of the game.

[0096] According to an embodiment of the present invention, there is also provided an embodiment of a device for generating a texture image, wherein: Figure 7is a schematic diagram of a device for generating a texture image according to an embodiment of the present invention, such as Figure 7 As shown, the device includes: a sampling module 701, a processing module 703 and a generating module 705.

[0097] Among them, the sampling module 701 is used to sample the noise texture image in a preset direction in the texture space to obtain a noise result; the processing module 703 is used to overlay the texture coordinates in the texture space according to the noise result to obtain the disturbed texture space; the generation module 705 is used to generate a texture image in the disturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust the texture parameters in the texture image, and the texture image at least includes a waveform texture that changes with time.

[0098] It should be noted that the above-mentioned sampling module 701, processing module 703 and generation module 705 correspond to steps S102 to S106 in the above-mentioned embodiment. The examples and application scenarios implemented by the three modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment.

[0099] Optionally, the texture image generating device further includes: a first generating module, which is used to generate a waveform animation based on the texture image after generating the texture image in the disturbed texture space based on a preset straight line texture function, wherein the waveform animation at least includes a waveform texture that changes with time.

[0100] Optionally, the sampling module includes: a first sampling module and a second sampling module. The first sampling module is used to sample the noise texture image in a first direction in the texture space based on the sampling density to obtain a first sampling result, wherein the sampling density at least includes a first value in the first direction, and the first value is less than a preset value; the second sampling module is used to sample the first sampling result in a second direction in the texture space to obtain a noise result, wherein the first direction is different from the second direction.

[0101] Optionally, the first sampling module includes: a first acquisition module, a first calculation module, a second calculation module, a third calculation module and a fourth calculation module. The first acquisition module is used to obtain the first coordinates of each pixel of the noise texture image in the texture space in the first direction and the second coordinates in the second direction, wherein the sampling density also includes the second value in the second direction; the first calculation module is used to calculate the product of the first coordinate and the first value to obtain the third coordinate; the second calculation module is used to calculate the product of the second coordinate and the second value to obtain the fourth coordinate; the third calculation module is used to calculate the product of the preset time parameter and the moving speed to obtain the product result, wherein the moving speed represents the speed of the moving noise texture image; the fourth calculation module is used to obtain the first sampling result according to the third coordinate and the fourth coordinate and the product result.

[0102] Optionally, the second sampling module includes: a second acquisition module, a mapping module and a third acquisition module. The second acquisition module is used to acquire the coordinate information corresponding to the first sampling result; the mapping module is used to map the coordinate information to a preset coordinate range to obtain noise information; and the third acquisition module is used to acquire the noise component information of the noise information in the second direction to obtain the noise result.

[0103] Optionally, the processing module includes: a first processing module, used to perform superposition processing on the coordinates of each pixel point in the texture space according to the noise component information to obtain a disturbed texture space.

[0104] Optionally, the generation module includes: a second generation module, used to generate a texture image in the disturbed texture space based on width value information of the waveform texture in the texture image and / or position information of the waveform texture in the texture image and / or background color information of the texture image and / or color information of the waveform texture, wherein the preset straight line texture function includes one or more of the following information: width value information, position information, background color information and color information.

[0105] Optionally, the texture image generation device further includes: a fourth acquisition module, a fifth calculation module, a sixth calculation module, a seventh calculation module, an eighth calculation module and a first adjustment module. The fourth acquisition module is used to acquire the first width value and the second width value of the waveform texture, wherein the width value information of the waveform texture includes at least the first width value and the second width value, the waveform texture includes a display part and a transition part, the transition part represents the part where the waveform texture transitions to the background color of the texture image, the first width value represents the difference between the width of the display part and the width of the transition part, and the second width value represents the width of the display part; the fifth calculation module is used to calculate the difference between the first width value and the second width value to obtain the first difference; the sixth calculation module is used to calculate the distance between the position of the waveform texture in the texture image and the position of each pixel point in the waveform texture; the seventh calculation module is used to obtain the second difference according to the distance and the first width value; the eighth calculation module is used to obtain the first ratio according to the first difference and the second difference; the first adjustment module is used to adjust the color information of the waveform texture and the background color information of the texture image according to the first ratio.

[0106] Optionally, the texture image generation device further includes: a fifth acquisition module, a ninth calculation module, and a second adjustment module. The fifth acquisition module is used to acquire a first width value and a second width value of the waveform texture, wherein the width value information of the waveform texture includes at least the first width value and the second width value, the waveform texture includes a display portion and a transition portion, the transition portion represents the portion where the waveform texture transitions to the background color of the texture image, the first width value represents the difference between the width of the display portion and the width of the transition portion, and the second width value represents the width of the display portion; the ninth calculation module is used to obtain a first difference value based on the first width value and the second width value; the second adjustment module is used to adjust the blurring degree of the waveform texture based on the first difference value.

[0107] Optionally, the texture image generation device further includes: a sixth acquisition module and a third adjustment module. The sixth acquisition module is used to acquire a first width value and a second width value of the waveform texture, wherein the width value information of the waveform texture includes at least the first width value and the second width value, the waveform texture includes a display portion and a transition portion, the transition portion represents the portion where the waveform texture transitions to the background color of the texture image, the first width value represents the difference between the width of the display portion and the width of the transition portion, and the second width value represents the width of the display portion; the third adjustment module is used to adjust the width of the waveform texture according to the size of the first width value and / or the second width value.

[0108] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the method for generating a texture image in the above embodiment when running.

[0109] According to another aspect of an embodiment of the present invention, an electronic device is also provided, which includes one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors are implemented to run the programs, wherein the program is configured to execute the method for generating a texture image in the above-mentioned embodiment when running.

[0110] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0111] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0112] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0113] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0114] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0115] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions 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 method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0116] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for generating a texture image, It is characterized in that include: Sampling the noise texture image in a preset direction in the texture space to obtain a noise result; Performing a superposition process on the texture coordinates in the texture space according to the noise result to obtain a disturbed texture space; Generating a texture image in the disturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust texture parameters in the texture image, and the texture image at least includes a waveform texture that changes with time; The generating of the texture image in the disturbed texture space based on the preset straight line texture function includes: generating the texture image in the disturbed texture space according to the width value information of the waveform texture in the texture image and / or the position information of the waveform texture in the texture image and / or the background color information of the texture image and / or the color information of the waveform texture, wherein the preset straight line texture function includes one or more of the following information: the width value information, the position information, the background color information and the color information.

2. The method according to claim 1, It is characterized in that After generating a texture image in the disturbed texture space based on a preset straight line texture function, the method further includes: A waveform animation is generated based on the texture image, wherein the waveform animation at least includes the waveform texture that changes with time.

3. The method according to claim 1, It is characterized in that The noise texture image is sampled in a preset direction in the texture space to obtain the noise result, including: Sampling the noise texture image in a first direction in the texture space based on a sampling density to obtain a first sampling result, wherein the sampling density at least includes a first value in the first direction, and the first value is less than a preset value; The first sampling result is sampled in a second direction in the texture space to obtain the noise result, wherein the first direction is different from the second direction.

4. The method according to claim 3, It is characterized in that Sampling the noise texture image in a first direction in the texture space based on the sampling density to obtain a first sampling result includes: Obtaining a first coordinate in the first direction and a second coordinate in the second direction of each pixel of the noise texture image in the texture space, wherein the sampling density also includes a second value in the second direction; Calculate the product of the first coordinate and the first value to obtain a third coordinate; Calculate the product of the second coordinate and the second value to obtain a fourth coordinate; Calculating the product of a preset time parameter and a moving speed to obtain a product result, wherein the moving speed represents a speed of moving the noise texture image; The first sampling result is obtained according to the third coordinate, the fourth coordinate and the product result.

5. The method according to claim 3, It is characterized in that Sampling the first sampling result in a second direction in the texture space to obtain the noise result includes: Obtaining coordinate information corresponding to the first sampling result; Mapping the coordinate information to a preset coordinate range to obtain target noise information; Noise component information of the target noise information in the second direction is acquired to obtain the noise result.

6. The method according to claim 5, It is characterized in that The texture coordinates in the texture space are superimposed according to the noise result to obtain a disturbed texture space, including: According to the noise component information, the coordinates of each pixel point in the texture space are superimposed to obtain the disturbed texture space.

7. The method according to claim 1, It is characterized in that The method further comprises: Acquire a first width value and a second width value of the waveform texture, wherein the width value information of the waveform texture at least includes the first width value and the second width value, the waveform texture includes a display portion and a transition portion, the transition portion represents a portion where the waveform texture transitions to a background color of the texture image, the first width value represents a difference between a width of the display portion and a width of the transition portion, and the second width value represents a width of the display portion; Calculating a difference between the first width value and the second width value to obtain a first difference; Calculating the distance between the position of the waveform texture in the texture image and the position of each pixel point in the waveform texture; Obtaining a second difference value according to the distance and the first width value; Obtaining a first ratio according to the first difference and the second difference; The color information of the waveform texture and the background color information of the texture image are adjusted according to the first ratio.

8. The method according to claim 1, It is characterized in that The method further comprises: Acquire a first width value and a second width value of the waveform texture, wherein the width value information of the waveform texture at least includes the first width value and the second width value, the waveform texture includes a display portion and a transition portion, the transition portion represents a portion where the waveform texture transitions to a background color of the texture image, the first width value represents a difference between a width of the display portion and a width of the transition portion, and the second width value represents a width of the display portion; Obtaining a first difference value according to the first width value and the second width value; The blur degree of the waveform texture is adjusted according to the first difference.

9. The method according to claim 1, It is characterized in that The method further comprises: Acquire a first width value and a second width value of the waveform texture, wherein the width value information of the waveform texture at least includes the first width value and the second width value, the waveform texture includes a display portion and a transition portion, the transition portion represents a portion where the waveform texture transitions to a background color of the texture image, the first width value represents a difference between a width of the display portion and a width of the transition portion, and the second width value represents a width of the display portion; The width of the waveform texture is adjusted according to the first width value and / or the second width value.

10. A texture image generating device, It is characterized in that include: A sampling module is used to sample the noise texture image in a preset direction in the texture space to obtain a noise result; A processing module, used for performing superposition processing on the texture coordinates in the texture space according to the noise result to obtain a disturbed texture space; A generating module, configured to generate a texture image in the disturbed texture space based on a preset straight line texture function, wherein the straight line texture function is used to adjust texture parameters in the texture image, and the texture image at least includes a waveform texture that changes with time; The generation module is also used to generate the texture image in the disturbed texture space according to the width value information of the waveform texture in the texture image and / or the position information of the waveform texture in the texture image and / or the background color information of the texture image and / or the color information of the waveform texture, wherein the preset straight line texture function includes one or more of the following information: the width value information, the position information, the background color information and the color information.

11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the method for generating a texture image as claimed in any one of claims 1 to 9 when executed.

12. An electronic device, It is characterized in that The electronic device includes one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors are enabled to run the programs, wherein the program is configured to execute the method for generating a texture image described in any one of claims 1 to 9 when running.