Methods, apparatus, storage media and electronic devices for generating water flow animation

By obtaining the base color of the water flow map and using time parameters to determine the periodic offset value for color mixing, the problem of low efficiency in water flow animation generation is solved, achieving efficient, smooth water flow animation generation and realistic effects.

CN116468823BActive Publication Date: 2026-05-26NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NETEASE (HANGZHOU) NETWORK CO LTD
Filing Date
2023-03-06
Publication Date
2026-05-26

Smart Images

  • Figure CN116468823B_ABST
    Figure CN116468823B_ABST
Patent Text Reader

Abstract

This disclosure provides a method, apparatus, storage medium, and electronic device for generating water flow animation, relating to the field of computer technology. The water flow animation generation method includes: obtaining a basic water flow color for pixels based on a water flow map; determining a first offset value and a second offset value for the target frame based on time parameters of the target frame; obtaining water flow parameters based on the basic water flow color, and obtaining a first water flow color based on the water flow parameters and the first offset value, and obtaining a second water flow color based on the water flow parameters and the second offset value; mixing the first and second water flow colors using color mixing parameters to obtain a target water flow color for pixels in each frame; and generating the water flow animation based on the target water flow color of the pixels in each frame. This disclosure improves upon the problem of low efficiency in water flow animation generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method for generating water flow animation, a device for generating water flow animation, a computer-readable storage medium, and an electronic device. Background Technology

[0002] Water flow animation is often used in film, games, animation and other fields. By adding water flow animation to virtual scenes, a realistic virtual scene can be presented, and the atmosphere and vividness of the virtual scene can be enhanced.

[0003] In related technologies, water flow animations are typically created manually by staff based on their experience. Clearly, this method is labor-intensive, time-consuming, and inefficient. Summary of the Invention

[0004] This disclosure provides a method for generating water flow animation, a device for generating water flow animation, a computer-readable storage medium, and an electronic device, thereby improving the problem of low efficiency in generating water flow animation at least to some extent.

[0005] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.

[0006] According to a first aspect of this disclosure, a method for generating a water flow animation is provided, comprising: obtaining a basic water flow color of a pixel based on a water flow map; determining a first offset value and a second offset value of a target frame based on a time parameter of a target frame, wherein the target frame is one or more frames in the water flow animation to be generated, the time parameter increasing sequentially with frame order within a water flow cycle, the first offset value and the second offset value differing by a sampling interval value and exhibiting periodic changes with the time parameter; obtaining water flow parameters based on the basic water flow color, and obtaining a first water flow color based on the water flow parameters and the first offset value, and obtaining a second water flow color based on the water flow parameters and the second offset value; performing color mixing on the first water flow color and the second water flow color using a color mixing parameter to obtain a target water flow color of a pixel in each frame; and generating the water flow animation based on the target water flow color of the pixel in each frame.

[0007] According to a second aspect of this disclosure, a water flow animation generation apparatus is provided, comprising: a basic water flow color acquisition module configured to acquire a basic water flow color of a pixel based on a water flow map; an offset value determination module configured to determine a first offset value and a second offset value of a target frame based on a time parameter of the target frame, wherein the target frame is one or more frames in the water flow animation to be generated, the time parameter increasing sequentially with the frame order within a water flow cycle, the first offset value and the second offset value differing by a sampling interval value and exhibiting periodic changes with the time parameter; a first water flow color and a second water flow color acquisition module configured to acquire water flow parameters based on the basic water flow color, and to obtain a first water flow color based on the water flow parameters and the first offset value, and to obtain a second water flow color based on the water flow parameters and the second offset value; a color mixing module configured to perform color mixing on the first water flow color and the second water flow color using a color mixing parameter to obtain a target water flow color of a pixel in each frame; and a water flow animation acquisition module configured to generate the water flow animation based on the target water flow color of the pixel in each frame.

[0008] According to a third aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the water flow animation generation method of the first aspect described above and its possible implementations.

[0009] According to a fourth aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor. The processor is configured to execute the water flow animation generation method of the first aspect and its possible implementations thereof by executing the executable instructions.

[0010] The technical solution disclosed herein has the following beneficial effects:

[0011] On the one hand, this method automates the generation of water flow animations, improving efficiency and reducing labor and time costs compared to manual methods. On the other hand, it obtains the first and second water flow colors based on water flow parameters and first and second offset values, respectively. These colors are then mixed using color mixing parameters to obtain the target water flow color. The animation is then generated based on the target water flow color of each frame's pixels, reducing method complexity and performance overhead, improving playback smoothness, and enhancing user experience. Furthermore, it generates periodically changing first and second offset values ​​based on the target frame's time parameters. The first and second water flow colors are then obtained from these values, and mixed to obtain the target water flow color for each pixel. This achieves a looping water flow effect, enhancing the realism and vividness of the animation.

[0012] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0014] Figure 1 This illustrates the system operating architecture of this exemplary embodiment;

[0015] Figure 2 This diagram illustrates a flowchart of generating a water flow animation in this exemplary embodiment;

[0016] Figure 3A This diagram illustrates a water flow scene texture in this exemplary embodiment.

[0017] Figure 3B A schematic diagram of a water flow noise map is shown in this exemplary embodiment;

[0018] Figure 4 This exemplary embodiment illustrates a flowchart for obtaining the basic water flow color;

[0019] Figure 5 This exemplary embodiment shows a flowchart of obtaining the first water flow color and the second water flow color;

[0020] Figure 6 This exemplary embodiment shows a flowchart of obtaining the first color sampling coordinates and the second color sampling coordinates;

[0021] Figure 7 This exemplary embodiment illustrates a flowchart for obtaining the color of a target water flow.

[0022] Figure 8 This illustrates another flowchart for obtaining the target water flow color in this exemplary embodiment;

[0023] Figure 9 This diagram illustrates the structure of a water flow animation generation device according to this exemplary embodiment.

[0024] Figure 10 A schematic diagram of the structure of an electronic device in this exemplary embodiment is shown. Detailed Implementation

[0025] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.

[0026] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0027] In related technologies, workers typically create water flow effects as skeletal animation or frame-by-frame animation. However, due to the complexity of the animation production process and the significant time and manpower required, the process of generating water flow animations is inefficient. Furthermore, the resulting water flow animations incur substantial performance overhead during loading and playback, easily leading to stuttering and a poor viewing experience for users.

[0028] In view of one or more of the above-mentioned problems, this disclosure first provides a method for generating water flow animation through exemplary embodiments. The following is in conjunction with... Figure 1 The system architecture of the operating environment for this exemplary embodiment will be described.

[0029] refer to Figure 1 As shown, the system architecture 100 may include a terminal device 110. The terminal device 110 may be an electronic device such as a laptop, desktop computer, or tablet computer, and the terminal device 110 may be used to obtain the basic water flow color of the pixels from the water flow map.

[0030] The water flow animation generation method in this exemplary embodiment can be executed by the terminal device 110. For example, in a game scene, the terminal device 110 can be a computer running the game, and the water flow texture can be a game scene image including water flow or a water flow noise image with only water flow. The terminal device 110 generates water flow animation in the game scene based on the water flow texture by executing the lightning animation generation method, making the game scene more atmospheric and vivid, thereby enhancing the player's immersion.

[0031] As can be seen from the above, the water flow animation generation method in this exemplary embodiment can be executed by the aforementioned terminal device 110.

[0032] The following is combined Figure 2 The method for generating water flow animation is explained. Figure 2 An exemplary flow diagram of a water flow animation generation method is shown, including the following steps S210 to S250:

[0033] Step S210: Obtain the basic water flow color of the pixel based on the water flow map;

[0034] Step S220: Determine the first offset value and the second offset value of the target frame according to the time parameter of the target frame. The target frame is one or more frames in the water flow animation to be generated. The time parameter increases with the frame order within a water flow cycle. The first offset value and the second offset value differ by a sampling interval value and change periodically with the time parameter.

[0035] Step S230: Obtain water flow parameters based on the basic water flow color, obtain the first water flow color based on the water flow parameters and the first offset value, and obtain the second water flow color based on the water flow parameters and the second offset value;

[0036] Step S240: Use color mixing parameters to mix the first water flow color and the second water flow color to obtain the target water flow color of each pixel in each frame.

[0037] Step S250: Generate a water flow animation based on the target water flow color of the pixels in each frame.

[0038] Based on the above method, on the one hand, automated generation of water flow animation is achieved, which improves efficiency and reduces the labor and time costs compared to manual water flow animation production. On the other hand, this solution can obtain the first and second water flow colors based on water flow parameters and first and second offset values, respectively, and then mix the first and second water flow colors using color mixing parameters to obtain the target water flow color. The water flow animation is then generated based on the target water flow color of each frame's pixels, reducing the complexity of the method and the performance consumption of the water flow animation generation process, improving the smoothness of the water flow animation playback, and effectively enhancing the user experience. Furthermore, periodically changing first and second offset values ​​are generated based on the time parameters of the target frame, and the first and second water flow colors are obtained based on these values. The first and second water flow colors are then mixed to obtain the target water flow color of each pixel, achieving a looping playback effect of the water flow effect and enhancing the realism and vividness of the water flow animation.

[0039] The following is about Figure 2 Each step in the process will be explained in detail.

[0040] refer to Figure 2 In step S210, the basic water flow color of the pixel is obtained based on the water flow map.

[0041] Among them, water flow texture is a texture that includes water flow images, such as Figure 3A and Figure 3B As shown; the base water flow color can represent the color of the water flow in the water flow map; the pixel can be the pixel in the water flow area of ​​the water flow map.

[0042] In one embodiment, the water flow texture may include a water flow scene texture and a water flow noise texture; the basic water flow color of the pixel is obtained based on the water flow texture, such as... Figure 4 As shown, steps S410 to S420 may be included:

[0043] Step S410: Obtain water flow noise texture based on water flow scene texture;

[0044] Step S420: Use the texture coordinates of the pixels to perform color sampling on the water flow noise map to obtain the basic water flow color of the pixels.

[0045] The water flow scene texture can be an image that includes water flow and other virtual elements, such as... Figure 3A As shown, a water flow noise map can be a map that only includes water flow elements, such as... Figure 3B As shown.

[0046] For example, the OpenGL color sampling function texture2D can be used to sample the water flow noise map uSamplerNoise based on the texture coordinates vTextureCoord of the pixels in the water flow area of ​​the water flow scene texture, so as to obtain the basic water flow color flowColor.

[0047] based on Figure 4 The proposed method obtains a water flow noise map based on a water flow scene map and performs color sampling on the water flow noise map to obtain the basic water flow color of the pixels. This reduces the complexity of obtaining the basic water flow color and reduces the interference of other virtual elements on the basic water flow color, effectively improving the accuracy of obtaining the basic water flow color.

[0048] In one embodiment, the above-mentioned method of obtaining a water flow noise map based on a water flow scene map may include: making the area outside the water flow in the water flow scene map transparent to obtain the water flow noise map.

[0049] For example, staff can create a water flow scene texture, and then set the pixels in the water flow scene texture other than the water flow area to transparent to obtain a water flow noise texture. In the water flow noise texture, the texture coordinates of the pixels in the area outside the water flow area are 0.

[0050] As can be seen, the method of obtaining water flow noise map based on water flow scene map can keep the water flow position and size consistent with the water flow noise map and water flow scene map, thereby accurately obtaining the water flow position in water flow scene map based on water flow noise map, so as to improve the accuracy of obtaining basic water flow color.

[0051] Continue to refer to Figure 2 In step S220, the first offset value and the second offset value of the target frame can be determined according to the time parameter of the target frame. The target frame is one or more frames in the water flow animation to be generated. The time parameter increases with the frame order within a water flow cycle. The first offset value and the second offset value differ by a sampling interval value and change periodically with the time parameter.

[0052] The time parameter can be a variable that increases with frame sequence within a water flow cycle. For example, the time parameter can increase between 0 and 1. When the time parameter is 0, it can indicate the start of a water flow cycle; when the time parameter is 1, it can indicate the end of a water flow cycle. That is, the process of the time parameter increasing from 0 to 1 is the entire process of a single water flow effect. The water flow cycle can characterize the entire process of a single water flow effect. For example, in a single water flow cycle, the texture information of the leftmost water flow pixel can be linearly shifted to the rightmost water flow pixel. The first offset value and the second offset value are two offset values ​​used to determine the sampling position when sampling the water flow color. The difference between the two is a sampling interval value, so that sampling can be performed at different sampling positions when acquiring the water flow color, thereby obtaining a double-sampled water flow color effect. For example, the first offset value can be determined according to the time parameter value, and the second offset value can be determined according to the sum of value and the sampling interval value. The sampling interval value is a constant related to the generation of the second offset value based on the time parameter. This disclosure does not make any special limitation on the specific value of the sampling interval value. For example, the sampling interval value can be 0.5.

[0053] In one embodiment, determining the first offset value and the second offset value of the target frame based on the time parameter of the target frame may include the following steps:

[0054] The first offset value is determined based on the time parameter;

[0055] The second offset value is determined based on the sum of the time parameter and the sampling interval value.

[0056] For example, the time parameter `value` can range from [0,1], meaning each target frame corresponds to a `value`. Within a water flow cycle, `value` can increment within the range [0,1]. If the current water flow cycle ends, the value of `value` is 1, and the value is set to 0 to start the next water flow cycle. `value` cycles through consecutive water flow cycles in a sequence of 0->1->0->1... If `value` = 0 and the sampling interval is 0.5, the first offset value `fract(value) = frac(0) = 0` and the second offset value `fract(value + 0.5) = fract(0.5) = 0.5` can be obtained using the `fract()` function in OpenGL and the time parameter. The `fract()` function is frequently used for decimal calculations; `fract(x)` is equivalent to `x - floor(x)`, and `floor(x)` can be used to round down x. If value = 0.5, then the first offset value fract(value) = frac(0.5) = 0.5, and the second offset value fract(value + 0.5) = fract(1) = 1. If value = 1, then the first offset value fract(value) = frac(1) = 1, and the second offset value fract(value + 0.5) = fract(1.5) = 0.5. That is to say, in a single water flow cycle, if the time parameter value increases from 0 to 1, the first offset value increases from 0 to 0.5 to 1, and the second offset value changes from 0.5 to 1 to 0.5. When a single water flow cycle ends, value is reset to 0. Therefore, in multiple water flow cycles, both the first and second offset values ​​show periodic changes, and the difference between the first and second offset values ​​is always a sampling interval of 0.5.

[0057] The method described above for obtaining the first offset value and the second offset value based on the time parameter ensures the periodic change of the first offset value and the second offset value, thereby realizing the periodic change of the first water flow color and the second water flow color, and achieving the effect of looping water flow animation.

[0058] After obtaining the basic water flow color, the first offset value, and the second offset value, continue to refer to... Figure 2 In step S230, water flow parameters can be obtained based on the basic water flow color, and the first water flow color can be obtained based on the water flow parameters and the first offset value, and the second water flow color can be obtained based on the water flow parameters and the second offset value.

[0059] The first water flow color and the second water flow color can represent the water flow colors of different pixels in the water flow texture.

[0060] In one embodiment, obtaining water flow parameters based on the basic water flow color may include multiplying the texture coordinates of a pixel, a preset water flow intensity parameter, and a preset water flow direction parameter to obtain the water flow parameters.

[0061] The texture coordinates of a pixel can include the pixel's texture information. This disclosure does not impose any special limitations on the method of obtaining the pixel's texture coordinates. For example, the pixel's texture coordinates can be obtained from pixels in the water flow scene texture, or they can be obtained from the texture coordinates of the basic water flow color. If the basic water flow color can be represented by flowColor, then the pixel's texture coordinates flowCoord = vec2(flowColor.x, flowColor.y). The preset water flow intensity parameter can be a parameter characterizing the flow intensity of the water flow. This disclosure does not impose any special limitations on the specific value of the preset water flow intensity parameter. For example, the preset water flow intensity parameter can be a two-dimensional variable, such as the preset water flow intensity parameter flowStrength = vec2(strength, strength). The preset water flow direction parameter can be a parameter that characterizes the direction of water flow. For example, the direction of water flow can include up, down, left, and right. Then the preset water flow direction parameter flowDirection = vec(0.0, 1.0) can represent the direction of water flow as up, flowDirection = vec(0.0, -1.0) can represent the direction of water flow as down, flowDirection = vec(1.0, 0.0) can represent the direction of water flow as left, and flowDirection = vec(-1.0, 0.0) can represent the direction of water flow as right.

[0062] For example, multiplying the pixel's texture coordinates (flowCoord), the preset water flow intensity parameter (flowStrength), and the preset water flow direction parameter (flowDirection) yields the water flow parameter (flowFactor). This water flow parameter includes both water flow direction and intensity information, and has low computational complexity, thus improving the overall efficiency of the water flow animation.

[0063] In one implementation, the first water flow color is obtained based on the water flow parameters and a first offset value, and the second water flow color is obtained based on the water flow parameters and a second offset value, such as... Figure 5 As shown, steps S510 to S520 may be included:

[0064] In step S510, the first color sampling coordinates are obtained based on the water flow parameters and the first offset value, and the second color sampling coordinates are obtained based on the water flow parameters and the second offset value.

[0065] The color sampling coordinates are used as the basis for color sampling in the water flow noise map. In one embodiment, the first color sampling coordinates are obtained based on the water flow parameters and a first offset value, and the second color sampling coordinates are obtained based on the water flow parameters and a second offset value, as shown below. Figure 6 As shown, steps S610 to S620 may be included:

[0066] Step S610: Multiply the water flow parameters by the first offset value and the second offset value respectively to obtain the first offset coordinate and the second offset coordinate;

[0067] Step S620: Add the texture coordinates of the pixel to the first offset coordinates and the second offset coordinates respectively to obtain the first color sampling coordinates and the second color sampling coordinates.

[0068] For example, by calculating the offset value twice based on the time parameter value to obtain the first offset value fract(value) and the second offset value fract(value+0.5), the first offset coordinate and the second offset coordinate can be obtained according to the following formulas (1) and (2):

[0069] vec2 offset1=flowFactor* fract(value) (1)

[0070] vec2 offset2=flowFactor* fract(value+0.5) (2)

[0071] In this context, offset1 represents the first offset coordinate, offset2 represents the second offset coordinate, flowFactor represents the water flow parameter, and vec2 indicates that offset1 and offset2 are two-dimensional variables.

[0072] After obtaining the first offset coordinate and the second offset coordinate, the first color sampling coordinate and the second color sampling coordinate can be obtained according to the following formulas (3) and (4):

[0073] vec2 uv1=vTextureCoord.xy+offset1 (3)

[0074] vec2 uv2=vTextureCoord.xy+offset2 (4)

[0075] Here, uv1 can represent the first color sampling coordinate, uv2 can represent the second color sampling coordinate, vTextureCoord.xy can represent the texture coordinates of the pixel, offset1 represents the first offset coordinate, offset2 represents the second offset coordinate, and vec2 indicates that uv1 and uv2 are two-dimensional variables.

[0076] After obtaining the first color sampling coordinates and the second color sampling coordinates, in step S520, the first color sampling coordinates and the second color sampling coordinates are used to sample the water flow scene texture to obtain the first water flow color and the second water flow color.

[0077] For example, the first and second water flow colors can be obtained by using the texture2D() function and color sampling coordinates to perform color sampling on the water flow scene texture using the following formulas (5) and (6):

[0078] vec4 color1= texture2D(uSampler, uv1) (5)

[0079] vec4 color2= texture2D(uSampler, uv2) (6)

[0080] Where color1 and color2 represent the first and second water flow colors, respectively; uSampler can represent the water flow scene texture; uv1 and uv2 can represent the first and second color sampling coordinates, respectively; vec4 can represent the first and second water flow colors as vectors composed of four floating-point numbers.

[0081] based on Figure 5 This method can achieve the color value corresponding to the UV coordinates of the cyclic double sampling phase difference sampling interval value multiple, thereby realizing the loop playback of the water flow effect and further enhancing the realism of the water flow animation.

[0082] After obtaining the colors of the first and second water flows, continue to refer to... Figure 2 In step S240, color mixing parameters can be used to mix the first water flow color and the second water flow color to obtain the target water flow color of each pixel in each frame.

[0083] The target water flow color can be the color of a pixel in the target frame. In one embodiment, the first water flow color and the second water flow color are mixed using color mixing parameters to obtain the target water flow color of each pixel in each frame. Figure 7 As shown, steps S710 to S720 may be included:

[0084] Step S710: Calculate the color mixing parameters based on the time parameters;

[0085] Step S720: Linear interpolation is performed on the first water flow color and the second water flow color using color mixing parameters, and the target water flow color of each frame's pixel is obtained based on the linear interpolation result.

[0086] Interpolation involves finding patterns in a known data sequence (such as a series of discrete points) and then using these patterns to estimate the values ​​of points for which no data has yet been recorded. Linear interpolation, on the other hand, involves estimating the values ​​of the two nearest neighboring data points in a one-dimensional data sequence (the weight of the estimation is determined by the distance to these two points).

[0087] For example, the process of calculating the color mixing parameter based on the time parameter and the first color mixing reference value and the second color mixing reference value can be as shown in Formula 7 below. This disclosure does not impose any special limitation on the specific values ​​of the first color mixing reference value and the second color mixing reference value. For example, the first color reference value can be 2.0 and the second color reference value can be 1.0.

[0088] interpolation=abs(fract(value)*2.0-1.0) (7)

[0089] Here, interpolation can represent the color mixing parameter, value is the time parameter, fract(value) represents the first offset value obtained based on the time parameter, 2.0 can be the first color mixing reference value, 1.0 can be the second color mixing reference value, and the abs(x) function is used to take the absolute value of x.

[0090] After obtaining the color blending parameters, the first water flow color and the second water flow color can be linearly interpolated using the mix() function and the color blending parameters according to the following formula (8) to obtain the target water flow color of each pixel in each frame:

[0091] vec4 blendColor = mix(color1, color2, interpolation) (8)

[0092] =color1*(1-interpolation)+color2*interpolation

[0093] Here, blendColor can represent the target water flow color, color1 represents the first water flow color, color2 represents the second water flow color, interpolation can represent the color blending parameters, and vec4 can represent the color blending parameters. blendColor is a vector composed of four floating-point numbers.

[0094] based on Figure 7The method obtains the color mixing parameter through the time parameter value, and then uses the color mixing parameter to linearly interpolate the colors of the first and second water flows to obtain the target water flow color. The process has a small amount of computation and low complexity, which improves the computational efficiency of obtaining the target water flow color and helps to improve the overall efficiency of generating water flow animation.

[0095] After obtaining the target water flow color, continue to refer to... Figure 2 In step S250, a water flow animation can be generated based on the target water flow color of the pixels in each frame.

[0096] For example, in a game scene, multiple frames of water flow scene textures with determined target water flow colors can be combined to obtain all image frames of a single water flow cycle. Water flow animation can be generated based on all image frames of a single water flow cycle, and then imported into Unreal Engine to be played in the game scene corresponding to the water flow scene texture, thereby enhancing the realism of the water flow effect and improving the expressiveness and vividness of the game.

[0097] In one implementation, such as Figure 8 As shown, the process of generating a water flow animation can be divided into three main parts: data preprocessing, time parameter processing, and target water flow color generation. The water flow color of the target frame can be obtained according to the following steps S801 to S817, thereby generating the water flow animation:

[0098] Step S801: Make the areas outside the water flow in the preset water flow scene texture uSampler transparent to obtain the water flow noise texture uSamplerNoise, and extract and store the water flow noise in the path noiseUrl.

[0099] Step S802: Load the water flow noise texture according to the preset water flow noise texture resource path noiseUrl;

[0100] Step S803: Pass the water flow noise texture into the target water flow color generation part and declare it as uSamplerNoise;

[0101] Step S804: Pass the preset water flow intensity and water flow direction into the target water flow color generation part;

[0102] Step S805: Update the time parameter according to the sum of the time parameter value and the preset speed factor speedValue: value = value + speedValue (the value of the preset speed factor can be 0.1);

[0103] Step S806: If the time parameter is greater than the preset time parameter threshold value>=1, proceed to step S807; otherwise, proceed to step S808.

[0104] Step S807: Set the time parameter to 0: value = 0;

[0105] Step S808: Pass the value into the target water flow color generation part;

[0106] Step S809: Use the texture2D() function and the texture coordinates vTextureCoord of the water flow base map to sample the water flow noise map uSamplerNoise to obtain the base water flow color flowColor: flowColor = texture2D(uSamplerNoise, vTextureCoord);

[0107] Step S810: Extract the texture coordinates of the pixels from the basic water flow color flowColor: flowCoord = vec2(flowColor.x, flowColor.y);

[0108] Step S811: Calculate the preset water flow strength parameter flowStrength based on the input water flow strength: flowStrength = vec2(strength, strength);

[0109] Step S812: Calculate the preset water flow direction parameter flowDirection based on the input water flow direction: if (direction == 1.0) flowDirection = vec2(0.0, 1.0) else if (direction == 2.0) flowDirection = vec2(0.0, -1.0) else if (direction == 3.0) flowDirection = vec2(1.0, 0.0) else if (direction == 4.0) flowDirection = vec2(-1.0, 0.0);

[0110] Step S813: Calculate the flow parameter flowFactor based on the pixel texture coordinates flowCoord, the preset flow strength parameter flowStrength, and the preset flow direction parameter flowDirection: flowFactor = flowCoord * flowStrength * flowDirection;

[0111] Step S814: Calculate the offset value twice for the time parameter value to obtain the first offset value fract(value) and the second offset value fract(value+0.5); multiply the flow parameter flowFactor with the first and second offset values ​​to obtain the first offset coordinate offset1 = flowFactor*fract(value) and the second offset coordinate offset2 = flowFactor*fract(value+0.5);

[0112] Step S815: Add the first offset coordinate offset1 and the second offset coordinate offset2 to the texture coordinates vTextureCoord.xy of the water flow scene texture to obtain the first color sampling coordinate uv1 and the second color sampling coordinate uv2: uv1 = vTextureCoord.xy + offset1 uv2 = vTextureCoord.xy + offset2;

[0113] Step S816: Based on the first color sampling coordinate uv1 and the second color sampling coordinate uv2, the water flow scene texture uSampler is sampled twice to obtain the first water flow color color1 and the second water flow color color2: color1 = texture2D(uSampler,uv1) color2 = texture2D(uSampler,uv2).

[0114] Step S817: Calculate the color mixing parameter interpolation based on the time parameter value: interpolation = abs(fract(value) * 2.0 - 1.0); Perform linear interpolation on the first water flow color color1 and the second water flow color color2 based on the color mixing parameter to obtain the target water flow color gl FragColor: gl FragColor = mix(color1, color2, interpolation);

[0115] based on Figure 8 This method can enhance the realism of water flow animation while effectively improving the generation efficiency and reducing the production cost of water flow animation.

[0116] Exemplary embodiments of this disclosure also provide a water flow animation generation apparatus. For example... Figure 9 As shown, the water flow animation generation device 900 may include:

[0117] The basic water flow color acquisition module 910 is configured to acquire the basic water flow color of pixels based on the water flow map.

[0118] The offset value determination module 920 is configured to determine the first offset value and the second offset value of the target frame based on the time parameter of the target frame. The target frame is one or more frames in the water flow animation to be generated. The time parameter increases with the frame sequence within a water flow cycle. The first offset value and the second offset value differ by a sampling interval value and change periodically with the time parameter.

[0119] The first water flow color and the second water flow color acquisition module 930 are configured to acquire water flow parameters based on the basic water flow color, and to obtain the first water flow color based on the water flow parameters and the first offset value, and to obtain the second water flow color based on the water flow parameters and the second offset value.

[0120] Color mixing module 940 is configured to use color mixing parameters to mix the first water flow color and the second water flow color to obtain the target water flow color of each pixel in each frame.

[0121] The water flow animation acquisition module 950 is configured to generate water flow animation based on the target water flow color of pixels in each frame.

[0122] In one embodiment, the water flow texture includes a water flow scene texture and a water flow noise texture; the acquisition of the basic water flow color of a pixel based on the water flow texture may include:

[0123] Obtain water flow noise texture based on water flow scene texture;

[0124] The water flow noise map is color sampled using the texture coordinates of the pixels to obtain the basic water flow color of the pixels.

[0125] In one implementation, the above-mentioned acquisition of water flow noise texture based on water flow scene texture may include:

[0126] Make the areas outside the water flow in the water flow scene texture transparent to obtain a water flow noise texture.

[0127] In one implementation, determining the first offset value and the second offset value of the target frame based on the time parameter of the target frame may include:

[0128] The first offset value is determined based on the time parameter;

[0129] The second offset value is determined based on the sum of the time parameter and the sampling interval value.

[0130] In one embodiment, the above-mentioned acquisition of water flow parameters based on basic water flow color may include:

[0131] The water flow parameters are obtained by multiplying the texture coordinates of the pixel, the preset water flow intensity parameters, and the preset water flow direction parameters.

[0132] In one embodiment, obtaining the first water flow color based on the water flow parameters and a first offset value, and obtaining the second water flow color based on the water flow parameters and a second offset value, may include:

[0133] The first color sampling coordinates are obtained based on the water flow parameters and the first offset value, and the second color sampling coordinates are obtained based on the water flow parameters and the second offset value.

[0134] The water flow scene texture is sampled using the first color sampling coordinate and the second color sampling coordinate to obtain the first water flow color and the second water flow color.

[0135] In one embodiment, the process of obtaining the first color sampling coordinates based on the water flow parameters and the first offset value, and obtaining the second color sampling coordinates based on the water flow parameters and the second offset value, may include:

[0136] Multiply the water flow parameters by the first offset value and the second offset value respectively to obtain the first offset coordinate and the second offset coordinate;

[0137] The texture coordinates of the pixel are added to the first offset coordinate and the second offset coordinate respectively to obtain the first color sampling coordinate and the second color sampling coordinate.

[0138] In one embodiment, the above-mentioned color mixing of the first water flow color and the second water flow color using color mixing parameters to obtain the target water flow color of each pixel in each frame may include:

[0139] Calculate color mixing parameters based on time parameters;

[0140] The color mixing parameters are used to perform linear interpolation between the first and second water flow colors, and the target water flow color of each pixel in each frame is obtained based on the result of the linear interpolation.

[0141] The specific details of each part of the above-mentioned device have been described in detail in the method section of the implementation, and therefore will not be repeated here.

[0142] Exemplary embodiments of this disclosure also provide a computer-readable storage medium that can be implemented as a program product including program code, which, when run on an electronic device, causes the electronic device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. In an alternative embodiment, the program product can be implemented as a portable compact disc read-only memory (CD-ROM) including program code and can run on an electronic device, such as a personal computer. However, the program product of this disclosure is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0143] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0144] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0145] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0146] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing devices can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0147] Exemplary embodiments of this disclosure also provide an electronic device. The electronic device may include a processor and a memory. The memory stores executable instructions for the processor, such as program code. The processor executes the executable instructions to perform the methods of this exemplary embodiment.

[0148] The following is for reference. Figure 10 The electronic device is illustrated by way of a general-purpose computing device. It should be understood that... Figure 10 The electronic device 1000 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.

[0149] like Figure 10 As shown, the electronic device 1000 may include: a processor 1010, a memory 1020, a bus 1030, an I / O (input / output) interface 1040, and a network adapter 1050.

[0150] The processor 1010 may include one or more processing units, such as a central processing unit (CPU), an application processor (AP), a modem processor, a display processing unit (DPU), a graphics processing unit (GPU), an image signal processor (ISP), a controller, an encoder, a decoder, a digital signal processor (DSP), a baseband processor, an artificial intelligence processor, etc. In one embodiment, the CPU can obtain the basic water flow color of a pixel based on a water flow map, determine the first offset value and the second offset value of the target frame according to the time parameters of the target frame, then obtain water flow parameters based on the basic water flow color, obtain the first water flow color based on the water flow parameters and the first offset value, obtain the second water flow color based on the water flow parameters and the second offset value, and mix the first water flow color and the second water flow color using color mixing parameters to obtain the target water flow color of the pixels in the target frame. Finally, a water flow animation is generated based on the target water flow color of the pixels in each frame.

[0151] The memory 1020 may include volatile memory, such as RAM 1021 and cache unit 1022, and may also include non-volatile memory, such as ROM 1023. The memory 1020 may also include one or more program modules 1024, such program modules 1024 including, but not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. For example, program module 1024 may include the modules in the aforementioned device 900.

[0152] Bus 1030 is used to connect different components of electronic device 1000, and may include data bus, address bus and control bus.

[0153] Electronic device 1000 can communicate with one or more external devices 1100 (such as keyboard, mouse, external controller, etc.) through I / O interface 1040.

[0154] Electronic device 1000 can communicate with one or more networks via network adapter 1050. For example, network adapter 1050 can provide mobile communication solutions such as 3G / 4G / 5G, or wireless communication solutions such as wireless LAN, Bluetooth, and near-field communication. Network adapter 1050 can communicate with other modules of electronic device 1000 via bus 1030.

[0155] although Figure 10 Other hardware and / or software modules, including but not limited to: displays, microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, may also be configured in the electronic device 1000.

[0156] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0157] Those skilled in the art will understand that various aspects of this disclosure can be implemented as systems, methods, or program products. Therefore, various aspects of this disclosure can be embodied in entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuit,” “module,” or “system.” Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0158] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is defined only by the appended claims.

Claims

1. A method for generating water flow animation, characterized in that, include: The base water flow color of a pixel is obtained based on the water flow map; The first offset value and the second offset value of the target frame are determined based on the time parameter of the target frame. The target frame is one or more frames in the water flow animation to be generated. The time parameter increases with the frame order within a water flow cycle. The first offset value and the second offset value differ by a sampling interval value and change periodically with the time parameter. Based on the basic water flow color, water flow parameters are obtained, and a first water flow color is obtained according to the water flow parameters and the first offset value. A second water flow color is obtained according to the water flow parameters and the second offset value. The first water flow color and the second water flow color are mixed using color mixing parameters to obtain the target water flow color of each pixel in each frame. The water flow animation is generated based on the target water flow color of the pixels in each frame.

2. The method according to claim 1, characterized in that, The water flow texture includes a water flow scene texture and a water flow noise texture; The method of obtaining the basic water flow color of pixels based on water flow mapping includes: The water flow noise map is obtained based on the water flow scene map; The water flow noise map is color sampled using the texture coordinates of the pixel to obtain the basic water flow color of the pixel.

3. The method according to claim 2, characterized in that, The process of obtaining water flow noise maps based on water flow scene maps includes: The area outside the water flow in the water flow scene texture is made transparent to obtain the water flow noise texture.

4. The method according to claim 1, characterized in that, Determining the first offset value and the second offset value of the target frame based on the time parameters of the target frame includes: The first offset value is determined based on the time parameter; The second offset value is determined based on the sum of the time parameter and the sampling interval value.

5. The method according to claim 1, characterized in that, The process of obtaining water flow parameters based on the basic water flow color includes: The water flow parameters are obtained by multiplying the texture coordinates of the pixel, the preset water flow intensity parameters, and the preset water flow direction parameters.

6. The method according to claim 1, characterized in that, The step of obtaining a first water flow color based on the water flow parameters and the first offset value, and obtaining a second water flow color based on the water flow parameters and the second offset value, includes: The first color sampling coordinates are obtained based on the water flow parameters and the first offset value, and the second color sampling coordinates are obtained based on the water flow parameters and the second offset value. The water flow scene texture is sampled using the first color sampling coordinates and the second color sampling coordinates to obtain the first water flow color and the second water flow color.

7. The method according to claim 6, characterized in that, The step of obtaining the first color sampling coordinates based on the water flow parameters and the first offset value, and obtaining the second color sampling coordinates based on the water flow parameters and the second offset value, includes: The water flow parameters are multiplied by the first offset value and the second offset value respectively to obtain the first offset coordinate and the second offset coordinate; The texture coordinates of the pixel are added to the first offset coordinate and the second offset coordinate respectively to obtain the first color sampling coordinate and the second color sampling coordinate.

8. The method according to claim 1, characterized in that, The step of mixing the first and second water flow colors using color mixing parameters to obtain the target water flow color for each pixel in each frame includes: The color mixing parameters are calculated based on the time parameters; The first water flow color and the second water flow color are linearly interpolated using the color mixing parameters, and the target water flow color of each pixel in each frame is obtained based on the result of the linear interpolation.

9. A water flow animation generation device, characterized in that, include: The basic water flow color acquisition module is configured to acquire the basic water flow color of pixels based on the water flow map; The offset value determination module is configured to determine a first offset value and a second offset value of the target frame based on the time parameter of the target frame. The target frame is one or more frames in the water flow animation to be generated. The time parameter increases with the frame order within a water flow cycle. The first offset value and the second offset value differ by a sampling interval value and change periodically with the time parameter. The first water flow color and the second water flow color acquisition module are configured to acquire water flow parameters based on the basic water flow color, obtain the first water flow color according to the water flow parameters and the first offset value, and obtain the second water flow color according to the water flow parameters and the second offset value. The color mixing module is configured to use color mixing parameters to mix the first water flow color and the second water flow color to obtain the target water flow color of each pixel in each frame. The water flow animation acquisition module is configured to generate the water flow animation based on the target water flow color of the pixels in each frame.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 8.

11. An electronic device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to execute the method of any one of claims 1 to 8 by executing the executable instructions.