Particle driving fluid simulation and rendering method of mobile phone terminal
By employing a particle-driven fluid simulation and rendering method, combined with Vulkan shaders and screen-space rendering, and optimizing computation and interaction, the efficiency and quality issues of fluid simulation and rendering on mobile devices have been resolved, achieving high frame rates and realistic fluid effects.
Patent Information
- Application Number
- CN202610187416.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-10
- Publication Date
- 2026-03-17
- Estimated Expiration
- 2046-02-10
AI Technical Summary
Existing technologies struggle to achieve efficient and realistic fluid simulation and rendering on mobile devices due to limitations in computing power, memory bandwidth, and power consumption.
We employ a particle-driven fluid simulation method combined with Vulkan shaders and screen-space fluid rendering. By optimizing computation through the PBF algorithm and incorporating a physically based shading model and mobile touch interaction, we reduce computational overhead and improve rendering quality.
It achieves high frame rate and low computational overhead fluid simulation and rendering on mobile devices, generating realistic fluid effects and improving the user experience.
Smart Images

Figure CN121685804A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer graphics, specifically to a particle-driven fluid simulation and rendering method for mobile devices. Background Technology
[0002] Fluid simulation and rendering technology is an important research area in computer graphics, widely used in video games, film and television special effects, virtual reality, augmented reality, and engineering simulation. Fluid simulation aims to simulate the dynamic behavior of fluids such as liquids and gases through numerical calculations, while real-time rendering is responsible for presenting the simulation results with realistic visual effects. In recent years, with the improvement of mobile device performance, fluid simulation and rendering technology has gradually expanded to mobile devices, meeting the needs of mobile games, AR applications, and interactive educational software for dynamic fluid effects. However, limited by the computing power, memory bandwidth, and power consumption of mobile devices, existing technologies face many challenges in achieving efficient and realistic fluid simulation and rendering.
[0003] In fluid simulation, mainstream methods include mesh-based Eulerian methods and particle-based Lagrangian methods. Eulerian methods simulate fluids by solving the Navier-Stokes equations on a fixed mesh, making them suitable for large-scale scenarios, but their high computational complexity makes real-time implementation difficult on mobile devices. Lagrangian methods, such as Smoothed Particle Fluid Dynamics and Position-Based Fluids (PBF), express fluid behavior through particle motion and interactions. PBF, in particular, ensures incompressibility through position-constrained iteration, exhibiting strong numerical stability and making it suitable for real-time applications. Hybrid methods, such as FLIP and MPM, combine the advantages of both approaches, making them suitable for complex scenarios, but optimization is needed on mobile devices to balance efficiency and performance.
[0004] In fluid rendering, traditional methods include stereoscopic rendering, surface reconstruction, and screen-space fluid rendering, each with its own characteristics and applicable scenarios. Stereoscopic rendering simulates the optical properties (such as refraction and scattering) inside the fluid using ray tracing or volume rendering techniques to generate realistic visual effects, and is widely used in film and television special effects. However, its high computational cost makes it difficult to achieve real-time rendering on mobile devices. Surface reconstruction methods, such as the Marching Cubes algorithm, extract isosurfaces from the fluid density field to generate triangular meshes, and then combine them with lighting models for rendering. They are suitable for high-quality scenes such as scientific visualization or console games, but mesh generation and rendering are costly, resulting in low efficiency on mobile devices. Screen-space fluid rendering is a lightweight method that projects fluid particles as point sprites in screen space. It simulates realistic lighting effects through smooth blending and physically based shading models, significantly reducing computational requirements and making it suitable for real-time mobile applications such as mobile games and AR / VR. Although screen-space fluid rendering is slightly inferior to stereoscopic rendering or surface reconstruction in terms of detail, its efficiency and flexibility make it the mainstream choice for fluid rendering on mobile devices. In the future, combined with machine learning-optimized rendering pipelines and improved mobile GPU performance, it is expected to further improve rendering quality and efficiency.
[0005] The choice of graphics API is crucial to the performance of fluid simulation and rendering on mobile devices. OpenGL ES is a commonly used graphics API for mobile devices, but its high overhead and limited parallelism restrict the efficiency of complex simulation tasks. Vulkan, as a next-generation cross-platform graphics API, provides greater parallelism and performance optimization space through low-level hardware abstraction and explicit resource management. Vulkan's computation shaders support general computational tasks, making them suitable for parallel processing of particle updates and neighborhood queries in fluid simulations. Summary of the Invention
[0006] The purpose of this invention is to provide a particle-driven fluid simulation and rendering method for mobile devices, which achieves higher frame rates, lower computational overhead, and realistic rendering effects on mobile devices, and is suitable for real-time fluid simulation and interactive applications on smartphones and other mobile devices.
[0007] The technical solution to achieve the purpose of this invention is: a particle-driven fluid simulation and rendering method for mobile devices, comprising the following steps:
[0008] The first step is to initialize the dynamic properties of the fluid particles and preset the scene data.
[0009] The second step involves employing a dynamic prediction and update algorithm based on particle position, combined with position-constrained parallel iterative simulation, to realize the calculation of solid-liquid coupling.
[0010] The third step is to reduce computational overhead by leveraging shader parallel computing and mobile hardware acceleration features.
[0011] The fourth step is to adopt a mobile fluid rendering pipeline, which optimizes rendering calculations through screen-space fluid rendering and physical shading models.
[0012] The fifth step involves controlling the fluid behavior through mobile touchscreen interaction.
[0013] Furthermore, in the second step, a particle position-based dynamic prediction and update algorithm is adopted, and simulation is performed using a parallel position constraint iteration method. To address the performance limitations of mobile hardware, the algorithm is optimized to reduce the number of iterations, and a spatial grid is used to accelerate neighborhood search, thereby improving computational efficiency.
[0014] Furthermore, in the third step, Vulkan shaders are used to complete the simulation rendering task of parallel particle processing; the size of the compute shader working group is defined as follows: Its value is adapted to the number of parallel threads of the mobile GPU, and the total number of particles is The number of working groups is The simulation task includes updating particle position, velocity, and density, managing particle data through a storage buffer, and performing synchronous calculations in conjunction with semaphores.
[0015] Furthermore, the fourth step employs a mobile fluid rendering pipeline. Mobile hardware resources are significantly limited compared to PCs, so screen-space fluid rendering is improved in the rendering method. This rendering directly maps fluid particles to screen-space sprites instead of directly drawing sphere models, thus generating fluid effects quickly and efficiently. Simultaneously, a physically based shading model (PBS) is used to simulate realistic lighting, making the fluid effects more lifelike. In addition, before smoothing the fluid depth map, a 2x to 4x downsampling operation is performed on both the depth and thickness maps, greatly reducing the time overhead of image smoothing.
[0016] Furthermore, in the fifth step, fluid behavior is controlled via mobile touchscreen interaction: a light touch generates a water flow, requiring the addition of new particles to the fluid particle array, simultaneous reconstruction of the simulation and rendering pipeline, and redrawing of the water flow; switching modes and a short touch generates an external force, affecting the particles. The formula for the action of a force field is expressed as:
[0017]
[0018] in For particles External forces, Indicates the external force strength coefficient. Indicates the time step. ; Represents particles Coordinates Indicates the coordinate position of the touch point.
[0019] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described above.
[0020] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the above-described method.
[0021] A computer program product includes a computer program that, when executed by a processor, implements the above-described method.
[0022] This invention achieves efficient and realistic fluid simulation and rendering on mobile devices by combining the PBF algorithm, Vulkan shaders, screen space fluid rendering, and mobile interaction. Compared with existing technologies, the significant advantages of this invention are: (1) by utilizing Vulkan's low overhead and computational shader parallelism, the computational overhead of simulation and rendering is significantly reduced, making it suitable for real-time mobile applications; (2) the PBF algorithm ensures incompressibility and solid-liquid coupling, and combined with the PBS lighting model, generates high-quality fluid effects; (3) mobile touch interaction enhances the user experience and meets the needs of interactive application scenarios.
[0023] The present invention will now be described in further detail with reference to the accompanying drawings. Attached Figure Description
[0024] Figure 1 This is a structural diagram of the method of the present invention.
[0025] Figure 2 This is a flowchart of a fluid-structure interaction algorithm based on the PBF algorithm.
[0026] Figure 3 It is a simulation diagram of the pipeline structure.
[0027] Figure 4 This is a diagram of an SSFR structure under fluid-structure interaction.
[0028] Figure 5 These are mobile fluid rendering images in three scenarios. Scenario A simulates a dragon model composed of fluid particles falling, with 8,000 particles; Scenario B simulates the interaction between milk and cat models, with 18,000 particles; and Scenario C simulates the coupling of water and multiple models, with 22,000 particles. Detailed Implementation
[0029] Combination Figure 1 This invention proposes a particle-driven fluid simulation and rendering method for mobile devices, with the following specific steps:
[0030] The first step is to initialize the dynamic properties of the fluid particles: This refers to the position attribute of the particle. For speed attribute, , , They represent the particles in , , Velocity components in the axial direction Indicates particle radius, Indicates particle mass. This represents the initial particle density; preset scene data includes the path and position offset information pointing to the model file, as well as the camera's viewpoint and position attributes; the initial properties of rigid particles are consistent with those of fluid particles, used to simulate solid boundaries or dynamic objects, supporting solid-liquid coupling calculations. After reading the above data, a structure is used to maintain it for simulation and rendering.
[0031] The second step involves reading the relevant data and then employing a dynamic prediction and update algorithm based on particle position, using a parallel position constraint iterative method for simulation. To address the performance limitations of mobile hardware, the algorithm is optimized to reduce the number of iterations, and a spatial grid is used to accelerate neighborhood search. The core algorithm is PBF, which maintains a density constraint based on the incompressibility of particles.
[0032]
[0033] in, Represents fluid particles The number of neighboring particles (including fluid particles and rigid particles within the neighborhood). Represents particles The position vector, Represents fluid particles The density constraint ensures that during particle position iteration, the particle... Current estimated density Towards the initial density of particles Changes are made to present the motion effect of the fluid.
[0034] Set the constraint to 0. So when the particle deflects Similarly, the constraint must be zero, that is...
[0035] Perform a first-order Taylor expansion on it:
[0036]
[0037] The position offset is constrained along the direction of the constraint gradient, i.e. , For Lagrange multipliers, then Rewritten as:
[0038]
[0039] Therefore, we can conclude that:
[0040] in, Represents constraint functions For all relevant particles The sum of the squares of the gradient magnitudes, It is the Lagrange multiplier of fluid particle i; It is a very small positive number. This term is introduced to prevent the denominator from being zero, thus ensuring the numerical stability of the calculation. For Item, of which Estimation is performed using neighboring particles. It can be represented as:
[0041]
[0042] Among the particles For particles Neighboring particles, Represents particles quality It is the Poly kernel function. It is the radius of the kernel function.
[0043] Assuming all fluid particles are equal and have a value of 1, constraints are applied. Regarding particles The gradient expression is:
[0044]
[0045] The final particle position offset can be expressed as:
[0046]
[0047] However, when particles have only a few neighbors and cannot reach a rest density, especially in the boundary regions of fluids, negative pressure can cause particles to aggregate or clump together. To counteract the effects of this negative pressure, the algorithm employs an artificial pressure term. Defined as:
[0048]
[0049] in, This is the artificial pressure coefficient. It is a power series. The preset reference displacement vector is used; the artificial pressure term is incorporated into the particle position calculation, expressed as:
[0050]
[0051] Based on the above offset After updating the particle positions, the fluid simulation enters the velocity update phase. To ensure the fluid exhibits realistic physical properties (such as viscous drag) and retains detail, additional corrections are needed in the velocity update step, including viscosity correction and vorticity constraint.
[0052] The following XSPH viscosity correction is applied:
[0053]
[0054] in Represents particles Applying the viscosity-corrected speed, Speed before application The coefficient representing artificial viscosity, in the range of... , For neighboring particles With particles The relative velocity;
[0055] Following the viscosity correction steps described above, while artificial viscosity can simulate the internal friction of a fluid, it also exacerbates numerical dissipation, causing the turbulent details within the fluid to disappear too quickly. To recover these details lost due to numerical calculations and viscosity smoothing, further calculations and enhancement of the fluid's vorticity are needed. The specific steps are as follows:
[0056] First, calculate the vorticity of each particle. :
[0057]
[0058] in The curl of the velocity field is represented. Representing kernel function Regarding the position of neighboring particles The gradient;
[0059] Secondly, apply the corrective force. To amplify existing vortex motion, that is:
[0060]
[0061] in This represents the gradient vector of the vortex field (pointing to the center of the vortex). It is a small constant used to control the amplification level. Representing vectors The modulus length. The problem of fluid-structure interaction (the solid in this invention only considers rigid bodies) can be transformed from the interaction between fluid and rigid body into the interaction between fluid particles and rigid body particles from a new perspective. If the rigid body is large and complex, then to ensure performance, only one layer of rigid body particles is sampled on the surface of the rigid body.
[0062] In fluid-structure interaction problems, the estimation of fluid particle density must additionally consider the influence of rigid body particles, i.e.:
[0063] in Represents fluid particles The estimated density, Indicates the mass of a neighboring fluid particle. This represents the mass of the neighboring rigid body particle. , Assuming all fluid rigid body particles have equal mass, let [the following is a literal translation of the original text: "let ..."] Then the fluid density can also be written as:
[0064] When sampling the surface of a rigid body, due to the complexity of the body's shape, often only one layer of rigid body particles can be sampled. This can lead to insufficient density estimation by the rigid body particles below the boundary. Therefore, it is necessary to add an additional layer of virtual particles. These virtual particles are hypothetical and only appear in the calculation. The fluid density is rewritten as:
[0065]
[0066] in Represents fluid particles With virtual particles The kernel function value between them; the influence of virtual particles can also be achieved by multiplying the rigid particle by a correction factor. To approximate simplification, the formula can be further simplified to:
[0067]
[0068] in , It refers to particle volume.
[0069] at the same time, The calculation also changes, and the formula is as follows (assuming the same assumptions). For 1):
[0070]
[0071] When fluid particles and rigid body particles penetrate each other, a position correction needs to be calculated to separate them. This correction can be expressed as:
[0072]
[0073]
[0074] in and Representing fluid particles and rigid particles The required displacement correction amount. and They represent particles respectively and particles Inverse mass, Indicates from rigid body particles Pointing to fluid particles The relative position vector, This represents the distance threshold for collision detection. and Let be the radii of the fluid particle and the rigid particle, respectively. At that time, inverse mass The weighting coefficients in the formula Simplified to .
[0075] After the rigid body particle position is corrected, its rigid body shape will not be maintained, so the rigid body shape needs to be restored.
[0076] First, calculate the center of mass of the rigid body:
[0077] in As the initial centroid, The centroid at the current time point; rigid particles The initial position, This refers to the current position at the current time. Let be the total mass of the rigid body particles.
[0078] Next, calculate the covariance matrix. :
[0079]
[0080] in , .right polar decomposition The rotation matrix of the rigid body particle's motion process can then be calculated. and scaling matrix The shape restoration of rigid particles can be achieved using a rotation matrix:
[0081]
[0082] in Represents rigid body particles To restore the positional correction amount of the shape Represents rigid body particles The position vector relative to the initial centroid at the initial moment (undeformed state).
[0083] In the above fluid simulation and solid-liquid coupling analysis, considering the limitations of mobile hardware, simplifications were made in viscosity calculation and the mass of sampled particles. Figure 2 This is the algorithm flow for fluid-structure interaction.
[0084] Thirdly, to achieve real-time rendering, the computational overhead is effectively reduced by leveraging shader parallel computing and mobile hardware acceleration. During the simulation, three different computational shaders are required, one for neighborhood search, one for the fluid particle solver, and one for the rigid body particle solver. Within each computational shader, a workgroup size is defined. This represents the number of threads performing computations simultaneously (this value is 128 in mobile GPU Mali). When the number is... Among the fluid particles, a total of [number] need to be allocated. A working group was established. To meet the performance requirements of mobile devices, the maximum neighbor particle size of fluid particles was limited to 64, and the number of PBF algorithm iterations was fixed at 2 (testing showed that 2 iterations did not affect the visual effect). After all computation shaders completed their calculation tasks, all particle data was saved for use by the rendering pipeline. Specifically, the detailed execution flow of this simulation pipeline is as follows: Figure 3 As shown, within one simulation time step, the computation shader performs the calculations in the following order:
[0085] 1) External force action and prediction stage: First, update the particle's velocity and position based on the external force. Represents particles The external forces acting on the location This represents the time step of the simulation. According to the formula... Update speed and calculate predicted location. ,Right now The predicted location Used for subsequent constraint solving, not representing the final position.
[0086] 2) Neighborhood search stage: Utilizing a grid buffer to search for neighborhoods at the predicted location. The particles are subjected to a neighborhood search to determine the list of neighbors for each particle, in preparation for subsequent density calculations.
[0087] 3) Constraint solution loop: Enter the iterative solver, in the loop: (3.1) Calculate the Lagrange multipliers And solve for the position offset. (3.2) Detect collisions between particles and boundaries or rigid bodies; (3.3) Calculate the position offset of rigid body particles. It then performs a rigid body shape restoration step to ensure that the rigid body does not deform.
[0088] 4) Position and velocity update phase: After the iteration is completed, the position and velocity are updated based on the corrected predicted position. Update particle speed .
[0089] 5) Additional Corrections and Final Update: To enhance physical realism, XSPH viscosity and eddy current constraints are applied sequentially, and finally, the corrected predicted position is assigned to the actual position. This completes the simulation of this frame and initiates the rendering process.
[0090] The fourth step involves adopting a mobile fluid rendering pipeline, optimizing rendering calculations through screen-space fluid rendering and a physically based shading model. After confirming the positional information of fluid and rigid body particles in the simulation pipeline, the rendering process is as follows: First, particles are drawn one by one on the screen as "point sprites" using a fragment shader; second, the color, depth, and information output by the fragment shader are stored as color maps, depth maps, and thickness maps for post-processing operations, with downsampling performed on both maps during this stage; next, bilateral filtering or two-stage guided filtering is applied to the depth map of the fluid particles to smooth the depth and enhance the visual effect of the fluid; finally, the depth and thickness maps of the fluid are upsampled and fused with the scene color map and the processed fluid and rigid body depth and thickness maps, outputting to the exchange chain image. The improved screen-space fluid rendering structure is as follows: Figure 4 As shown. In the post-processing stage, to achieve high-quality fluid rendering effects while considering mobile performance, the physically shading model needs to be optimized for fluid characteristics, and efficient calculations are performed in conjunction with the output of screen-space fluid rendering. First, the normals of the fluid surface can be approximated using the gradient of the depth map, directly employing the one-sided difference method to reduce computational complexity. For pixels in screen space... Its depth value Then the normal at that point It can be calculated as follows: ,in This represents a vector normalization operation that ensures the normal length is 1. , Secondly, based on normal information and combined with the GGX microsurface model, the Diffuse and Specular terms for direct illumination are calculated. The Diffuse term uses the Lambert model: ,in This represents the color contribution value of the diffuse illumination term. It is the color of the light source. It is the normal line. Indicates the direction of the light source. The Specular term uses the GGX distribution function: ,in This represents the color contribution value of the specular reflection illumination term. It is the normal distribution function. It is a half vector. , Indicates the direction of the line of sight. It's the Fresnel item. This represents the geometric occlusion term; then, refraction and scattering information of the lighting is supplemented based on the depth and thickness maps; finally, the calculated fluid color, rigid body color, and scene color are merged and output to the exchange chain image to complete the rendering. The color merging formula is: ,in Indicates the transparency coefficient. This represents the final pixel color output to the screen. This represents the calculated fluid color. Indicates the background scene color. Indicates the color of a rigid body.
[0091] The fifth step involves controlling the fluid behavior through mobile touchscreen interaction. First, using Android's MotionEvent, a single finger tap on the screen triggers the generation of a new fluid. Let the screen space coordinates of the touch be... The screen space coordinates are converted into world coordinates through inverse transformation. This coordinate serves as the starting point for the generation of the new fluid. Subsequently, an initial horizontal acceleration is applied to the new fluid. and gravitational acceleration The simulation and rendering pipeline was rebuilt to present the effect of newly added fluid falling naturally. Furthermore, when fluid generation is disabled, touching the screen applies a force field to the surrounding fluid, and particles... The formula for the action of a force field can be written as: .in For particles External forces, Indicates the external force strength coefficient. For time step, , For particles Coordinates To touch the coordinate position.
[0092] This invention verifies the performance and effectiveness of a Vulkan-based efficient and realistic fluid simulation and rendering method through simulation experiments on PC and mobile platforms. The test platform included a PC (AMD Ryzen 7 5800H, NVIDIA RTX3060 Laptop, 16GB RAM, Windows 11) and a mobile device (Snapdragon 8 Gen 2, Adreno 740, 8GB RAM, Android 13); the software environment included Visual Studio 2022, Android Studio (NDK r25), Vulkan SDK 1.3.204, and ImGui (Android-compatible version); the programming languages were C++ (PC), Java (mobile), and glsl (shaders); the experimental scenarios included three different fluid scene renderings. Simulation parameters are shown in Table 1.
[0093] Table 1 Simulation Parameter Table
[0094]
[0095] A unified lighting setup (unidirectional light source, direction [0, -1, 0]) and camera parameters (default position [0, 0, 5], field of view 45°) were used. Computation and rendering were synchronized through Vulkan's pipeline barriers and semaphore mechanisms. Test data was collected using RenderDoc to capture rendering frame information (including frame rate and graphics memory allocation), supplemented by Vulkan Memory Allocator (VMA) to monitor global memory usage, in order to evaluate the method's compatibility across various hardware platforms. Rendering parameters and experimental scene performance parameters are shown in Tables 2 and 3, respectively.
[0096] Table 2 Rendering Parameters
[0097]
[0098] Table 3 Performance Parameters of Experimental Scenarios
[0099]
[0100] The fluid simulation and rendering method of this invention exhibits excellent performance and visual effects across different hardware platforms. On high-performance computing devices, the method fully utilizes hardware computing resources to achieve high frame rates for fluid simulation and rendering. On resource-constrained mobile terminals, through optimized computing strategies and rendering methods, it maintains a smooth interactive experience and low power consumption. On a PC (RTX 3060 Laptop), high frame rates are achieved in preset scenes A, B, and C, with short simulation and rendering times and low GPU memory usage, fully demonstrating the powerful computing capabilities of high-performance hardware. On a mobile device (Snapdragon 8 Gen 2), smooth frame rates are maintained in the same scenes, with reasonable simulation and rendering times and significantly optimized power consumption, demonstrating high efficiency in resource-constrained environments. Visually, both the PC and mobile devices present smooth fluid surfaces and realistic flow effects; see the visual effect images below. Figure 5 The PBS lighting model produces detailed specular and diffuse reflection effects, with rapid touch interaction response and overall satisfactory performance. The high frame rate of this method validates its feasibility and practicality in cross-platform real-time fluid simulation.
[0101] The specific embodiments of the present invention have been described in detail above. It should be noted that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various modifications or variations within the scope of the claims, which do not affect the essence of the present invention.
Claims
1. A method for mobile particle-driven fluid simulation and rendering, comprising: The method comprises the following steps: First, initialize the dynamic properties of fluid particles, and preset scene data; Second, use a dynamic prediction and update algorithm based on particle position, combined with position constraint and parallel iterative simulation to realize the calculation of solid-liquid coupling; Third, use shader parallel computing and mobile terminal hardware acceleration features to reduce the computational overhead; Fourth, use a mobile terminal fluid rendering pipeline to optimize rendering calculation through screen space fluid rendering and physical shading model; Fifth, use a mobile terminal touch screen interaction form to control fluid behavior.
2. The method of claim 1, wherein, First, initialize the kinetic properties of fluid particles: For the position attribute of the particle, For the velocity attribute, , , respectively represent the velocity components of the particle in , , axis direction, represent the particle radius, represent the particle mass, represent the initial density of the particle; preset scene data, scene data contains path and position offset information pointing to the model file, and also contains the perspective, position attribute of the camera; the initial attributes of the rigid body particles are consistent with those of the fluid particles, which are used to simulate solid boundaries or dynamic objects, and support solid-liquid coupling calculation.
3. The method of claim 1, wherein, Second, use a dynamic prediction and update algorithm based on particle position, and perform simulation through a parallel position constraint iterative method; in view of the performance limitation of a mobile terminal, the algorithm is optimized to reduce the number of iterations, and a spatial grid is used to accelerate neighborhood search; The PBF algorithm considers the incompressibility of fluid particles, and maintains a density constraint: ; wherein, represents the number of neighbor particles of a fluid particle represents the position vector of a particle represents the density constraint of a fluid particle ; the density constraint ensures that the current estimated density of a particle changes towards the initial density of the particle to present the motion effect of the fluid; Let the constraint be 0, When the particle is displaced Again, we want to ensure that the constraint is 0, i.e. ; first order Taylor expansion of: ; where the position offset is constrained along the direction of the constraint gradient, i.e. , is a Lagrange multiplier, then is rewritten as: ; The final particle position offset is expressed as: ; where represents the constraint function for all relevant particles the sum of the squared magnitude of the gradient of is the Lagrange multiplier for fluid particle i; is a small positive number introduced to prevent division by zero for term, where is estimated by neighboring particles is represented as: ; wherein the particle is a neighbor particle of the particle , denotes the mass of the particle , is the Poly kernel function, is the kernel function radius; Assuming fluid particles are equal and all 1, constraint Regarding the particle Gradient expression is: ; The viscosity correction is as follows: ; The method of adding artificial pressure is used to offset the influence of negative pressure, and the artificial pressure term is defined as: ; wherein, is an artificial pressure coefficient, is a power series, is a preset reference displacement vector; the artificial pressure term is incorporated into the particle position calculation, expressed as: ; According to the offset After the particles' positions are updated, the fluid simulation enters a velocity update phase; additional corrections are made in the velocity update step, including viscosity correction and vorticity confinement; When sampling a rigid body surface, an additional layer of virtual particles needs to be added, and the fluid density is rewritten as: ; wherein represents a particle the velocity after applying the viscosity correction, the velocity before applying, represents a coefficient of artificial viscosity, interval , is the relative velocity of the neighboring particle and the particle . calculating the vorticity of each particle : ; wherein denotes the curl of the velocity field, denotes the kernel function with respect to the position of the neighbor particle the gradient; Applying a correction force , amplifying the existing vortex motion, i.e.: ; wherein denotes the gradient vector of the vorticity field, is a constant for controlling the degree of amplification, denotes the modulus of the vector ; The estimation of the fluid particle density takes into account additionally the influence of the rigid body particles, i.e. ; where represents the mass of a fluid particle, represents the estimated density of a fluid particle, represents the mass of a neighbor fluid particle, represents the mass of a neighbor rigid particle, , Assuming all fluid-rigid particles have equal mass, let then the fluid density is written as: ; When fluid particles and rigid body particles penetrate each other, a position correction needs to be calculated to separate them, and the correction is expressed as: ; where represents the kernel value between fluid particle and virtual particle ; the effect of virtual particle is approximated by multiplying rigid particle with a correction factor , the formula is simplified as ; wherein , is the volume of the particle; The computation of the change: ; Fourth, use a mobile terminal fluid rendering pipeline; directly map fluid particles to screen space point sprites, combine a physical shading model to simulate real light, and perform 2 to 4 times downsampling operation on the fluid depth map and thickness map before performing smoothing processing on the fluid depth map. ; ; wherein and denote fluid particles and rigid body particles a displacement correction amount needed for movement, and denote the inverse mass of a particle and a particle , denotes the relative position vector from the rigid body particle to the fluid particle , denotes the distance threshold for collision detection, and are the radii of the fluid particle and the rigid body particle, respectively, and when the inverse mass , the weight factor in the formula simplifies to ; After the rigid body particle position is corrected, the rigid body shape needs to be restored; the center of mass of the rigid body is calculated: ; in As the initial centroid, The centroid at the current time point; rigid particles The initial position, This refers to the current position at the current time. The total mass of the rigid body particles; Computing a covariance matrix : ; wherein , ; the polar decomposition is performed , the rotation matrix and the scaling matrix of the rigid body particle motion are found ; the shape recovery of the rigid body particle is achieved by the rotation matrix: ; wherein represents a rigid body particle For restoring the shape, a position correction amount, represents a rigid body particle Position vector with respect to the initial center of mass at the initial time.
4. The method of claim 1, wherein, Third, the simulation rendering task of particles is completed by using Vulkan shader for parallel processing. The size of workgroup is defined by the compute shader, which is , the value of which is adapted to the number of parallel threads of mobile GPU, and the total number of particles is , the number of workgroups is . The simulation task includes the update of particle position, velocity and density. Particle data is managed by storage buffer, and synchronized calculation is performed by combining semaphore.
5. The method of claim 1, wherein, The processor executes the program to implement the steps of the method of any one of claims 1-6.
6. The method of claim 1, wherein, Step 5, mobile terminal touch screen interaction form to control fluid behavior: light screen to generate a stream of water, need to add new particles to the fluid particle array, while rebuilding simulation and rendering pipeline, redraw the water flow; switch mode and short touch screen to generate external force, particle The formula for the force field is represented as: ; wherein are particles experienced external force, denotes the external force strength coefficient, denotes the time step, ; denotes the particle coordinate position, denotes the touch coordinate position.
7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The program is executed by the processor to implement the steps of the method of any one of claims 1-6.
8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1-6.
9. A computer program product comprising a computer program, characterized in that,
Citation Information
Patent Citations
Method for drawing surface of SPH (smoothed particle hydrodynamics) fluid in real time on basis of screen spaces
CN103679802A
GPU fluid simulation method for real-time interactive application
CN115906703A
Fluid particle processing method and device, computing equipment and computer storage medium
CN118747472A
A real-time simulation and rendering method for fluid flows using particle dynamics and volume rendering techniques
KR1020050042916A