Fluid animation processing method and device, electronic device, and storage medium
By obtaining the current position and velocity of fluid particles, using constraint projection equations and collision detection to update the motion position, and combining factors such as gravity, density constraints and viscosity, the problem that fluid animation in existing technologies cannot achieve interactivity is solved, and a more realistic and interactive fluid animation effect is achieved.
Patent Information
- Application Number
- CN202111662958.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2041-12-30
AI Technical Summary
Although existing fluid animation solutions can create shapes when rendering fluid motion, they cannot meet the needs of interactivity and are limited to restoring corresponding physical behaviors through specific algorithms.
By obtaining the current position and velocity of each fluid particle in the fluid particle group, using the constraint projection equation and collision detection to update the motion position, and combining factors such as gravity, density constraints, artificial repulsion and viscosity, the motion state of the fluid particles is determined to achieve the authenticity and interactivity of the fluid animation.
Improves the realism and interactivity of fluid animation, enabling more accurate simulation of fluid motion and real-time interactive operations.
Smart Images

Figure CN114299199B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a fluid animation processing method and device, electronic equipment, and storage medium. Background Art
[0002] With the advancement of computer technology, fluid animation simulation has been widely used in fields such as animated films and games, becoming a crucial component in visual effects development. Related fluid animation solutions prioritize realistic and believable rendering, typically using flow maps and Gerstner Waves to simulate motion. While these methods can simulate fluid forms, they are limited to reproducing corresponding physical behaviors through specific algorithms and fall short of interactivity requirements. Summary of the Invention
[0003] In view of the above problems, the present application is proposed to provide a fluid animation processing method and device, electronic device, and storage medium that overcome the above problems or at least partially solve the above problems, including:
[0004] A fluid animation processing method, the method comprising:
[0005] Obtaining the first position and first velocity of each fluid particle in the fluid particle group at the current moment;
[0006] determining a moving position of the fluid particle at a next moment according to a constraint projection equation of the fluid particle and the first position and first velocity;
[0007] updating the movement position through collision detection to obtain a second position;
[0008] Based on the first position and the second position, an animation of the fluid particles is determined to obtain a fluid animation of the fluid particle group.
[0009] Optionally, determining the moving position of the fluid particle at a next moment according to the constraint projection equation of the fluid particle and the first position and the first velocity includes:
[0010] determining a gravitational position offset and acceleration of the fluid particles caused by gravity parameters;
[0011] updating the first position and the first velocity according to the gravity position offset and the acceleration;
[0012] The moving position of the fluid particle at the next moment is determined according to the constraint projection equation of the fluid particle and the updated first position and the updated first velocity.
[0013] Optionally, the constraint condition of the constrained projection equation is a density constraint; and determining the motion position of the fluid particle at a next moment according to the constrained projection equation of the fluid particle and the updated first position and the updated first velocity includes:
[0014] Determining a data structure for neighbor particle search, and determining neighbor particles of the fluid particle based on the data structure for neighbor particle search;
[0015] Obtaining a density constraint equation of the fluid particles;
[0016] The constraint projection equation is solved according to the solution of the density constraint equation to determine the moving position of the fluid particle at the next moment.
[0017] Optionally, the method further includes:
[0018] Obtaining a relaxation factor, where the relaxation factor is used to constrain the projection range of fluid particles;
[0019] Based on the relaxation factor, the constrained projection equation is updated.
[0020] Optionally, the method further includes:
[0021] When the pressure of the fluid particle is negative, obtaining the artificial repulsive force corresponding to the fluid particle;
[0022] The motion position obtained according to the constraint projection equation of the fluid particle and the first position and the first velocity is determined as the initial position, and the initial position is updated according to the repulsive force position offset generated by the artificial repulsive force on the fluid particle to obtain the motion position of the fluid particle at the next moment.
[0023] Optionally, updating the motion position through collision detection to obtain a second position includes:
[0024] When the moving position of the fluid particles is located inside the collision body, the moving position of the fluid particles is adjusted to the outside of the collision body to obtain a second position.
[0025] Optionally, the method further includes:
[0026] Calculating a second velocity of the fluid particle at a next moment according to the second position, the first position, the first velocity, and the time step between the next moment and the current moment;
[0027] After determining the animation of the fluid particles from the current moment to the next moment, the first velocity is updated using the second velocity, and the first position is updated using the second position.
[0028] Optionally, after calculating the second velocity of the fluid particle at the next moment based on the second position, the first position and the first velocity, and the time steps at the next moment and the current moment, the method further includes:
[0029] determining a viscous damping velocity of the fluid particles caused by viscous forces;
[0030] The second velocity of the fluid particles is updated according to the viscous damping velocity.
[0031] A fluid animation processing device, comprising:
[0032] An initial state acquisition module, used to obtain the first position and first velocity of each fluid particle in the fluid particle group at the current moment;
[0033] a motion position determining module, configured to determine the motion position of the fluid particle at a next moment according to the constraint projection equation of the fluid particle and the first position and first velocity;
[0034] A second position determination module, configured to update the motion position through collision detection to obtain a second position;
[0035] The fluid animation determination module is used to determine the animation of the fluid particles from the current moment to the next moment based on the first position and the second position, so as to obtain the fluid animation of the fluid particle group.
[0036] Optionally, the motion position determination module includes:
[0037] A state determination module based on gravity parameters, for determining a gravity position offset and acceleration of the fluid particles generated by the gravity parameters;
[0038] A gravity parameter-based state updating module, configured to update the first position and the first velocity according to the gravity position offset and acceleration;
[0039] The module for determining the motion position based on the updated state is used to determine the motion position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle and the updated first position and the updated first velocity.
[0040] Optionally, the constraint condition of the constrained projection equation is a density constraint; and the motion position determination module includes:
[0041] a neighbor particle search and determination module, configured to determine a data structure for neighbor particle search, and determine neighbor particles of the fluid particle based on the data structure for neighbor particle search;
[0042] A density constraint equation determination module, used to obtain the density constraint equation of the fluid particles;
[0043] The module for determining the movement position based on the density constraint equation is used to solve the constraint projection equation according to the solution of the density constraint equation to determine the movement position of the fluid particle at the next moment.
[0044] Optionally, the device further comprises:
[0045] A relaxation factor acquisition module, used to acquire a relaxation factor, wherein the relaxation factor is used to constrain the projection range of fluid particles;
[0046] The module for updating the constraint projection equation based on the relaxation factor is used to update the constraint projection equation based on the relaxation factor.
[0047] Optionally, the device further comprises:
[0048] an artificial repulsive force acquisition module, configured to acquire the artificial repulsive force corresponding to the fluid particles when the pressure of the fluid particles is negative;
[0049] The motion position updating module based on artificial repulsion is used to determine the motion position obtained according to the constraint projection equation of the fluid particle and the first position and the first velocity as the initial position, and update the initial position according to the repulsive position offset generated by the artificial repulsion on the fluid particle to obtain the motion position of the fluid particle at the next moment.
[0050] Optionally, the second position determination module includes:
[0051] The collision detection module is configured to adjust the moving position of the fluid particle to the outside of the collision body when the moving position of the fluid particle is inside the collision body, so as to obtain a second position.
[0052] Optionally, the device further comprises:
[0053] a second velocity determination module, configured to calculate a second velocity of the fluid particle at a next moment according to the second position, the first position, the first velocity, and the time steps between the next moment and the current moment;
[0054] The initial state updating module is configured to, after determining the animation of the fluid particles from the current moment to the next moment, update the first velocity with the second velocity and update the first position with the second position.
[0055] Optionally, the device further comprises:
[0056] a viscous force damping velocity acquisition module, configured to determine the viscous force damping velocity of the fluid particles caused by the viscous force;
[0057] A velocity updating module based on the viscous damping velocity is configured to update the second velocity of the fluid particles according to the viscous damping velocity.
[0058] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the fluid animation processing method described above when executed by the processor.
[0059] A computer-readable storage medium stores a computer program, which implements the steps of the fluid animation processing method described above when executed by a processor.
[0060] This application has the following advantages:
[0061] In an embodiment of the present application, the first position and the first velocity of each fluid particle in the fluid particle group at the current moment are obtained; the motion position of the fluid particle at the next moment is determined according to the constraint projection equation of the fluid particle and the first position and the first velocity; the motion position is updated through collision detection to obtain the second position; based on the first position and the second position, the animation of the fluid particle from the current moment to the next moment is determined to obtain the fluid animation of the fluid particle group; the embodiment of the present application particle-izes the fluid, and determines the motion state of the fluid particle group used to form the fluid by determining the motion state of each fluid particle, which can improve the realism of the flow animation, and in the process of determining the motion state of the fluid particles, the motion state of the fluid particles is updated in combination with collision detection, thereby realizing the interactivity of the fluid animation. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for the description of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0063] Figure 1 This is a flow chart of the steps of a fluid animation processing method according to an embodiment of the present application;
[0064] Figure 2 This is a structural block diagram of a fluid animation processing device according to an embodiment of the present application. DETAILED DESCRIPTION
[0065] To make the above-mentioned purposes, features, and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and specific embodiments. It is apparent that the embodiments described are only a portion of the embodiments of this application, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments in this application without inventive effort are also within the scope of protection of this application.
[0066] Related fluid animation solutions generally use Flow map and Gerstner Wave to achieve the effect of fluid motion. Flow map uses the principle of UV animation, which means that UV offsets need to be made according to the information in the Flow map, and then the offset size is changed over time to produce a flow effect. Gerstner Wave uses the Gerstner wave function to control the movement of mesh vertices, thereby producing a flow effect. Although the above solutions can produce fluid shapes, they are limited to restoring the corresponding physical behavior through specific algorithms and do not meet the needs of interactivity.
[0067] In view of this, an embodiment of the present application provides a fluid animation processing method to overcome the shortcomings of the prior art.
[0068] The fluid animation processing method in the embodiment of the present application can be run on a local terminal device or a server. When the fluid animation processing method is run on a server, the fluid animation processing method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0069] In an optional embodiment, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a gaming method based on cloud computing. In the cloud game operation mode, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the fluid animation processing method are completed on the cloud game server. The role of the client device is to receive and send data and present the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a first terminal device, a TV, a computer, a handheld computer, etc.; but the fluid animation processing method is performed by the cloud game server in the cloud. When playing the game, the player operates the client device to send operation instructions to the cloud game server. The cloud game server runs the game according to the operation instructions, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0070] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present the game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, conventionally downloading and installing the game program through an electronic device and running it. The local terminal device can provide the graphical user interface to the player in a variety of ways, for example, it can be rendered and displayed on the terminal's display screen, or provided to the player through holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present the graphical user interface, the graphical user interface includes the game screen, and the processor is used to run the game, generate the graphical user interface, and control the display of the graphical user interface on the display screen.
[0071] Reference Figure 1 , shows a flow chart of a fluid animation processing method provided by an embodiment of the present application. In the embodiment of the present application, the method may include the following steps:
[0072] Step 101, obtaining the first position and first velocity of each fluid particle in the fluid particle group at the current moment;
[0073] Step 102: determining the moving position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle and the first position and first velocity;
[0074] Step 103, updating the movement position through collision detection to obtain a second position;
[0075] Step 104 : Based on the first position and the second position, determine the animation of the fluid particles from the current moment to the next moment to obtain the fluid animation of the fluid particle group.
[0076] The embodiment of the present application obtains the first position and the first velocity of each fluid particle in the fluid particle group at the current moment; determines the motion position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle and the first position and the first velocity; updates the motion position through collision detection to obtain the second position; and determines the animation of the fluid particle from the current moment to the next moment based on the first position and the second position to obtain the fluid animation of the fluid particle group; the embodiment of the present application particle-izes the fluid, and determines the motion state of the fluid particle group used to form the fluid by determining the motion state of each fluid particle, which can improve the realism of the flow animation, and in the process of determining the motion state of the fluid particles, combines the collision detection to update the motion state of the fluid particles, thereby realizing the interactivity of the fluid animation.
[0077] Next, the fluid animation processing method in this exemplary embodiment will be further described.
[0078] In step 101, the first position and first velocity of each fluid particle in the fluid particle group at the current moment are obtained.
[0079] In this embodiment, fluids are particle-ized, that is, fluids are represented by groups of fluid particles. A group of fluid particles is composed of multiple fluid particles, which interact with each other. Each fluid particle carries corresponding physical quantities, including mass, density, velocity, etc. The position of the fluid particles can also be determined based on their positional relationships in the corresponding virtual scene.
[0080] The current moment can be any moment. The first position and first velocity of each fluid particle at the current moment are related to its position and velocity at the previous moment, and also affect its position and velocity at the next moment. When the current moment is the initial moment, the first position and first velocity at the current moment are determined by pre-set system parameters. It is understood that when creating a fluid, animation designers can configure corresponding position parameters and velocity parameters for the fluid particles forming the fluid according to actual needs, as the initial velocity and position of the fluid particles.
[0081] In step 102, the moving position of the fluid particle at the next moment is determined according to the constraint projection equation of the fluid particle and the first position and first velocity.
[0082] The fluids involved in the embodiments of this application are liquid fluids. The motion of fluid particles is subject to various constraints. Constrained projection equations are used to determine the motion position of the fluid particles at the next moment in order to simulate real-world fluid motion. When solving the constrained projection equations for the fluid particles, the first position and first velocity of the fluid particles at the current moment are combined to determine the motion position of the fluid particles at the next moment.
[0083] In an optional embodiment of the present application, in order to improve the simulation effect of the fluid animation, the above-mentioned determining the movement position of the fluid particle at the next moment based on the constraint projection equation of the fluid particle and the first position and the first velocity includes:
[0084] determining a gravitational position offset and acceleration of the fluid particles caused by gravity parameters;
[0085] updating the first position and the first velocity according to the gravity position offset and the acceleration;
[0086] The moving position of the fluid particle at the next moment is determined according to the constraint projection equation of the fluid particle and the updated first position and the updated first velocity.
[0087] This embodiment divides the forces acting on fluid particles into those related to positional constraints and those unrelated to positional constraints. It should be understood that forces related to positional constraints are those whose magnitude is related to the motion of the fluid particles, including but not limited to the interaction forces between the fluid particles. Forces unrelated to positional constraints, on the other hand, are fixed-magnitude forces, including but not limited to gravity. In other words, the gravity parameter in this embodiment refers to forces that cannot generate positional constraints, and is not limited to gravity.
[0088] The gravity parameters, including the magnitude and direction of the force, can be set by the animation designer based on actual needs. By obtaining the magnitude and direction of the force corresponding to the gravity parameters and combining them with Newton's second law, the gravitational position offset and acceleration of the fluid particles under the influence of the gravity parameters can be calculated. Combined with the fluid particles' current first position and first velocity, the updated first position and first velocity of the fluid particles can be obtained.
[0089] Before using the constrained projection equation of the fluid particles to determine the movement position of the fluid particles at the next moment, this embodiment calculates the influence of the gravity parameter on the position and velocity of the fluid particles and updates the first position and first velocity of the fluid particles, thereby ensuring the accuracy of the calculated movement position of the fluid particles at the next moment.
[0090] In an optional embodiment of the present application, the constraint condition of the constraint projection equation is a density constraint, and the determining of the motion position of the fluid particle at the next moment based on the constraint projection equation of the fluid particle and the updated first position and the updated first velocity includes:
[0091] Determining a data structure for neighbor particle search, and determining neighbor particles of the fluid particle based on the data structure for neighbor particle search;
[0092] Obtaining a density constraint equation of the fluid particles;
[0093] The constraint projection equation is solved according to the solution of the density constraint equation to determine the moving position of the fluid particle at the next moment.
[0094] Because fluid particles interact with each other, determining the motion state of a fluid particle requires determining the influence of its neighboring fluid particles on the particle. The neighbor particle search data structure accelerates the neighbor particle search to identify the neighboring fluid particles of the target fluid particle, which can be any fluid particle whose motion state needs to be determined.
[0095] There are many data structures for neighbor particle search. This example adopts the idea of Hash hashing uniform grid division. Spatial hashing uses hash tables to store grid information. The corresponding hash function is expressed as follows:
[0096] hash(X grid )=(xP1)XOR(yP2)XOR(zP3)mod N
[0097] Where X represents the grid coordinate, X grid =(x, y, z);
[0098] x, y, and z are the spatial coordinates of the target fluid particle. P1, P2, and P3 are three prime numbers. For example, P1 = 73,856,093, P2 = 19,349,663, and P3 = 83,492,791. N is the total number of grid cells. The coordinates of the fluid particle can be used to calculate the grid coordinates to which it belongs. When using uniform spatial partitioning for neighbor search, the grid coordinates of the target fluid particle can be used to determine the coordinates of the 26 surrounding grids. After calculating the values for each of these 27 grids, the fluid particle in that grid is queried in a hash table to determine whether it is a neighbor of the target fluid particle.
[0099] Optionally, since fluid particles cannot be well positioned and perform neighbor particle search in world space, it is necessary to normalize the coordinates of the fluid particles through a normalization matrix. The specific normalization matrix is related to the data structure used for neighbor particle search. For the data structure divided by Hash hash uniform grid in this example, the corresponding normalization matrix is expressed as follows:
[0100]
[0101] In this embodiment, the constraint projection equation can be expressed as:
[0102] C(p+Δp)=0
[0103] Where C represents the constraint equation, p represents the position, and Δp represents the displacement deviation.
[0104] In an optional embodiment of the present application, the constraint equation for constraining the projection equation adopts a density constraint equation. In this case, the constraint equation C can be expressed as:
[0105]
[0106] Among them, C i represents the density constraint equation of the target fluid particles, p1,…,p n represents the position of the neighboring particles of the target fluid particle, ρ i represents the dynamic density of the target fluid particles; ρ0 represents the static density of the fluid.
[0107] By obtaining the density constraint equation of the fluid particles, the constraint projection equation can be solved to obtain the motion position of the fluid particles at the next moment.
[0108] The density constraint equation obtained in an optional embodiment of the present application is as follows:
[0109]
[0110] Where i represents the target fluid particle, j represents the neighbor particle of the target fluid particle, W represents the density kernel function, p represents the position, h represents the compact support domain, and ρ0 represents the static density;
[0111] After determining the density constraint equation of the fluid particles, the density constraint equation can be converted into data. For example, by taking the gradient of both sides of the density constraint equation, we can obtain:
[0112]
[0113] The above gradient calculation needs to be combined with a density kernel function. The specific form of the density kernel function can be set and selected according to actual needs. In this embodiment, Muller's W_spiky kernel function is used for gradient calculation, where the W_spiky kernel function is one of the commonly used kernel functions in this field. The result obtained contains the density gradient of the target fluid particle and its neighboring particles. The corresponding formula is as follows:
[0114]
[0115] Among them, k is used to distinguish between two situations of target fluid particles and neighbor particles. It can be understood that when k=i, the formula in the previous row is used for calculation; when k=j, the formula in the next row is used for calculation.
[0116] In the process of solving the constraint projection equation, the constraint projection equation can be expanded by a first-order Taylor expansion to obtain the first-order Taylor representation of the constraint projection equation:
[0117]
[0118] Among them, λ is the Lagrange multiplier, which is expressed as follows:
[0119]
[0120] After obtaining the solution of the density constraint equation, the value of the Lagrange multiplier can be obtained, and then the constraint projection equation is solved to obtain the displacement deviation. Combined with the first position, the motion position of the fluid particle can be obtained.
[0121] Furthermore, in order to prevent the system from being unstable at the edge of the smooth core, in an optional embodiment of the present application, the fluid animation processing method may further include:
[0122] Obtaining a relaxation factor, where the relaxation factor is used to constrain the projection range of fluid particles;
[0123] Based on the relaxation factor, the constrained projection equation is updated.
[0124] Among them, the size of the relaxation factor can be set by the animation designer according to the actual animation requirements. Generally speaking, the larger the relaxation factor, the smaller the projection range of the fluid particles. That is to say, by adding the relaxation factor to the constraint projection equation, the system can always be in a hard constraint state. Reasonable control of the size of the relaxation factor according to actual needs can make the fluid animation more realistic.
[0125] For example, after introducing the relaxation factor into the above constraint projection equation, we can obtain:
[0126]
[0127] Among them, ∈ is the relaxation factor, which is a constant, and λ is the Lagrange multiplier, which is expressed as follows:
[0128]
[0129] The expression of displacement deviation is obtained by sorting:
[0130]
[0131] After mathematical transformation, the displacement deviation can be expressed as:
[0132]
[0133] By solving the Lagrange multiplier, the displacement deviation can be obtained, and then combined with the first position at the current moment, the moving position of the fluid particle at the next moment can be obtained.
[0134] Furthermore, in an optional embodiment of the present application, it is also considered that when the number of neighboring particles of a fluid particle is insufficient, the pressure gradient will be negative, thereby causing abnormal particle aggregation. In order to solve this non-physical problem, this embodiment introduces an additional repulsive force, namely artificial repulsion. The above-mentioned fluid animation processing method also includes:
[0135] When the pressure of the fluid particle is negative, obtaining the artificial repulsive force corresponding to the fluid particle;
[0136] The motion position obtained according to the constraint projection equation of the fluid particle and the first position and the first velocity is determined as the initial position, and the initial position is updated according to the repulsive force position offset generated by the artificial repulsive force on the fluid particle to obtain the motion position of the fluid particle at the next moment.
[0137] In this embodiment, when the pressure of the fluid particle becomes negative, the artificial repulsive force corresponding to the fluid particle is obtained; the movement position of the fluid particle is updated based on the artificial repulsive force, and the corresponding displacement deviation calculation formula is:
[0138]
[0139] Among them, s corr Indicates artificial repulsion, k is a constant, W represents a kernel function, which may specifically be the W_poly6 kernel function, which is one of the commonly used kernel functions in this field; and λ is a Lagrange multiplier.
[0140] In step 103, the movement position is updated through collision detection to obtain a second position.
[0141] After the motion position of the fluid particle at the next moment is calculated by the constrained projection equation, collision detection is required to determine whether the motion position is inside the collision body. If so, the motion position of the fluid particle is adjusted to the outside of the collision body, and the adjusted motion position is used as the final motion position of the fluid particle at the next moment, that is, the second motion position.
[0142] The collision volume includes the collision volume corresponding to the neighboring particle and the boundary collision volume. Optionally, the collision volume corresponding to the neighboring particle can be a spherical mesh volume that coincides with the outer surface of the neighboring particle, and the boundary collision volume can be a patch mesh volume that coincides with the inner surface of the container used to hold the fluid particle group.
[0143] When the collision body is a spherical mesh, the distance between the moving position and the collision body's center is detected to determine whether the distance is less than the collision body's radius or a certain threshold. If so, it indicates that the fluid particle has collided with the collision body. In this case, the moving position of the fluid particle is adjusted to outside the collision body. Optionally, the moving position of the fluid particle can be moved to the position closest to the collision body's surface to obtain the updated moving position of the fluid particle, i.e., the second position.
[0144] When the collision volume is a patch mesh, the fluid particle's first position and moving position are checked to see if they are on opposite sides of the patch mesh. If so, a collision has occurred between the fluid particle and the collision volume. The moving position of the fluid particle is then adjusted to the same side as the first position. Alternatively, the first position and the moving position can be connected, and the point where the connecting line intersects the patch mesh is used as the updated moving position of the fluid particle, i.e., the second position.
[0145] In step 104 , based on the first position and the second position, the animation of the fluid particles from the current moment to the next moment is determined to obtain the fluid animation of the fluid particle group.
[0146] For each fluid particle in the fluid particle group, through the above steps 101-104, the first position of each fluid particle at the current moment and the second position at the next moment can be determined, and then the position state of the fluid particle group at the current moment and the position state at the next moment can be determined. Based on the first position of each fluid particle at the current moment (i.e., the position state of the fluid particle group at the current moment), a frame of animation can be rendered, recorded as the first animation frame; based on the second position of each fluid particle at the next moment (i.e., the position state of the fluid particle group at the next moment), a frame of animation can be rendered, recorded as the second animation frame; from the first frame animation and the second frame animation, a fluid animation of the fluid particle group from the current moment to the next moment can be obtained.
[0147] Furthermore, after determining the first position and first velocity at the current moment and the moving position at the next moment, the moving velocity of the fluid particle at the next moment, ie, the second velocity, can be calculated based on the time step between the current moment and the next moment.
[0148] It should be noted that the direction of the second velocity obtained after a collision is opposite to the direction of the first velocity.
[0149] After determining the animation of the fluid particles from the current moment to the next moment, that is, after determining the fluid animation of the fluid particle group from the current moment to the next moment, the second speed is used to update the first speed, and the second position is used to update the first position to continue to obtain the fluid animation of the fluid particle group from the next moment to the next moment. This cycle is repeated to obtain animation frames at different moments. Multiple animation frames are displayed according to the time sequence and time step of their generation to obtain fluid animation.
[0150] Furthermore, in an optional embodiment of the present application, after calculating the second velocity of the fluid particle at the next moment based on the second position, the first position, the first velocity, and the time step between the next moment and the current moment, the method further includes:
[0151] determining a viscous damping velocity of the fluid particles caused by viscous forces;
[0152] The second velocity of the fluid particles is updated according to the viscous damping velocity.
[0153] In this embodiment, the calculation of the movement velocity of the fluid particles also takes into account the influence of viscosity. According to the viscous damping speed generated by the viscosity, the initial velocity calculated based on the second position, the first position, the first velocity, and the time step between the next moment and the current moment is adjusted. The adjusted velocity is used as the second velocity of the fluid particle at the next moment. The calculation formula corresponding to the second velocity is as follows:
[0154]
[0155] in, Indicates the second speed, is the viscous damping velocity, v represents the velocity, c is a constant, v ij Indicates v i With v j The difference, that is, v ij =v i -v j , W represents a kernel function, specifically a W_viscosity kernel function, which is one of the commonly used kernel functions in this field.
[0156] In the process of calculating the second velocity, this embodiment takes into account the influence of viscosity on the velocity of fluid particles, so that the obtained fluid animation is more consistent with the physical behavior of real fluid, thereby improving the authenticity of fluid animation simulation.
[0157] The embodiment of the present application obtains the first position and the first velocity of each fluid particle in the fluid particle group at the current moment; determines the motion position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle and the first position and the first velocity; updates the motion position through collision detection to obtain the second position, and determines the second velocity of the fluid particle at the next moment based on the second position; determines the animation of the fluid particle based on the first position and the second position to obtain the fluid animation of the fluid particle group; the embodiment of the present application particle-izes the fluid, and determines the motion state of the fluid particle group used to form the fluid by determining the motion state of each fluid particle, which can improve the realism of the flow animation, and in the process of determining the motion state of the fluid particles, combines the collision detection to update the motion state of the fluid particles, thereby realizing the interactivity of the fluid animation.
[0158] It should be noted that for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0159] Reference Figure 2 , shows a structural block diagram of an embodiment of a fluid animation processing device of the present application, corresponding to the above-mentioned embodiment of the fluid animation processing method, the device may include the following modules:
[0160] The initial state acquisition module 201 is used to obtain the first position and first velocity of each fluid particle in the fluid particle group at the current moment;
[0161] A motion position determining module 202 is configured to determine the motion position of the fluid particle at a next moment according to the constraint projection equation of the fluid particle and the first position and first velocity;
[0162] A second position determination module 203 is configured to update the motion position through collision detection to obtain a second position;
[0163] The fluid animation determination module 204 is configured to determine the animation of the fluid particles from the current moment to the next moment based on the first position and the second position, so as to obtain the fluid animation of the fluid particle group.
[0164] In an optional embodiment of the present application, the motion position determination module 202 includes:
[0165] A state determination module based on gravity parameters, configured to determine a gravity position offset and an acceleration of the fluid particles caused by the gravity parameters;
[0166] A gravity parameter-based state updating module, configured to update the first position and the first velocity according to the gravity position offset and acceleration;
[0167] The module for determining the motion position based on the updated state is used to determine the motion position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle and the updated first position and the updated first velocity.
[0168] In an optional embodiment of the present application, the constraint condition of the constrained projection equation is a density constraint; the motion position determination module 202 includes:
[0169] a neighbor particle search and determination module, configured to determine a data structure for neighbor particle search, and determine neighbor particles of the fluid particle based on the data structure for neighbor particle search;
[0170] A density constraint equation determination module, used to obtain the density constraint equation of the fluid particles;
[0171] The module for determining the movement position based on the density constraint equation is used to solve the constraint projection equation according to the solution of the density constraint equation to determine the movement position of the fluid particle at the next moment.
[0172] In an optional embodiment of the present application, the device further includes:
[0173] A relaxation factor acquisition module, used to acquire a relaxation factor, wherein the relaxation factor is used to constrain the projection range of fluid particles;
[0174] The module for updating the constraint projection equation based on the relaxation factor is used to update the constraint projection equation based on the relaxation factor.
[0175] In an optional embodiment of the present application, the device further includes:
[0176] an artificial repulsive force acquisition module, configured to acquire the artificial repulsive force corresponding to the fluid particles when the pressure of the fluid particles is negative;
[0177] The motion position updating module based on artificial repulsion is used to determine the motion position obtained according to the constraint projection equation of the fluid particle and the first position and the first velocity as the initial position, and update the initial position according to the repulsive position offset generated by the artificial repulsion on the fluid particle to obtain the motion position of the fluid particle at the next moment.
[0178] In an optional embodiment of the present application, the second position determination module 203 includes:
[0179] The collision detection module is configured to adjust the moving position of the fluid particle to the outside of the collision body when the moving position of the fluid particle is inside the collision body, so as to obtain a second position.
[0180] Optionally, the device further comprises:
[0181] a second velocity determination module, configured to calculate a second velocity of the fluid particle at a next moment according to the second position, the first position, the first velocity, and the time steps between the next moment and the current moment;
[0182] The initial state updating module is configured to, after determining the animation of the fluid particles from the current moment to the next moment, update the first velocity with the second velocity and update the first position with the second position.
[0183] In an optional embodiment of the present application, the device further includes:
[0184] a viscous force damping velocity acquisition module, configured to determine the viscous force damping velocity of the fluid particles caused by the viscous force;
[0185] A velocity updating module based on the viscous damping velocity is configured to update the second velocity of the fluid particles according to the viscous damping velocity.
[0186] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0187] An embodiment of the present application also discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the steps of the fluid animation processing method described above are implemented.
[0188] The embodiment of the present application further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the fluid animation processing method described above are implemented.
[0189] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0190] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0191] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0192] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0193] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0194] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0195] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0196] The above is a detailed introduction to the fluid animation processing method and device, electronic device and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A fluid animation processing method, characterized in that: The method comprises: Obtaining the first position and first velocity of each fluid particle in the fluid particle group at the current moment; determining the motion position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle and the first position, the first velocity, and a gravity parameter; wherein the gravity parameter refers to a force that cannot generate position constraints; The moving position is updated through collision detection to obtain a second position; the collision detection is used to characterize the positional relationship between the fluid particle and the collision body, and the second position is the closest position on the surface of the collision body, or the point where a connecting line between the first position and the moving position intersects the collision body; Based on the first position and the second position, the animation of the fluid particles from the current moment to the next moment is determined to obtain the fluid animation of the fluid particle group.
2. The method according to claim 1, characterized in that The determining the movement position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle and the first position, the first velocity, and the gravity parameter includes: determining a gravitational position offset and acceleration of the fluid particles caused by gravity parameters; updating the first position and the first velocity according to the gravity position offset and the acceleration; The moving position of the fluid particle at the next moment is determined according to the constraint projection equation of the fluid particle and the updated first position and the updated first velocity.
3. The method according to claim 2, characterized in that The constraint condition of the constrained projection equation is a density constraint; and determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle and the updated first position and the updated first velocity includes: Determining a data structure for neighbor particle search, and determining neighbor particles of the fluid particle based on the data structure for neighbor particle search; Obtaining a density constraint equation of the fluid particles; The constraint projection equation is solved according to the solution of the density constraint equation to determine the moving position of the fluid particle at the next moment.
4. The method according to claim 3, characterized in that The method further comprises: Obtaining a relaxation factor, where the relaxation factor is used to constrain the projection range of fluid particles; Based on the relaxation factor, the constrained projection equation is updated.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: When the pressure of the fluid particle is negative, obtaining the artificial repulsive force corresponding to the fluid particle; The motion position obtained according to the constraint projection equation of the fluid particle and the first position and the first velocity is determined as the initial position, and the initial position is updated according to the repulsive force position offset generated by the artificial repulsive force on the fluid particle to obtain the motion position of the fluid particle at the next moment.
6. The method according to claim 1, characterized in that The updating of the motion position by collision detection to obtain a second position includes: When the moving position of the fluid particles is located inside the collision body, the moving position of the fluid particles is adjusted to the outside of the collision body to obtain a second position.
7. The method according to claim 1, characterized in that The method further includes: calculating a second velocity of the fluid particle at a next moment according to the second position, the first position and the first velocity, and a time step between the next moment and the current moment; After determining the animation of the fluid particles from the current moment to the next moment, the first velocity is updated using the second velocity, and the first position is updated using the second position.
8. The method according to claim 7, characterized in that After calculating the second velocity of the fluid particle at the next moment based on the second position, the first position and the first velocity, and the time steps at the next moment and the current moment, the method further includes: determining a viscous damping velocity of the fluid particles caused by viscous forces; The second velocity of the fluid particles is updated according to the viscous damping velocity.
9. A fluid animation processing device, characterized in that: The device comprises: An initial state acquisition module, used to obtain the first position and first velocity of each fluid particle in the fluid particle group at the current moment; a motion position determination module, configured to determine the motion position of the fluid particle at a next moment based on the constraint projection equation of the fluid particle and the first position, first velocity, and gravity parameter; wherein the gravity parameter refers to a force that cannot generate position constraints; a motion speed determination module, configured to update the motion position through collision detection to obtain a second position; wherein the collision detection is used to characterize the positional relationship between the fluid particle and the collision body, and the second position is the closest position on the surface of the collision body, or the point where a connecting line between the first position and the motion position intersects the collision body; The fluid animation determination module is used to determine the animation of the fluid particles from the current moment to the next moment based on the first position and the second position, so as to obtain the fluid animation of the fluid particle group.
10. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the fluid animation processing method according to any one of claims 1 to 8 when executed by the processor.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the fluid animation processing method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Video generation method and device and storage medium
CN113824990A