Liquid simulation method and device, medium and product

By constructing a virtual liquid surface and utilizing a spring bone model, combined with the target parameters, the problem of poor liquid simulation results in the existing technology is solved, and high-performance and highly realistic liquid simulation effects are achieved.

CN119113517APending Publication Date: 2024-12-13SHANGHAI MIHA YOUHAIYUANCHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411258109.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The existing liquid simulation technology based on AlphaClip cannot achieve highly realistic liquid effects, with poor results and low performance.

Method used

By obtaining liquid level information and container information, building a virtual liquid level, using liquid level equations and container information for liquid simulation, combining spring bone model and target parameters, accurately controlling the geometric shape and dynamic changes of the liquid level to enhance the visual effect.

Benefits of technology

While maintaining good rendering performance, create visually realistic liquid surface effects, overcome the limitations of the traditional AlphaClip method, and achieve a more realistic and attractive interactive liquid effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119113517A_ABST
    Figure CN119113517A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the field of computers, and discloses a liquid simulation method and device, a medium and a product. The method comprises the following steps: acquiring liquid level information; the liquid level information is used for representing the geometrical shape and position of the liquid level; determining a virtual liquid level according to the liquid level information and the container information; the virtual liquid level is used for representing the geometrical shape and position of the liquid surface in the container; and simulating the liquid according to the virtual liquid level. The technical problems that in the technical scheme based on AlphaClip in the related technology, the effect is generally poor, and the highly vivid liquid effect cannot be achieved can be at least solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a liquid simulation method, device, medium and product. Background Art

[0002] Interactive liquids can generate real-time feedback as players move in the game, thereby greatly enhancing the realism and immersion of the game.

[0003] In the related technology, many games have the application of interactive liquid effects. There are many technical solutions to achieve the simulation of interactive liquids, such as the technical solution based on AlphaClip and the technical solution based on particle simulation of liquids. Among them, in the technical solution based on AlphaClip, AlphaClip technology can be used to achieve the transparency and rendering effect of the liquid, thereby creating realistic liquid dynamics. In the technical solution based on particle simulation of liquids, a particle system is used to simulate the flow and interaction of the liquid, making the visual effect more flexible and controllable.

[0004] However, the inventors have found that there are at least the following technical problems in the related technology: in the technical solution based on AlphaClip, it is usually used for simple transparency and clipping effects, with relatively small calculation amount and relatively friendly performance, but the effect is generally poor and it is impossible to achieve highly realistic liquid effects. Summary of the invention

[0005] One purpose of the present application is to provide a liquid simulation method, device, medium and product, at least to solve the technical problem that the effect of the AlphaClip-based technical solution in the related art is generally poor and cannot achieve highly realistic liquid effects.

[0006] To achieve the above objectives, some embodiments of the present application provide the following aspects:

[0007] In a first aspect, some embodiments of the present application also provide a method for simulating a liquid, the method comprising: obtaining liquid level information; the liquid level information is used to characterize the geometric shape and position of the liquid surface; determining a virtual liquid surface based on the liquid level information and container information; the virtual liquid surface is used to characterize the geometric shape and position of the liquid surface in the container; and simulating the liquid based on the virtual liquid surface.

[0008] In a second aspect, some embodiments of the present application further provide an electronic device, comprising: one or more processors; and a memory storing computer program instructions, wherein the computer program instructions, when executed, cause the processor to perform the steps of the method described above.

[0009] In a third aspect, some embodiments of the present application further provide a computer-readable medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the method as described above.

[0010] In a fourth aspect, some embodiments of the present application further provide a computer program product, comprising a computer program / instruction, which implements the steps of the method described above when executed by a processor.

[0011] Compared with the related art, in the solution provided in the embodiment of the present application, by obtaining liquid level information, and determining the virtual liquid level according to the liquid level information and container information, the liquid is simulated according to the virtual liquid level. The liquid level information is used to characterize the geometric shape and position of the liquid level, and the container information is used to provide the boundary conditions that the liquid level should follow. It can be seen that in the embodiment of the present application, the technical solution based on AlphaClip (but not limited to this technical solution) can still be adopted, so that good rendering performance can be maintained, because AlphaClip is an efficient clipping technology that can reduce unnecessary rendering calculations. Different from the traditional technical solution of using AlphaClip to simulate interactive liquids, in the embodiment of the present application, a virtual liquid level is constructed using the liquid level equation and container information. Among them, the liquid level equation is used to determine the geometric shape and position of the liquid level, and the container information is used to provide the boundary conditions that the liquid level should follow. This method can create a visually realistic liquid level effect without sacrificing performance, thereby overcoming the limitations of the traditional AlphaClip method and achieving a more realistic and attractive interactive liquid effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0013] Figure 1 An exemplary flow chart of a liquid simulation method provided according to some embodiments of the present application;

[0014] Figure 2 An exemplary flow chart of a method for constructing a liquid surface equation in a liquid simulation method provided according to some embodiments of the present application;

[0015] Figure 3 An exemplary schematic diagram of determining the coordinate position of a virtual liquid surface according to the ray equation and the liquid surface equation in a liquid simulation method provided according to some embodiments of the present application;

[0016] Figure 4 This is an exemplary schematic diagram of a foam effect with a strong three-dimensional sense achieved in a liquid simulation method provided according to some embodiments of the present application;

[0017] Figure 5 A comparative schematic diagram of the fusion normal line in a liquid simulation method provided according to some embodiments of the present application;

[0018] Figure 6 An exemplary schematic diagram of adding additional highlights at the connection position in a liquid simulation method provided according to some embodiments of the present application;

[0019] Figure 7 and Figure 8 This is an exemplary schematic diagram of the contrast effect before and after processing a connection position in a liquid simulation method provided according to some embodiments of the present application;

[0020] Fig. 9 This is an exemplary structural diagram of an electronic device provided according to some embodiments of the present application. Specific embodiments

[0021] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0022] The following terms are used in this article.

[0023] AlphaClip: is a technology used in graphics rendering, especially in the Unity engine, which allows developers to control the rendering process through specific material properties and achieve complex visual effects.

[0024] Shader: A program used to calculate rendering effects, mainly executed on the GPU.

[0025] Small scale: This means that this solution is suitable for small-scale liquid environments such as liquid in wine bottles and liquid in buckets, but not for large-scale liquid environments such as ponds and lakes.

[0026] Interactive liquid: refers to liquid in the game that can produce real-time feedback following the player's actions. For example, when a player shakes a bottle of wine, the liquid in the bottle will simulate physical phenomena in the real world, such as inertia, gravity, and surface tension, producing effects such as shaking and splashing. The liquid in the embodiments of this application mainly refers to interactive liquid.

[0027] Draw Call: refers to the rendering command sent by the CPU to the GPU to draw a group of graphic objects, such as triangles. Draw Call contains instructions such as setting the rendering state and submitting rendering commands.

[0028] GPU Instance: is an efficient rendering technology that allows developers to render multiple instances through one Draw Call. Each instance is defined by only a small amount of vertex and index data, which significantly reduces the number of rendering commands and the communication overhead from CPU to GPU.

[0029] First embodiment

[0030] The first embodiment of the present application relates to a method for simulating a liquid. Figure 1 As shown, the method may include the following steps:

[0031] Step S101, obtaining liquid level information; the liquid level information is used to characterize the geometric shape and position of the liquid level;

[0032] Step S102, determining a virtual liquid surface according to the liquid surface information and container information; the container information is used to provide boundary conditions of the liquid surface;

[0033] Step S103: simulating the liquid according to the virtual liquid surface.

[0034] The following is a detailed description of each of the above steps.

[0035] Regarding step S101, specifically, in some examples, the liquid surface is the surface where two different media, liquid and air, intersect, and correspondingly, the liquid surface information is the relevant information of the surface where two different media, liquid and air, intersect; the liquid surface can be regarded as a constantly changing three-dimensional plane. The liquid can be, but is not limited to, water, wine, etc., and this embodiment of the application does not specifically limit this.

[0036] With respect to step S102, specifically, in some examples, the liquid is in the container, and the container is a physical space for holding the liquid, and the container can have various shapes and sizes. Exemplarily, the container can be, but is not limited to, a columnar water glass, a goblet, a conical wine glass, etc., which is not specifically limited in the embodiments of the present application. The container information can be information used to characterize the interior of the container, which is not specifically limited in the embodiments of the present application. It should be noted that the virtual liquid surface does not refer to an actual physical surface, but is simulated in a computer using the liquid surface information, and is used to characterize the geometric shape and position of the liquid surface in the container.

[0037] Regarding step S103, specifically, in some examples, the liquid is simulated according to the virtual liquid surface, which may be a dynamic simulation of the liquid when the user shakes the container.

[0038] It is not difficult to find that, compared with the related art, in the solution provided in the embodiment of the present application, by obtaining liquid level information, and determining the virtual liquid level according to the liquid level information and container information, the liquid is simulated according to the virtual liquid level. The liquid level information is used to characterize the geometric shape and position of the liquid level, and the container information is used to provide the boundary conditions that the liquid level should follow. It can be seen that in the embodiment of the present application, the technical solution based on AlphaClip (but not limited to this technical solution) can still be adopted, so that good rendering performance can be maintained, because AlphaClip is an efficient clipping technology that can reduce unnecessary rendering calculations. Different from the traditional technical solution of using AlphaClip to simulate interactive liquids, in the embodiment of the present application, a virtual liquid level is constructed using the liquid level equation and container information. Among them, the liquid level equation is used to determine the geometric shape and position of the liquid level, and the container information is used to provide the boundary conditions that the liquid level should follow. This method can create a visually realistic liquid level effect without sacrificing performance, thereby overcoming the limitations of the traditional AlphaClip method and achieving a more realistic and attractive interactive liquid effect.

[0039] Second embodiment

[0040] The second embodiment of the present application relates to a method for simulating liquid. The second embodiment is an improvement on the first embodiment, and the specific improvement is: in the second embodiment of the present application, a method for constructing the liquid surface equation is provided.

[0041] Optionally, in some embodiments, the obtaining of the liquid level information may include: constructing a three-dimensional plane equation according to the liquid level information to obtain the liquid level equation; correspondingly, the determining of the virtual liquid level according to the liquid level information and the container information is specifically: determining the virtual liquid level according to the liquid level equation and the container information. That is, in some embodiments, the liquid level equation may be obtained by constructing a three-dimensional plane equation according to the liquid level information. The liquid level equation may be used to define the basic form of the liquid level.

[0042] Specifically, in some embodiments, the method for constructing the liquid level equation may further include the following steps: Figure 2 As shown:

[0043] Step S201, obtaining the starting point and end point of the spring skeleton model;

[0044] Step S202, simulating the spring force of the liquid when it is shaking according to the starting point and the end point, and determining the end point posture of the spring skeleton model according to the spring force;

[0045] Step S203, determining the liquid surface equation according to the endpoint posture.

[0046] Exemplarily, in an embodiment of the present application, the dynamic behavior of the liquid is abstracted into a spring skeleton model, and the liquid surface equation is determined according to the spring skeleton model. The spring skeleton model is a model composed of multiple continuous skeletons, wherein each skeleton can rotate or move relative to adjacent elements, similar to the extension and compression characteristics of a spring. The starting point can be the fixed end of the spring skeleton model, and the fixed end corresponds to a skeleton with an initial position and attributes. Opposite to the starting point, the end point can be the free end of the spring skeleton model.

[0047] Optionally, in some embodiments, the step of obtaining the starting point and the end point of the spring skeleton model, i.e., step S201, may further include the following steps:

[0048] Step S2011, obtaining the starting point of the spring skeleton model according to the center of mass position of the liquid;

[0049] Step S2012, obtaining the end point of the spring skeleton model according to the liquid level position of the liquid.

[0050] Exemplarily, the center of mass position of the liquid can be abstracted as the starting point of a spring skeleton. The center of mass position of the liquid can also be understood as the center of gravity position of the liquid, and the center of mass position is used to characterize the equilibrium point of the mass distribution of the liquid. In this way, that is to say, the starting point of the spring skeleton model corresponds to the center of mass position of the liquid.

[0051] Exemplarily, the liquid surface position of the liquid can be abstracted as the end point of a spring skeleton, so that the dynamic change of the liquid surface can be simulated by the extension or compression of the spring.

[0052] Optionally, in some embodiments, the spring force of the liquid when shaking is simulated according to the starting point and the end point, and the end point posture of the spring skeleton model is determined according to the spring force, that is, step S202 may further include the following steps:

[0053] Step S2021, obtaining the elastic coefficient, damping value and acceleration of the spring skeleton model;

[0054] Step S2022, simulating the spring force of the liquid when it is shaking according to the starting point and the end point, as well as the elastic coefficient, the damping value and the acceleration, and determining the end point posture of the spring skeleton model according to the spring force.

[0055] Exemplarily, when the liquid is shaken, the force applied to the spring can be simulated according to the elastic coefficient, damping value and acceleration of the spring. The elastic coefficient is used to describe the parameters of the spring elasticity in the spring skeleton model. In Hooke's law, the elastic force applied to the spring is proportional to the length of the spring extension or compression. The damping value is used to determine the resistance applied to the spring skeleton model during movement, which is usually proportional to the speed of the spring. The acceleration is used to determine the acceleration of the spring due to the action of an external force, wherein the external force is the force applied to the spring system by an external object, such as the force applied to the liquid by a player shaking a wine glass. It can be understood that the resultant force applied to an object is equal to the product of the mass of the object and the acceleration. Here, the acceleration is the result of the combined action of external force, elastic force, damping force and gravity.

[0056] For example, the spring force simulating the shaking of the liquid can be determined by the following simplified mechanical formula, where the spring force is the resultant force. The following formula describes that under given acceleration, velocity and gravity conditions, the resultant force on the liquid is the vector sum of all individual forces:

[0057] F = F1 + F2 + F3;

[0058] Among them, F represents the resultant force finally exerted on the spring skeleton model; F1 represents the external force; F2 represents the resistance exerted on the spring skeleton model; F3 represents the gravity exerted on the spring skeleton model; it can be understood that gravity can be continuously applied to the spring skeleton model, and the spring skeleton model will eventually tend to stabilize under the dual effects of the gravity and resistance.

[0059] Exemplarily, the endpoint posture may specifically be the posture of the endpoint of the spring skeleton model in three-dimensional space, and the endpoint posture may include the endpoint position and quaternion of the spring skeleton model; furthermore, the liquid surface equation may be constructed according to the endpoint posture.

[0060] Exemplarily, the end point position corresponds to the coordinates (x0, y0, z0) of the end point of the spring skeleton model in three-dimensional space; the quaternion is used to represent the rotation of the spring skeleton model in three-dimensional space, and the orientation of the spring skeleton model, that is, the normal vector (A, B, C) of the plane can be determined according to the quaternion. Among them, the quaternion can be first converted into a rotation matrix, and then the rotation matrix is ​​applied to a certain vector (such as a unit vector) to obtain the normal vector (A, B, C) of the plane.

[0061] Exemplarily, the liquid surface equation can be constructed using the point method according to the endpoint posture. In the embodiment of the present application, the liquid surface equation can provide a mathematical basis for rendering the liquid surface, ensuring that the rendered virtual liquid surface can dynamically change according to physical simulation and art parameters.

[0062] Exemplarily, the liquid level equation can be expressed as:

[0063] A(x-x0)+B(y-y0)+C(z-z0)=0

[0064] Among them, (A, B, C) is the orientation of the spring skeleton model calculated using the quaternion, that is, the normal vector of the plane, which is perpendicular to the plane; (x0, y0, z0) is the end point position, which is the coordinates of a known point on the plane. (x-x0), (y-y0) and (z-z0) on the left side of the equation are the distance differences from the point (x, y, z) on any plane to the known point (x0, y0, z0) in the x, y and z directions respectively. The liquid surface equation is used to describe the set of all points on the plane that satisfy the A, B, C directions and pass through the point (x0, y0, z0).

[0065] Furthermore, the above liquid level equation can be organized into a standard form, as shown below:

[0066] Ax+By+Cz+D=0;

[0067] Among them, (A, B, C) is the normal vector of the plane, and D is a constant, which is a constant calculated from the point on the plane and the normal vector, and represents the distance between the plane and the normal vector.

[0068] For example, D can be calculated by replacing x, y, z with x0, y0, z0:

[0069] D=-Ax0-By0-Cz0.

[0070] It is not difficult to find that in the embodiment of the present application, by obtaining the starting point and end point of the spring skeleton model, simulating the spring force of the liquid when shaking according to the starting point and end point, and determining the end point posture of the spring skeleton model according to the spring force, and then determining the liquid surface equation according to the end point posture, a method for constructing the liquid surface equation is provided. In this way, the end point posture of the liquid surface can be accurately controlled through the spring skeleton model; the liquid surface equation is constructed by combining the methods of physical simulation and art control, which is conducive to ensuring the accuracy of the liquid surface equation. Furthermore, during real-time interaction, a simplified spring model can also be used to calculate the direction of movement of the liquid and add noise disturbances. In this way, small fluctuations and ripples in the liquid can be simulated, making the movement of the liquid richer and more realistic.

[0071] Third embodiment

[0072] The third embodiment of the present application relates to a method for simulating liquid. The third embodiment is an improvement on the second embodiment, and the specific improvement is that: in the second embodiment, some basic parameters such as elastic coefficient, damping value and acceleration are used to simulate the spring force of the liquid when it is shaking; while in the third embodiment of the present application, other factors are also considered, and some additional target parameters are provided to simulate the spring force of the liquid when it is shaking and determine the terminal posture of the spring skeleton model, so that it is convenient to adjust and control the artistic visual effect of the liquid surface.

[0073] Specifically, in some embodiments, the spring force of the liquid when shaking is simulated according to the starting point and the end point, as well as the elastic coefficient, the damping value and the acceleration, and the end point posture of the spring skeleton model is determined according to the spring force, that is, step S2022 may further include the following steps:

[0074] Step S20221, obtaining target parameters, wherein the target parameters include at least one of the following: a first weight value for characterizing the offset of the spring skeleton model, a second weight value for characterizing the rotation of the spring skeleton model, and a speed value for characterizing the recovery of the spring skeleton model;

[0075] Step S20222, in combination with the target parameters, simulate the spring force of the liquid when it is shaking according to the starting point and end point, as well as the elastic coefficient, damping value and acceleration, and determine the end point posture of the spring skeleton model according to the spring force.

[0076] Exemplarily, the first weight value used to characterize the offset of the spring skeleton model is used to adjust the initial offset of the spring skeleton model in a static or moving state, affecting the initial shape and starting point of the movement of the spring skeleton model. During specific calculations, the natural length or static position of the spring skeleton model can be adjusted according to the first weight value to achieve fine-tuning of the liquid level.

[0077] Exemplarily, the second weight value used to characterize the rotation of the spring skeleton model is used to control the rotation force or angle change of the spring skeleton segment, affecting the bending and torsion effect of the spring skeleton model. During calculation, the rotation angle or rotation speed of the spring skeleton segment can be adjusted according to the second weight value to simulate the fluctuation and distortion of the liquid surface;

[0078] Exemplarily, the speed value used to characterize the recovery of the spring skeleton model is used to control the speed at which the spring returns to the equilibrium position, affecting the dynamic response of the spring skeleton model. In the simulation, the deformation recovery process of the spring skeleton model can be calculated based on the speed value, thereby affecting the naturalness of the liquid surface dynamics.

[0079] Exemplarily, the terminal posture of the spring skeleton model can be determined by physical simulation and mathematical calculation in combination with the target parameters. For example, the initial length or position of the spring skeleton model can be adjusted according to the first weight value first; then the rotation angle of the spring segment can be adjusted according to the second weight value, and then the acceleration and speed of the spring skeleton model can be calculated using Newton's second law in combination with the elastic coefficient, damping value and acceleration. Finally, the deformation recovery process of the spring skeleton model is adjusted according to the speed value used to characterize the recovery of the spring skeleton model. Finally, the terminal posture of the spring skeleton model is obtained.

[0080] It should be noted that the third embodiment of the present application may also be an improvement based on the first embodiment.

[0081] It is not difficult to find that in the embodiment of the present application, by obtaining the target parameters, the target parameters include at least one of the following: a first weight value for characterizing the offset of the spring skeleton model, a second weight value for characterizing the rotation of the spring skeleton model, and a speed value for characterizing the recovery of the spring skeleton model, and in combination with the target parameters, the spring force of the liquid when it is shaking is simulated according to the starting point and the end point, as well as the elastic coefficient, the damping value and the acceleration, and the terminal posture of the spring skeleton model is determined according to the spring force. It is provided to combine some additional target parameters, and by considering other factors, to simulate the spring force of the liquid when it is shaking and determine the terminal posture of the spring skeleton model, so as to facilitate the adjustment and control of the artistic visual effect of the liquid surface.

[0082] Fourth embodiment

[0083] The fourth embodiment of the present application relates to a liquid simulation method. The fourth embodiment is an improvement on the second embodiment, and the specific improvement is: in the fourth embodiment of the present application, a specific implementation method for determining a virtual liquid level according to the liquid level information and container information is provided.

[0084] Specifically, in some embodiments, the step of determining the virtual liquid level according to the liquid level information and the container information, that is, step S102, may further include the following steps:

[0085] Step S1021, obtaining a ray equation from the coordinates of the inner wall of the container to the camera; wherein the coordinates of the inner wall of the container are used to represent the coordinates of the bottom of the liquid surface based on the inner wall of the container;

[0086] Step S1022, determining the coordinate position of the virtual liquid surface according to the ray equation and the liquid surface equation;

[0087] Step S1023, determining the virtual liquid surface according to the coordinate position of the virtual liquid surface.

[0088] That is to say, the intersection point of the ray emitted from the inner wall coordinates of the container and the liquid surface equation can be found to determine the coordinate position of the virtual liquid surface. Figure 3 The intersection points 3 and 4 in the figure represent the boundaries where the liquid surface intersects with the inner wall of the container.

[0089] Exemplarily, the surface of the virtual liquid may be rendered according to the coordinate position of the pseudo-liquid surface to make the virtual liquid more realistic.

[0090] Optionally, in some embodiments, the step of obtaining the ray equation between the coordinates of the inner wall of the container and the camera, i.e., step S1021, may further include the following steps:

[0091] Step S10211, obtaining coordinate data of a point on the ray, a normalized direction vector representing the ray, and parameter information used to represent the distance of the coordinates of the inner wall of the container along the ray direction;

[0092] Step S10212: Obtain the ray equation between the coordinates of the inner wall of the container and the camera according to the coordinate data, the normalized direction vector and the parameter information.

[0093] For example, the ray equation between the coordinates of the inner wall of the container and the camera can be as follows:

[0094] x=x1+t×m;

[0095] y=y1+t×n;

[0096] z=z1+t×p;

[0097] Among them, (x1, y1, z1) are the coordinates of a known point on the ray (such as the coordinates of the inner wall of the container), (m, n, p) are the normalized direction vector of the ray, and t is a parameter representing the distance from the point (x1, y1, z1) along the ray direction.

[0098] Optionally, in some embodiments, the determining the coordinate position of the virtual liquid surface according to the ray equation and the liquid surface equation, that is, step S1022, may further include the following steps:

[0099] Step S10221, determining the intersection coordinates according to the ray equation and the liquid surface equation;

[0100] Step S10222, determining the coordinate position of the virtual liquid surface according to the intersection coordinates.

[0101] According to the second embodiment, the liquid level equation can be expressed by the following formula:

[0102] A(x-x0)+B(y-y0)+C(z-z0)=-D;

[0103] Among them, (x0, y0, z0) represents the coordinate data of a point on the ray, such as the end point position, which is the coordinate of a known point on the plane, (A, B, C) is the normal vector of the plane, and D is a constant, which is a constant calculated from the point on the plane and the normal vector, and represents the distance between the plane and the normal vector.

[0104] Furthermore, substituting the ray equation into the liquid surface equation, we can obtain:

[0105] A(x1+t×m-x0)+B(y1+t×n-y0)+C(z1+t×p-z0)=-D;

[0106] Further arrangement, we can get the equation about t:

[0107] A(m)t+B(n)t+C(p)t+(Ax1+By1+Cz1-Ax0-By0-Cz0+D)=0;

[0108] This can be simplified to:

[0109] (Am+Bn+Cp)t+(Ax1+By1+Cz1-Ax0-By0-Cz0+D)=0;

[0110] So, if Am+Bn+Cp≠0, we can solve for t:

[0111]

[0112] After obtaining the value of t, the t can be substituted back into the ray equation to obtain the coordinates of the intersection point:

[0113] x 交点 =x1+t×m;

[0114] y 交点 =y1+t×n;

[0115] z 交点 =z1+t×p

[0116] At this point, the intersection coordinates are obtained, which are the coordinate positions of the virtual liquid surface. Further, the virtual liquid surface can be determined according to the coordinate positions of the virtual liquid surface. Determining the coordinate positions of the virtual liquid surface helps to simulate the connection between the liquid and the inner wall of the container in the determined virtual liquid surface, thereby increasing the details of the visual effect.

[0117] It should be noted that if Am+Bn+Cp=0, it means that the ray is parallel to the liquid surface and there is no intersection between them. In practical applications, it is also possible to check whether the value of t is within a reasonable range to ensure that the intersection coordinates are within the visible range of the scene.

[0118] It should be noted that the third embodiment of the present application may also be an improvement based on the first embodiment and / or the second embodiment.

[0119] It is not difficult to find that in the embodiment of the present application, by obtaining the ray equation between the coordinates of the inner wall of the container and the camera; wherein the coordinates of the inner wall of the container are used to characterize the bottom of the liquid surface based on the coordinates of the inner wall of the container, the coordinate position of the virtual liquid surface is determined according to the ray equation and the liquid surface equation, and the virtual liquid surface is determined according to the coordinate position of the virtual liquid surface, a specific implementation method for determining the virtual liquid surface according to the liquid surface information and the container information is provided. In this way, a virtual liquid surface with a more realistic liquid effect can be obtained.

[0120] Fifth embodiment

[0121] The fifth embodiment of the present application relates to a liquid simulation method. The fifth embodiment is an improvement based on the fourth embodiment, and the specific improvement is: in the fifth embodiment of the present application, a specific implementation method for determining the intersection coordinates according to the ray equation and the liquid surface equation is provided.

[0122] Specifically, in some embodiments, the determining the intersection coordinates according to the ray equation and the liquid surface equation, that is, step S10221, may further include the following steps:

[0123] Step S102211, obtaining the coordinates of the inner wall of the first container above the liquid surface and the coordinates of the inner wall of the second container below the liquid surface;

[0124] Step S102212, determining the coordinates of the first intersection point according to the coordinates of the inner wall of the first container and the liquid surface equation;

[0125] Step S102213, determining the coordinates of the second intersection point according to the coordinates of the inner wall of the second container, the ray equation and the liquid surface equation;

[0126] Correspondingly, the coordinate position of the virtual liquid surface is determined according to the intersection coordinates as follows:

[0127] The coordinate position of the virtual liquid surface is determined according to the first intersection coordinate and the second intersection coordinate. That is, the sum of the first intersection coordinate and the second intersection coordinate is the coordinate position of the virtual liquid surface.

[0128] Optionally, in some embodiments, determining the coordinates of the first intersection point according to the coordinates of the inner wall of the first container and the liquid surface equation, that is, step S102212, may further include the following steps:

[0129] Step S1022121, mirroring the inner wall coordinates of the first container using the liquid surface equation to determine a virtual reflection point;

[0130] Step S1022122, constructing an oblique vector of a preset angle according to the virtual reflection point;

[0131] Step S1022123, determine the coordinates of the first intersection point according to the oblique vector and the liquid surface equation.

[0132] It should be noted that, considering that the vector from the coordinates of the inner wall of the first container above the liquid surface to the camera may not have any intersection with the liquid surface equation, in the embodiment of the present application, a special intersection method is used for the coordinate position above the liquid surface equation. Specifically, the virtual reflection point is determined by mirroring the coordinates of the inner wall of the first container through the liquid surface equation, and based on the virtual reflection point, an oblique vector of a preset angle is constructed to replace the ray. The oblique vector is used together with the virtual reflection point to intersect with the liquid surface equation to determine the coordinates of the first intersection. In this way, the coordinate position of the virtual liquid surface above the liquid surface can be determined, which is conducive to further processing the connection position between the inner wall of the container and the liquid.

[0133] For example, the preset angle may be, but is not limited to, 45 degrees, which is not specifically limited in the present embodiment of the application.

[0134] It should be noted that the fifth embodiment of the present application may also be an improvement based on any one or more of the first to third embodiments.

[0135] It is not difficult to find that in the embodiment of the present application, by obtaining the coordinates of the inner wall of the first container above the liquid surface and the coordinates of the inner wall of the second container below the liquid surface; determining the coordinates of the first intersection point according to the coordinates of the inner wall of the first container and the liquid surface equation, and determining the coordinates of the second intersection point according to the coordinates of the inner wall of the second container, the ray equation and the liquid surface equation, a specific implementation method for determining the coordinates of the intersection point according to the ray equation and the liquid surface equation is provided.

[0136] Sixth embodiment

[0137] The sixth embodiment of the present application relates to a liquid simulation method. The sixth embodiment is an improvement on the fourth embodiment, and the specific improvement is: in the sixth embodiment of the present application, a specific implementation method for determining the virtual liquid surface according to the coordinate position of the virtual liquid surface is provided.

[0138] Specifically, in some embodiments, the step of determining the virtual liquid surface according to the coordinate position of the virtual liquid surface, that is, step S1023, may further include the following steps:

[0139] Step S10231, determining the target two-dimensional coordinates according to the coordinate position of the virtual liquid surface;

[0140] Step S10232, determining the two-dimensional texture coordinates according to the target two-dimensional coordinates;

[0141] Step S10233, sampling is performed according to the two-dimensional texture coordinates to determine the virtual liquid surface.

[0142] For example, each three-dimensional coordinate (assuming X, Y, Z) of the liquid surface can be projected onto a two-dimensional plane, retaining only the X and Z coordinates and ignoring the Y coordinate. In this way, each point of the liquid surface can be represented by a two-dimensional coordinate (x, z), which is the target two-dimensional coordinate.

[0143] Exemplarily, after obtaining the target two-dimensional coordinates, the target two-dimensional coordinates can be linearly mapped to map to the texture space to obtain two-dimensional texture coordinates. It can be understood that the texture can be represented by UV, the texture space can be represented by UV space, and the two-dimensional texture coordinates can be represented by two-dimensional UV coordinates. Among them, the UV space can be a standardized coordinate system from (0,0) to (1,1), and the standardized coordinate system corresponds to the lower left corner to the upper right corner of the texture map. The mapping can be completed by the following linear transformation:

[0144]

[0145] Wherein, W and H are the width and height of the texture image respectively, and (u, v) represents the two-dimensional texture coordinates.

[0146] Furthermore, the two-dimensional texture coordinates can be used to sample the corresponding texture map to obtain more texture information; by sampling different texture maps, different display effects can be obtained. Exemplarily, the texture map can be a noise texture, a normal texture, or other types of images, which are not specifically limited in the embodiments of the present application. By sampling according to the two-dimensional texture coordinates, the color, height, or normal information of each coordinate point of the liquid surface can be obtained, thereby determining the virtual liquid surface.

[0147] If a noise texture is used, the height value obtained by sampling can be used to offset the height of the virtual liquid surface, thereby creating an undulating effect on the virtual liquid surface. If a normal texture is used, the effect of light on the virtual liquid surface can be calculated based on the normal information obtained by sampling, and a shader can be used to simulate how light interacts with the liquid surface, adding an undulating light and shadow effect to the liquid surface.

[0148] It should be noted that the sixth embodiment of the present application may also be an improvement based on any one or more of the first to third embodiments and the fifth embodiment.

[0149] It is not difficult to find that in the embodiment of the present application, the target two-dimensional coordinates are determined according to the coordinate position of the virtual liquid surface, the two-dimensional texture coordinates are determined according to the target two-dimensional coordinates, and the virtual liquid surface is determined by sampling according to the two-dimensional texture coordinates. A specific implementation method for determining the virtual liquid surface according to the coordinate position of the virtual liquid surface is provided. In this way, the coordinate position of the virtual liquid surface can be effectively converted into two-dimensional texture coordinates, and the texture mapping technology can be used to enhance the visual effect, so that the virtual liquid surface can be made more realistic and rich.

[0150] Seventh embodiment

[0151] The seventh embodiment of the present application relates to a liquid simulation method. The seventh embodiment is an improvement based on the sixth embodiment, and the specific improvement is: in the seventh embodiment of the present application, a specific implementation method for determining the virtual liquid surface by sampling according to the two-dimensional texture coordinates is provided.

[0152] Specifically, in some embodiments, the sampling according to the two-dimensional texture coordinates to determine the virtual liquid surface, that is, step S10233, may further include the following steps:

[0153] Step S102331, determining a mask according to the surface of the liquid and the center of mass of the liquid;

[0154] Step S102332, determining a virtual liquid surface according to the two-dimensional texture coordinates and the mask; wherein the virtual liquid surface presents a three-dimensional foam effect.

[0155] Exemplarily, the mask can be determined according to the position of the liquid surface from the center of mass of the liquid; wherein the mask is an image processing technology used to control the visible area of ​​the effect. In the embodiment of the present application, by using the distance from the surface of the liquid to the center of mass of the liquid as the mask, the foam effect can be mainly concentrated in the area of ​​the liquid surface away from the center of mass. In this way, the simulated foam effect can present a natural phenomenon of uneven distribution on the surface of the liquid. It can be understood that the liquid around the center of mass is usually calmer, while the edge area away from the center of mass is more likely to form foam.

[0156] Exemplarily, in the process of determining the virtual liquid surface according to the two-dimensional texture coordinates, noise can be added to the mask, so that the virtual liquid surface can present a three-dimensional foam effect. The noise is used to characterize random texture or height changes. In this way, by adding noise, the randomness and naturalness of the foam can be further enhanced, making the foam effect more realistic. According to actual needs, the noise can be static or dynamically changing; if the noise is dynamically changing, it can be used to simulate the change of the foam effect over time and the dynamic characteristics of the liquid. See Figure 4 , which is an exemplary schematic diagram of a foam effect with a strong three-dimensional sense achieved according to the technical solution provided in an embodiment of the present application.

[0157] It should be noted that the seventh embodiment of the present application may also be an improvement based on any one or more embodiments from the first embodiment to the fifth embodiment.

[0158] It is not difficult to find that in the embodiment of the present application, a mask is determined according to the surface of the liquid and the center of mass of the liquid; a virtual liquid surface is determined according to the two-dimensional texture coordinates and the mask; wherein the virtual liquid surface presents a three-dimensional foam effect, and a specific implementation method for determining the virtual liquid surface by sampling according to the two-dimensional texture coordinates is provided. It can be understood that the foam effect is a common phenomenon on the surface of virtual liquids, especially when the virtual liquid is stirred or shaken. Through the method provided in the embodiment of the present application, a more realistic foam effect can be produced, the dynamic and three-dimensional sense of the virtual liquid surface can be enhanced, and the overall visual experience can be improved, especially when observed at a close distance or rendered at high resolution.

[0159] Eighth embodiment

[0160] The eighth embodiment of the present application relates to a method for simulating a liquid. The eighth embodiment is an improvement on the first embodiment, and the specific improvement is that: in the eighth embodiment of the present application, a specific implementation method for simulating the liquid according to the virtual liquid surface is provided. In this implementation method, the focus is on the processing of the connection position between the liquid and the inner wall of the container, which is often ignored in the related art.

[0161] Specifically, in some embodiments, the liquid is simulated according to the virtual liquid surface, that is, step S103 may further include the following steps:

[0162] Step S1031, determining the connection position between the liquid and the inner wall of the container according to the virtual liquid surface;

[0163] Step S1032, simulating the liquid according to the connection position.

[0164] Optionally, in some embodiments, the liquid is simulated according to the connection position, that is, step S1032 may further include the following steps:

[0165] Step S10321, obtaining a liquid surface normal and a container inner wall normal; wherein the liquid surface normal is used to characterize a vector of the liquid surface orientation, and the container inner wall normal is used to characterize a vector of the container inner wall surface;

[0166] Step S10322, determining a fusion normal line according to the liquid surface normal line and the container inner wall normal line; the fusion normal line is an arc;

[0167] Step S10323, simulating the liquid according to the fusion normal.

[0168] For example, when simulating liquid, the liquid surface normal is different for each point on the liquid surface to simulate the fluctuation of the water surface. By creating an arc-shaped fusion normal, it is helpful to simulate the natural transition of the contact position between the liquid and the inner wall of the container in the real world.

[0169] Optionally, in some embodiments, the determining of the fusion normal according to the liquid surface normal and the container inner wall normal, that is, step S10322, may further include the following steps:

[0170] Step S103221, obtaining interpolation parameters; wherein the interpolation parameters are determined according to the inner wall of the container;

[0171] Step S103222, interpolate the liquid surface normal and the container inner wall normal according to the interpolation parameters to determine a fused normal.

[0172] Exemplarily, the boundary where the liquid contacts the inner wall of the container can be determined based on the area on the inner wall of the container, and the connection position can be obtained, and the connection position and the liquid surface normal can be merged. Then, an interpolation parameter e from 0 to 1 can be used, where 0 represents the normal of the inner wall of the container and 1 represents the normal of the liquid surface. The interpolation parameter e can be changed according to the position along the inner wall of the container to achieve a smooth transition.

[0173] Exemplarily, according to the interpolation parameter e, the liquid surface normal and the container inner wall normal are interpolated to determine the fused normal, which can be referred to the following formula:

[0174] Fusion normal = (1-e) × container inner wall normal + e × liquid surface normal;

[0175] In the above formula, the container inner wall normal and the liquid surface normal are mixed according to the value of the interpolation parameter e. As e changes from 0 to 1, the fused normal will also smoothly transition from the container inner wall normal to the liquid surface normal. It can be understood that by changing the interpolation parameter e at different positions along the inner wall of the container, a continuous normal change interval can be created on the inner wall of the container, thereby achieving a smooth transition, which helps to simulate the visual effect of the liquid rising or falling along the inner wall of the container. In other words, in the end, through the interpolation method, a curved fused normal can be created, which visually simulates the change in curvature at the contact point between the liquid and the inner wall of the container.

[0176] Optionally, in some embodiments, simulating the liquid according to the fused normal may further include: sampling a reflection map according to the fused normal, and calculating a lighting effect to simulate the liquid. The lighting effect may be calculated using, but not limited to, a BRDF bidirectional reflectance distribution function, which is not specifically limited in the present embodiment of the application.

[0177] See also Figure 5 , which shows a comparison diagram of the fused normal. It can be seen that without interpolation, the liquid surface normal and the container inner wall normal may be completely different, which will cause visual unnaturalness. By interpolating the fused normal, a gradient effect can be created, making the transition between the liquid surface and the container inner wall smoother.

[0178] It should be noted that due to the effect of surface tension, the surface of a small-scale liquid will not be completely horizontal at the edge, but will be warped upward. Among them, surface tension is the mutual attraction between liquid molecules, which makes the liquid surface as small as possible, resulting in a curved or convex effect at the edge. In many games, due to performance and resource limitations, such tiny details caused by the surface tension of the liquid are generally not restored. However, such details are very important for improving the sense of reality. In the embodiment of the present application, considering that the small-scale liquid may have a close-up viewing angle in the game, the details of the junction between the liquid and the cup wall are processed more finely, so that the interaction between the liquid and the inner wall of the container can be better reflected, which can not only enhance the sense of reality of the liquid. It can also significantly enhance the artistic expression of the liquid effect. In short, in the embodiment of the present application, by specially treating the contact area between the liquid surface and the inner wall of the container, the tension characteristics of the liquid on the surface of the inner wall of the container in a small-scale environment can be simulated, so that the liquid surface forms a curved or convex effect near the inner wall of the container.

[0179] Optionally, in some embodiments, in the process of simulating the liquid by sampling the reflection map according to the fused normal and calculating the lighting effect, an additional highlight may be added at the connection position, such as Figure 6 As shown, in this way, the details at the connection position can be further enriched. It can be understood that the highlight can simulate the gloss and reflection characteristics of the liquid surface, especially the edge area represented at the connection position between the liquid and the inner wall of the container, which can increase the visual contrast and depth of the scene, so that the richness of the details is enhanced.

[0180] For example, in technical implementation, a highlight component can be added by adjusting the lighting model in the shader. The highlight component can be a simple lighting multiplier or a more complex lighting function, which is used to enhance the lighting effect in a specific area.

[0181] See also Figure 7 and Figure 8 As shown, Figure 7 and Figure 8 The comparison of the effect before and after processing the connection position is shown. Through comparison, we can clearly see the visual difference before and after normal fusion and highlight addition. The processed image appears more natural and realistic at the connection position.

[0182] It should be noted that the eighth embodiment of the present application may also be an improvement based on any one or more embodiments from the first embodiment to the seventh embodiment.

[0183] It is not difficult to find that in the embodiment of the present application, by determining the connection position between the liquid and the inner wall of the container according to the virtual liquid surface, and simulating the liquid according to the connection position, a specific implementation method for simulating the liquid according to the virtual liquid surface is provided. In particular, when simulating small-scale liquids, by specially processing the details of the connection position between the liquid and the inner wall of the container, not only the realism of the liquid effect can be improved, but also the artistic expression can be enhanced, especially in the case of close observation.

[0184] In summary, the embodiments of the present application have at least the following technical effects:

[0185] 1. In the liquid simulation method provided in the embodiment of the present application, the visual effect is significantly improved compared with the traditional AlphaClip-based technical solution. In the traditional AlphaClip-based technical solution, the rendering of the liquid surface is simply by using a height value as a judgment condition, cutting off the pixels above the liquid surface, and drawing the back of the liquid as the liquid surface. Although this method is simple, the generated liquid surface effect is relatively simple and lacks the complexity and details of the liquid in the real world. In contrast, in the liquid simulation method provided in the embodiment of the present application, the judgment condition of the liquid surface is improved from the height value to the plane equation. Through the plane equation, the curvature and dynamic changes of the liquid surface can be more accurately simulated, thereby providing a more realistic visual effect; at the same time, in the liquid simulation method provided in the embodiment of the present application, by adding random noise disturbances, the natural fluctuations of the liquid surface, such as ripples and splashes, can be simulated, which increases the dynamic sense and visual richness of the liquid surface. Through these improvements, the solution can show more detailed and realistic liquid surface details while maintaining performance, thereby improving the overall visual effect.

[0186] 2. In the simulation method of liquid provided in the embodiment of the present application, when simulating small-scale liquid, the details of the junction between the cup wall and the liquid are focused on. In the traditional small-scale liquid simulation scheme, the junction between the cup wall and the liquid is often simplified or completely ignored, but the inventors found that in the game, there are often situations where small-scale liquids are observed closely, so it is necessary to focus on the details of the junction between the cup wall and the liquid. For example, in the simulation method of liquid provided in the embodiment of the present application, the junction between the cup wall and the liquid is subjected to normal fusion and special highlight processing. Among them, through normal fusion, the normal of the junction between the cup wall and the liquid can be adjusted, so that the transition between the liquid cup wall and the liquid is smoother and more natural, reducing the visual abruptness; through special highlight processing, a special highlight effect can be added to the junction where the cup wall and the liquid contact, simulating the reflection and refraction of light by the liquid, and enhancing the gloss and realism of the liquid. These improvements enable players to show more realistic physical properties and visual effects when observing small-scale liquids at close range, thereby enhancing the player's immersion and visual experience.

[0187] 3. The liquid simulation method provided in the embodiment of the present application has a significant improvement in performance compared to the traditional spring particle method. In the traditional spring particle method, a large amount of calculations need to be performed on each vertex to simulate the physical behavior of the liquid, which consumes a large amount of computing resources. However, in the liquid simulation method provided in the embodiment of the present application, the entire liquid only needs one spring model to roughly calculate the direction of movement of the liquid, thereby greatly reducing the amount of calculation and performance consumption.

[0188] In addition, the liquid simulation method provided in the embodiment of the present application also supports GPU Instance technology, which enables rendering with performance close to that of one Draw Call when multiple liquid effects are placed in a scene, thereby improving rendering efficiency.

[0189] In summary, the liquid simulation method provided by the embodiment of the present application can not only reduce the amount of calculation required for each liquid effect, but also improve the rendering efficiency through GPU Instance technology, and realize the simultaneous rendering of multiple liquid effects in complex scenes, while maintaining high performance and low resource consumption. The liquid simulation method provided by the embodiment of the present application can be applied to games that need to achieve high-quality interactive liquid effects on performance-limited platforms.

[0190] The step division of the above methods is only for the purpose of clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this patent.

[0191] In addition, some embodiments of the present application also provide an electronic device. The electronic device may be a digital computer in various forms, such as a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, etc. The electronic device may also be a mobile device in various forms, such as a personal digital processing, a cellular phone, a smart phone, a wearable device, and other similar computing devices.

[0192] The electronic device includes: one or more processors; and a memory storing computer program instructions, wherein when the computer program instructions are executed, the processor executes the steps of the method provided in any one or more of the above embodiments. Fig. 9 An exemplary structural diagram of the electronic device is disclosed. Fig. 9 As shown, the electronic device includes: one or more processors 1101, memory 1102, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Among them, the components shown in this article, their connections and relationships, and their functions are only used as examples, and are not intended to limit the implementation of the present application described and / or required herein.

[0193] The electronic device may further include: an input device 1103 and an output device 1104. The processor 1101, the memory 1102, the input device 1103 and the output device 1104 may be connected via a bus or other means. Fig. 9 The example of connecting through bus is taken in the following.

[0194] The input device 1103 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a track ball, a joystick and other input devices. The output device 1104 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.

[0195] To provide interaction with a user, the electronic device may be a computer. The computer has: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball), through which the user can provide input to the computer. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0196] In the embodiments of the present application, a computer program / instruction is stored on a computer-readable medium, and when the computer program / instruction is executed by a processor, the steps of the method provided by any one or more of the above embodiments are implemented. The computer-readable medium may be included in the electronic device described in the above embodiments; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more computer-readable instructions.

[0197] The memory 1102 can be used as a non-transient computer-readable storage medium, which can be used to store non-transient software programs, non-transient computer executable programs and modules. The processor 1101 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 1102, so as to implement the program instructions / modules corresponding to the method provided by any one or more embodiments in the embodiments of the present application.

[0198] The memory 1102 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1102 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 1102 may optionally include a memory remotely arranged relative to the processor 1101, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0199] It should be noted that the computer-readable medium described in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.

[0200] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.

[0201] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0202] In the above-described embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. For example, it can be implemented by using an application specific integrated circuit (ASIC), a general-purpose computer or any other similar hardware device. In certain embodiments, the software program of the present application can be executed by a processor to implement the above steps or functions. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented by hardware, for example, as a circuit that cooperates with a processor to perform each step or function.

[0203] The computer program product provided in the embodiment of the present application includes one or more computer programs / instructions, and when the computer program / instructions are executed by the processor, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from a computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0204] The flow chart or block diagram in the accompanying drawings shows the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0205] The scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes that fall within the meaning and scope of the equivalent elements of the claims are included in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim may also be implemented by one unit or device through software or hardware. The words "first", "second", etc. are only used to distinguish the description, and do not indicate any particular order, nor can they be understood as indicating or implying relative importance.

[0206] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily mention changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims, and the above embodiments should be regarded as exemplary and non-restrictive.

Claims

1. A method for simulating a liquid, characterized in that: The method comprises: Acquiring liquid level information; the liquid level information is used to characterize the geometric shape and position of the liquid level; Determining a virtual liquid surface according to the liquid surface information and container information; the container information is used to provide boundary conditions of the liquid surface; The liquid is simulated according to the virtual liquid surface.

2. The method according to claim 1, characterized in that: The obtaining of liquid level information comprises: Constructing a three-dimensional plane equation according to the liquid surface information to obtain a liquid surface equation; Correspondingly, the determining of the virtual liquid level according to the liquid level information and the container information is specifically: The virtual liquid level is determined according to the liquid level equation and the container information.

3. The method according to claim 2, characterized in that The method for constructing the liquid level equation includes: Get the starting point and end point of the spring skeleton model; Simulating the spring force of the liquid when it is shaking according to the starting point and the end point, and determining the end point posture of the spring skeleton model according to the spring force; The liquid surface equation is determined according to the endpoint posture.

4. The method according to claim 3, characterized in that The starting point and end point of obtaining the spring skeleton model include: According to the center of mass position of the liquid, obtaining the starting point of the spring skeleton model; The end point of the spring skeleton model is obtained according to the liquid level position of the liquid.

5. The method according to claim 3, characterized in that: The step of simulating the spring force of the liquid when it is shaking according to the starting point and the end point, and determining the end point posture of the spring skeleton model according to the spring force comprises: Obtaining the elastic coefficient, damping value and acceleration of the spring skeleton model; The spring force of the liquid when shaking is simulated according to the starting point and the end point, as well as the elastic coefficient, the damping value and the acceleration, and the end point posture of the spring skeleton model is determined according to the spring force.

6. The method according to claim 5, characterized in that The step of simulating the spring force of the liquid when it is shaking according to the starting point and the end point, as well as the elastic coefficient, the damping value and the acceleration, and determining the end point posture of the spring skeleton model according to the spring force includes: Acquire a target parameter, wherein the target parameter includes at least one of the following: a first weight value for characterizing the offset of the spring skeleton model, a second weight value for characterizing the rotation of the spring skeleton model, and a speed value for characterizing the recovery of the spring skeleton model; In combination with the target parameters, the spring force of the liquid when shaking is simulated according to the starting point and the end point, as well as the elastic coefficient, the damping value and the acceleration, and the end point posture of the spring skeleton model is determined according to the spring force.

7. The method according to any one of claims 1 to 6, characterized in that: Determining the virtual liquid level according to the liquid level information and the container information includes: Obtaining the ray equation from the coordinates of the inner wall of the container to the camera; wherein the coordinates of the inner wall of the container are used to represent the coordinates of the bottom of the liquid surface based on the inner wall of the container; Determining the coordinate position of the virtual liquid surface according to the ray equation and the liquid surface equation; The virtual liquid surface is determined according to the coordinate position of the virtual liquid surface.

8. The method according to claim 7, characterized in that The ray equation for obtaining the coordinates of the inner wall of the container and the camera includes: Acquire coordinate data of a point on the ray, a normalized direction vector representing the ray, and parameter information used to represent the distance of the coordinates of the inner wall of the container along the ray direction; The ray equation between the coordinates of the inner wall of the container and the camera is obtained according to the coordinate data, the normalized direction vector and the parameter information.

9. The method according to claim 7, characterized in that: Determining the coordinate position of the virtual liquid surface according to the ray equation and the liquid surface equation includes: Determining the coordinates of the intersection point according to the ray equation and the liquid surface equation; The coordinate position of the virtual liquid surface is determined according to the intersection coordinates.

10. The method according to claim 9, characterized in that Determining the intersection coordinates according to the ray equation and the liquid surface equation comprises: Obtain the coordinates of the inner wall of the first container above the liquid surface and the coordinates of the inner wall of the second container below the liquid surface; Determining the coordinates of the first intersection point according to the coordinates of the inner wall of the first container, the ray equation and the liquid surface equation; Determining the coordinates of the second intersection point according to the coordinates of the inner wall of the second container, the ray equation and the liquid surface equation; Correspondingly, the coordinate position of the virtual liquid surface is determined according to the intersection coordinates as follows: The coordinate position of the virtual liquid surface is determined according to the first intersection coordinates and the second intersection coordinates.

11. The method according to claim 10, characterized in that Determining the coordinates of the first intersection point according to the coordinates of the inner wall of the first container, the ray equation and the liquid surface equation comprises: Mirroring the coordinates of the inner wall of the first container using the liquid surface equation to determine a virtual reflection point; According to the virtual reflection point, construct an oblique vector of a preset angle; The coordinates of the first intersection point are determined according to the oblique vector, the ray equation and the liquid surface equation.

12. The method according to claim 7, characterized in that Determining the virtual liquid surface according to the coordinate position of the virtual liquid surface includes: Determining the target two-dimensional coordinates according to the coordinate position of the virtual liquid surface; Determining two-dimensional texture coordinates according to the target two-dimensional coordinates; Sampling is performed according to the two-dimensional texture coordinates to determine a virtual liquid surface.

13. The method according to claim 12, characterized in that The sampling according to the two-dimensional texture coordinates to determine the virtual liquid surface comprises: Determining a mask according to the surface of the liquid and the center of mass of the liquid; A virtual liquid surface is determined according to the two-dimensional texture coordinates and the mask; wherein the virtual liquid surface presents a three-dimensional foam effect.

14. The method according to any one of claims 1 to 6, characterized in that The simulating the liquid according to the virtual liquid surface comprises: Determining the connection position between the liquid and the inner wall of the container according to the virtual liquid surface; The liquid is simulated according to the engagement position.

15. The method according to claim 14, characterized in that The simulating of the liquid according to the connection position comprises: Obtaining a liquid surface normal and a container inner wall normal; wherein the liquid surface normal is used to characterize a vector of the liquid surface orientation, and the container inner wall normal is used to characterize a vector of the container inner wall surface; Determine a fusion normal according to the liquid surface normal and the container inner wall normal; the fusion normal is an arc; The liquid is simulated according to the blend normal.

16. The method according to claim 15, characterized in that Determining the fusion normal according to the liquid surface normal and the container inner wall normal includes: Obtaining interpolation parameters; wherein the interpolation parameters are determined according to the inner wall of the container; The liquid surface normal and the container inner wall normal are interpolated according to the interpolation parameters to determine a fused normal.

17. An electronic device, characterized in that: The electronic device comprises: one or more processors; and A memory storing computer program instructions which, when executed, cause the processor to perform the steps of the method as claimed in any one of claims 1 to 16.

18. A computer readable medium having a computer program / instructions stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 16 are implemented.

19. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 16 are implemented.