Fluid simulation diagram generation method and device, equipment and storage medium
By constructing height maps, heat maps and flow direction maps in fluid simulation, the problems of low efficiency and high cost of fluid simulation in the prior art are solved, and a more efficient and accurate fluid simulation effect is achieved.
Patent Information
- Application Number
- CN202411555826.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-03-21
AI Technical Summary
In the prior art, the fluid simulation efficiency is low and the cost is high. Especially in mobile platforms or high performance requirements, it is difficult to achieve real fluid simulation.
By obtaining the specified area of fluid flowing in the initial grid, the specified flow time and the specified flow direction, the specified area is divided into multiple grids, and a height map, thermal map and flow direction map are constructed based on the scene information to generate a flow simulation map of the fluid.
Improve the simulation efficiency, accuracy and authenticity of fluid simulation maps, reduce the cost of fluid simulation, and does not require the construction of separate terrain data for different terrains.
Smart Images

Figure CN119670343A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for generating a fluid simulation diagram. Background Art
[0002] Computer fluid simulation is a technical means that integrates computer science, fluid mechanics, mathematical theory of partial differential equations, computational geometry, numerical analysis and other scientific methods. It is widely used in aviation, aerospace, shipbuilding, and water conservancy. In the game industry, there are also many situations where water flow simulation is required for game performance. However, in the game industry, not only the authenticity of fluid simulation should be considered, but also the cost and efficiency of development and production resources should be considered.
[0003] In related technologies, fluid data is generated offline, and each specific terrain requires a separate piece of data, which results in a large expansion of art resources and high costs. In the process of real-time particle-based fluid simulation, due to the complexity of fluid simulation, these solutions cannot be applied to mobile platforms or occasions with high performance requirements. At the same time, these effects are closely related to the number of particles. When the number of particles meets the requirements of art performance, the high consumption has made it impossible for the game to run other logic. Moreover, this multi-particle performance is mutually exclusive with the fluid performance that requires smooth surfaces in the game, and can only be applied to some light puzzle games or games with simple art styles. Summary of the invention
[0004] The present disclosure provides a method, device, equipment and storage medium for generating a fluid simulation diagram, so as to at least solve the problems of low fluid simulation efficiency and high fluid simulation cost in the related art. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a method for generating a fluid simulation diagram is provided, comprising:
[0006] Acquire a specified area, a specified flow time, and a specified flow direction of the fluid in an initial grid, and divide the specified area into a plurality of grids; the initial grid is determined based on scene information of the fluid simulation area;
[0007] Determine the expected height of the fluid in each grid according to the scene information of the fluid simulation area; and construct a height map according to the expected height of the fluid in each grid;
[0008] Determining a predicted time for the fluid to reach each grid according to the specified flow time; and constructing a thermal map according to the predicted time for the fluid to reach each grid;
[0009] Determine the flow direction of the fluid in each grid according to the specified flow direction; and construct a flow direction diagram according to the flow direction of the fluid in each grid;
[0010] A flow simulation diagram of the fluid is generated according to the height map, the thermal map and the flow direction map.
[0011] In an exemplary embodiment, determining the expected height of the fluid in each grid according to the scene information of the fluid simulation area includes:
[0012] Determining the ground height of each grid and the liquid level height of the fluid in each grid according to the scene information of the fluid simulation area;
[0013] The sum of the ground height and the liquid level height corresponding to each grid is calculated to obtain the expected height of the fluid in each grid.
[0014] In an exemplary embodiment, determining the ground height of each grid and the liquid level height of the fluid in each grid according to the scene information of the fluid simulation area includes:
[0015] Determining the ground height of each grid according to the scene information and coordinate information of the fluid simulation area;
[0016] Determining, according to the scene information of the fluid simulation area, a first distance between each grid and the liquid outlet and a second distance between each grid and the edge of the fluid;
[0017] The liquid level of the fluid in each grid is determined according to the first distance and the second distance corresponding to each grid; wherein the liquid level decreases as the first distance increases and increases as the second distance increases.
[0018] In an exemplary embodiment, determining the predicted time for the fluid to reach each grid according to the specified flow time includes:
[0019] Determine the height cost of the fluid to reach each grid according to the expected height of the fluid in each grid;
[0020] Determining the terrain corresponding to each grid according to the scene information of the fluid simulation area;
[0021] Determine the terrain cost of each grid based on the terrain corresponding to each grid;
[0022] The predicted time for the fluid to reach each grid is determined according to the designated flow time, the height cost for the fluid to reach each grid, and the terrain cost of each grid.
[0023] In an exemplary embodiment, determining the predicted time for the fluid to reach each grid according to the specified flow time, the height cost for the fluid to reach each grid, and the terrain cost for each grid includes:
[0024] Each grid in the initial grid is traversed in turn, and the following operations are performed for each current grid traversed:
[0025] Determine adjacent grids of the current grid in the initial grid;
[0026] Determine the flow cost of the fluid flowing from the current grid to the adjacent grid according to the height cost of the fluid flowing from the current grid to the adjacent grid and the terrain cost;
[0027] The predicted time for the fluid to arrive at each grid is determined according to the designated flow time and the flow cost of the fluid flowing from the current grid to the adjacent grid.
[0028] In an exemplary embodiment, the current grid corresponds to a plurality of adjacent grids, and determining the flow direction of the fluid in each grid according to the specified flow direction includes:
[0029] According to the flow cost from the current grid to each adjacent grid, a grid with the lowest flow cost is selected from the plurality of adjacent grids as a selected adjacent grid;
[0030] Constructing a distance unit vector between the current grid and the selected adjacent grid;
[0031] Calculating the distance between the current grid and each adjacent grid;
[0032] Determine a distance vector from the current grid to each adjacent grid according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and each adjacent grid;
[0033] The target flow direction of the fluid in the current grid is determined according to the sum of the distance vectors corresponding to the plurality of adjacent grids.
[0034] In an exemplary embodiment, determining the distance vector from the current grid to each adjacent grid according to the distance unit vector from the current grid to the selected adjacent grid and the distance between the current grid and each adjacent grid includes:
[0035] Taking the grids among the plurality of adjacent grids except the screened adjacent grid as the remaining adjacent grids;
[0036] Determine a real-time distance vector between the current grid and the remaining adjacent grids according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and the remaining adjacent grids;
[0037] The step of determining the target flow direction of the fluid in the current grid according to the sum of the distance vectors corresponding to the plurality of adjacent grids includes:
[0038] Calculate the sum of the distance unit vector and the real-time distance vector to obtain a comprehensive distance vector corresponding to the current grid;
[0039] The comprehensive distance vector is normalized to obtain the target flow direction of the fluid in the current grid.
[0040] In an exemplary embodiment, generating the flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map includes:
[0041] The height map, the heat map and the flow direction map are transmitted to a graphics processor, wherein the graphics processor includes an r channel, a g channel and a ba channel;
[0042] Determine first filling data for the r channel based on the height map;
[0043] Determining second filling data for the g channel based on the heat map;
[0044] Determining third filling data of the ba channel based on the flow direction map;
[0045] Based on the graphics processor, the first filling data is filled into the r channel, the second filling data is filled into the g channel, and the third filling data is filled into the ba channel to generate a flow simulation diagram of the fluid.
[0046] In an exemplary embodiment, determining the first filling data of the r channel based on the height map includes:
[0047] Determining the expected height of each grid at which the fluid flows based on the height map;
[0048] Determine a first height of the highest area and a second height of the lowest area in the fluid simulation area;
[0049] The first filling data of the r channel is determined according to the first height, the second height, the height of the fluid flowing through each grid, and the expected height.
[0050] In an exemplary embodiment, determining the second filling data of the g channel based on the heat map includes:
[0051] Determining, according to the thermal map, a flow cost of the fluid flowing through each grid and a maximum flow cost of the fluid simulation area;
[0052] The second filling data of the g channel is determined according to the flow cost of the fluid flowing through each grid and the maximum flow cost of the fluid simulation area.
[0053] In an exemplary embodiment, determining the third filling data of the ba channel based on the flow direction map includes:
[0054] Determining the flow direction of the fluid along the x-axis and the flow direction along the z-axis according to the flow direction diagram;
[0055] Determining filling data of channel b in channel ba according to the flow direction of the fluid along the x-axis;
[0056] Determining filling data of channel a in channel ba according to the flow direction of the fluid along the z-axis;
[0057] The filling data of the b channel and the filling data of the a channel are determined as the third filling data of the ba channel.
[0058] In an exemplary embodiment, generating the flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map includes:
[0059] determining a target height of a vertex in the fluid based on the height map, and determining a current flow process of the fluid based on the thermal map;
[0060] Determining a height offset according to the current flow process of the fluid and the flow direction diagram, and adjusting the target height of the vertex according to the height offset to obtain an updated target height of the vertex;
[0061] When the vertex moves in a quasi-circular motion with the wave, the waveform parameters in the running process are fused to obtain fused waveform parameters;
[0062] A flow simulation diagram of the fluid is generated according to the updated target height of the vertex and the fused waveform parameters.
[0063] In an exemplary embodiment, generating the flow simulation diagram of the fluid according to the updated target height of the vertex and the fused waveform parameter includes:
[0064] Generate a vertex change graph according to the updated target height of the vertex and the fused waveform parameters;
[0065] determining the impact progress of vertices in the fluid according to the thermal map;
[0066] Generate wavefront spray according to the impact process of the vertex and the screen depth;
[0067] A flow simulation diagram of the fluid is generated according to the vertex change diagram and the wave front ripples.
[0068] In an exemplary embodiment, generating a flow simulation diagram of the fluid according to the vertex change diagram and the wave front spray includes:
[0069] determining edge fluid based on the thermal map, and simulating white foam of the edge fluid based on Perlin noise;
[0070] A flow simulation diagram of the fluid is generated according to the vertex change diagram, the wave front ripples and the white foam of the edge fluid.
[0071] In an exemplary embodiment, generating a flow simulation diagram of the fluid according to the vertex change diagram, the wave front spray, and the white foam of the edge fluid includes:
[0072] Determining the advancing time of a target wave having a surge amplitude greater than a preset amplitude according to the current flow process of the fluid;
[0073] Determine the circular motion diameter and y-axis offset corresponding to the vertex of the target wave;
[0074] According to the advancing time, circular motion diameter and y-axis offset of the target wave, the color of the wave front spray is superimposed on the target wave to generate a wave highlight image;
[0075] A flow simulation diagram of the fluid is generated according to the vertex change diagram, the wave front spray, the white foam of the edge fluid and the wave highlight diagram.
[0076] In an exemplary embodiment, obtaining a specified area, a specified flow time, and a specified flow direction of the fluid flowing in the initial grid includes:
[0077] Determine the fluid simulation area, and obtain scene information of the fluid simulation area; the scene information includes height information, rectangular area, number of pixels, flow direction and flow terrain addition;
[0078] According to the scene information of the fluid simulation area, the designated area, designated flow time and designated flow direction of the fluid in the initial grid are determined.
[0079] According to a second aspect of an embodiment of the present disclosure, there is provided a device for generating a fluid simulation diagram, comprising:
[0080] An information acquisition module is configured to acquire a designated area, a designated flow time, and a designated flow direction of a fluid flowing in an initial grid, and divide the designated area into a plurality of grids; the initial grid is determined based on scene information of a fluid simulation area;
[0081] An expected height determination module is configured to determine an expected height of the fluid in each grid according to scene information of the fluid simulation area; and construct a height map according to the expected height of the fluid in each grid;
[0082] A heat map construction module is configured to determine the predicted time for the fluid to arrive at each grid according to the specified flow time; and construct a heat map according to the predicted time for the fluid to arrive at each grid;
[0083] A flow direction diagram construction module is configured to determine the flow direction of the fluid in each grid according to the specified flow direction; and construct a flow direction diagram according to the flow direction of the fluid in each grid;
[0084] The flow simulation diagram construction module is configured to generate a flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map.
[0085] In an exemplary embodiment, the desired height determination module includes:
[0086] A liquid level determination unit, configured to determine the ground height of each grid and the liquid level of the fluid in each grid according to the scene information of the fluid simulation area;
[0087] The expected height determination unit is configured to calculate the sum of the ground height and the liquid level height corresponding to each grid to obtain the expected height of the fluid in each grid.
[0088] In an exemplary embodiment, the liquid level determination unit comprises:
[0089] A ground height determination subunit is configured to determine the ground height of each grid according to the scene information and coordinate information of the fluid simulation area;
[0090] a distance determination subunit, configured to determine a first distance between each grid and the liquid outlet and a second distance between each grid and the edge of the fluid according to scene information of the fluid simulation area;
[0091] The liquid level determination subunit is configured to determine the liquid level of the fluid in each grid according to the first distance and the second distance corresponding to each grid; wherein the liquid level decreases as the first distance increases and increases as the second distance increases.
[0092] In an exemplary embodiment, the heat map construction module includes:
[0093] A height cost determination unit, configured to determine a height cost for the fluid to reach each grid according to an expected height of the fluid at each grid;
[0094] A terrain determination unit, configured to determine the terrain corresponding to each grid according to the scene information of the fluid simulation area;
[0095] A terrain cost determination unit is configured to determine the terrain cost of each grid according to the terrain corresponding to each grid;
[0096] The predicted time determination unit is configured to determine the predicted time when the fluid reaches each grid according to the designated flow time, the height cost of the fluid reaching each grid, and the terrain cost of each grid.
[0097] In an exemplary implementation, the prediction time determination unit is further configured to sequentially traverse each grid in the initial grid, and for each current grid traversed, perform the following operations:
[0098] Determine adjacent grids of the current grid in the initial grid;
[0099] Determine the flow cost of the fluid flowing from the current grid to the adjacent grid according to the height cost of the fluid flowing from the current grid to the adjacent grid and the terrain cost;
[0100] The predicted time for the fluid to arrive at each grid is determined according to the designated flow time and the flow cost of the fluid flowing from the current grid to the adjacent grid.
[0101] In an exemplary embodiment, the flow direction map building module includes:
[0102] A screening unit is configured to screen out a grid with the lowest flow cost from the plurality of adjacent grids according to the flow cost from the current grid to each adjacent grid as a screened adjacent grid;
[0103] A distance unit vector construction unit is configured to execute construction of a distance unit vector between the current grid and the selected adjacent grid;
[0104] A distance calculation unit, configured to calculate the distance between the current grid and each adjacent grid;
[0105] a distance vector determining unit, configured to determine a distance vector from the current grid to each adjacent grid according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and each adjacent grid;
[0106] The target flow direction determining unit is configured to determine the target flow direction of the fluid in the current grid according to the sum of the distance vectors corresponding to each of the plurality of adjacent grids.
[0107] In an exemplary embodiment, the distance vector determining unit includes:
[0108] A remaining grid determination subunit is configured to execute the process of taking the grids among the plurality of adjacent grids except the screened adjacent grids as remaining adjacent grids;
[0109] A real-time distance vector determination subunit is configured to determine a real-time distance vector between the current grid and the remaining adjacent grids according to a distance unit vector pointing from the current grid to the screened adjacent grid and a distance between the current grid and the remaining adjacent grids;
[0110] The target flow direction determination unit comprises:
[0111] A comprehensive distance vector determination subunit is configured to calculate the sum of the distance unit vector and the real-time distance vector to obtain a comprehensive distance vector corresponding to the current grid;
[0112] The target flow direction determination subunit is configured to perform normalization processing on the comprehensive distance vector to obtain the target flow direction of the fluid in the current grid.
[0113] In an exemplary embodiment, the flow simulation diagram construction module includes:
[0114] A data input unit is configured to input the height map, the heat map and the flow direction map into a graphics processor, wherein the graphics processor includes an r channel, a g channel and a ba channel;
[0115] A first data determining unit is configured to determine first filling data of the r channel based on the height map;
[0116] A second data determination unit is configured to determine second filling data of the g channel based on the heat map;
[0117] A third data determination unit is configured to determine third filling data of the ba channel based on the flow direction map;
[0118] The simulation diagram generating unit is configured to execute, based on the graphics processor, filling the first filling data into the r channel, filling the second filling data into the g channel, and filling the third filling data into the ba channel to generate a flow simulation diagram of the fluid.
[0119] In an exemplary embodiment, the first data determination unit includes:
[0120] an expected height determination subunit, configured to determine an expected height of the fluid flowing through each grid based on the height map;
[0121] A height determination subunit, configured to determine a first height of a highest area and a second height of a lowest area in the fluid simulation area;
[0122] The first data determination subunit is configured to determine first filling data of the r channel according to the first height, the second height, the height of the fluid flowing through each grid, and the expected height.
[0123] In an exemplary embodiment, the second data determination unit includes:
[0124] A flow cost determination subunit, configured to determine the flow cost of the fluid flowing through each grid and the maximum flow cost of the fluid simulation area according to the thermal map;
[0125] The second data determination subunit is configured to determine the second filling data of the g channel according to the flow cost of the fluid flowing through each grid and the maximum flow cost of the fluid simulation area.
[0126] In an exemplary implementation, the third data determination unit includes:
[0127] a flow direction determination subunit, configured to determine the flow direction of the fluid along the x-axis and the flow direction along the z-axis according to the flow direction diagram;
[0128] A first filling data determination subunit is configured to determine filling data of channel b in channel ba according to a flow direction of the fluid along the x-axis;
[0129] A second filling data determination subunit is configured to determine the filling data of the a channel in the ba channel according to the flow direction of the fluid along the z-axis;
[0130] The third filling data determining subunit is configured to determine the filling data of the b channel and the filling data of the a channel as the third filling data of the ba channel.
[0131] In an exemplary embodiment, the flow simulation diagram construction module includes:
[0132] a flow process determination unit configured to determine a target height of a vertex in the fluid according to the height map, and to determine a current flow process of the fluid according to the thermal map;
[0133] a height updating unit, configured to determine a height offset according to a current flow process of the fluid and the flow direction diagram, and adjust a target height of the vertex according to the height offset to obtain an updated target height of the vertex;
[0134] A parameter fusion unit is configured to fuse the waveform parameters in the running process to obtain fused waveform parameters when the vertex moves in a quasi-circular motion with the wave;
[0135] The simulation diagram generating unit is configured to generate a flow simulation diagram of the fluid according to the updated target height of the vertex and the fused waveform parameters.
[0136] In an exemplary embodiment, the simulation diagram generating unit includes:
[0137] A vertex change graph generating subunit is configured to generate a vertex change graph according to the updated target height of the vertex and the fused waveform parameter;
[0138] an impact process determination subunit, configured to execute an impact process for determining vertices in the fluid according to the thermal map;
[0139] A wavefront spray sub-generation unit is configured to generate wavefront spray according to the impact process of the vertex and the screen depth;
[0140] The simulation graph generating subunit is configured to generate a flow simulation graph of the fluid according to the vertex change graph and the wave front ripples.
[0141] In an exemplary embodiment, the simulation diagram generating subunit includes:
[0142] A white foam simulation subunit, configured to determine the edge fluid based on the thermal map, and simulate the white foam of the edge fluid based on Perlin noise;
[0143] The graph simulation subunit is configured to generate a flow simulation graph of the fluid based on the vertex change graph, the wave front ripples and the foam of the edge fluid.
[0144] In an exemplary embodiment, the graph simulation subunit includes:
[0145] an advancement time determination subunit, configured to determine the advancement time of a target wave having a surge amplitude greater than a preset amplitude according to a current flow process of the fluid;
[0146] an offset determination subunit, configured to determine a circular motion diameter and a y-axis offset corresponding to the vertex of the target wave;
[0147] A wave highlight image generating subunit is configured to generate a wave highlight image by superimposing the wave front spray color on the target wave according to the advancing time, the circular motion diameter and the y-axis offset of the target wave;
[0148] The flow simulation graph generating subunit is configured to generate a flow simulation graph of the fluid according to the vertex change graph, the wave front ripples, the white foam of the edge fluid and the wave highlight graph.
[0149] In an exemplary embodiment, the information acquisition module includes:
[0150] A scene information acquisition unit is configured to determine the fluid simulation area and acquire scene information of the fluid simulation area; the scene information includes height information, rectangular area, number of pixels, flow direction and flow terrain addition;
[0151] The designated information determination unit is configured to determine the designated area, designated flow time and designated flow direction of the fluid in the initial grid according to the scene information of the fluid simulation area.
[0152] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0153] processor;
[0154] a memory for storing instructions executable by the processor;
[0155] Wherein, the processor is configured to execute the instructions to implement the method for generating the fluid simulation diagram as described above.
[0156] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for generating a fluid simulation diagram as described above.
[0157] According to a fifth aspect of an embodiment of the present disclosure, there is provided a computer program product, comprising a computer program, which, when executed by a processor, implements the method for generating a fluid simulation diagram as described above.
[0158] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0159] The present disclosure obtains the specified area, specified flow time and specified flow direction of the fluid flowing in the initial grid, and divides the specified area into multiple grids; the initial grid is determined based on the scene information of the fluid simulation area; according to the scene information of the fluid simulation area, the expected height of the fluid in each grid is determined; and according to the expected height of the fluid in each grid, a height map is constructed; according to the specified flow time, the predicted time for the fluid to reach each grid is determined; and according to the predicted time for the fluid to reach each grid, a thermal map is constructed; according to the specified flow direction, the flow direction of the fluid in each grid is determined; and according to the flow direction of the fluid in each grid, a flow direction map is constructed; according to the height map, the thermal map and the flow direction map, a flow simulation map of the fluid is generated. The present disclosure can quickly and accurately construct a height map, a thermal map and a flow direction map of the fluid simulation area according to the scene information of the fluid simulation area, thereby improving the simulation efficiency, accuracy and authenticity of the flow simulation map of the fluid. And the present disclosure does not need to construct separate terrain data for different terrains, reducing the cost of fluid simulation.
[0160] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0161] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0162] Figure 1 This is an application environment diagram of a method for generating a fluid simulation diagram according to an exemplary embodiment.
[0163] Figure 2 The present invention is a flowchart of a method for generating a fluid simulation diagram according to an exemplary embodiment.
[0164] Figure 3 The present invention is a flowchart showing a method of determining the ground height of each grid and the liquid level height of the fluid in each grid according to scene information of the fluid simulation area according to an exemplary embodiment.
[0165] Figure 4The present invention is a flowchart showing a method of determining a predicted time for the fluid to reach each grid according to the specified flow time according to an exemplary embodiment.
[0166] Figure 5 It is a flowchart showing a method of generating a flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map according to an exemplary embodiment.
[0167] Figure 6 The invention is a flowchart showing a method of determining first filling data of the r channel based on the height map according to an exemplary embodiment.
[0168] Figure 7 It is a block diagram of a device for generating a fluid simulation diagram according to an exemplary embodiment.
[0169] Figure 8 It is a block diagram of a server according to an exemplary embodiment.
[0170] Fig. 9 It is a block diagram of an electronic device for generating a fluid simulation diagram according to an exemplary embodiment. DETAILED DESCRIPTION
[0171] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0172] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0173] See also Figure 1 , which is a diagram showing an application environment of a method for generating a fluid simulation diagram according to an exemplary embodiment. The application environment may include a server 01 and a client 02.
[0174] Specifically, in the embodiments of this specification, the server 01 may include an independently operated server, or a distributed server, or a server cluster composed of multiple servers, and may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 01 may include a network communication unit, a processor, a memory, and the like. Specifically, the server 01 can be used to construct a height map, a thermal map, and a flow direction map of the fluid; and generate a flow simulation map of the fluid based on the height map, the thermal map, and the flow direction map; and send the flow simulation map to the client 02.
[0175] Specifically, in the embodiments of this specification, the client 02 may include physical devices such as smart phones, desktop computers, tablet computers, laptop computers, digital assistants, smart wearable devices, and vehicle-mounted terminals, and may also include software running in physical devices, such as web pages provided by some service providers to users, or applications provided by these service providers to users. Specifically, the client 02 may be used to display a flow simulation diagram.
[0176] Figure 2 is a flow chart of a method for generating a fluid simulation diagram according to an exemplary embodiment. Figure 2 As shown, this method can be applied to Figure 1 The server 01 shown includes the following steps.
[0177] In step S201, a designated area, a designated flow time, and a designated flow direction of the fluid in an initial grid are obtained, and the designated area is divided into a plurality of grids; the initial grid is determined based on scene information of the fluid simulation area.
[0178] In the disclosed embodiments, the fluid may include but is not limited to water flow or other liquid flow, etc.; the initial grid may be an N*N rectangular diagram. The designated area may be a rectangle of N*M, and there should be no influence of any fluid outside the rectangular area, and any grid within the rectangular area should be impacted by the fluid. In order to simplify the calculation, the N*M area is divided into w*h grids for management. Among them, M is less than N, w is greater than N, and h is greater than N. The designated area can be divided into a target number of grids according to actual conditions. The specified flow time refers to spreading the fluid to the entire fluid simulation area within the planned specified time. The specified flow direction can be determined according to the outlet position of the fluid, so the initial flow direction of the fluid is fixed.
[0179] In combination with the above-mentioned designated area, designated flow time and designated flow direction, the expected height of the fluid in each grid, the flow direction and the predicted time for the fluid to reach each grid can be determined, thereby performing fluid simulation.
[0180] In step S203, the expected height of the fluid in each grid is determined according to the scene information of the fluid simulation area; and a height map is constructed according to the expected height of the fluid in each grid.
[0181] In step S205, the predicted time for the fluid to reach each grid is determined according to the specified flow time; and a thermal map is constructed according to the predicted time for the fluid to reach each grid.
[0182] In step S207, the flow direction of the fluid in each grid is determined according to the specified flow direction; and a flow direction diagram is constructed according to the flow direction of the fluid in each grid.
[0183] In step S209, a flow simulation diagram of the fluid is generated according to the height map, the thermal map and the flow direction map.
[0184] In the disclosed embodiment, the expected height of the fluid in each grid can be determined based on the scene information of the fluid simulation area, thereby constructing a height map; the predicted time for the fluid to reach each grid can be determined based on the specified flow time, thereby constructing a thermal map; the flow direction of the fluid in each grid can be determined based on the specified flow direction, thereby constructing a flow direction map; and the height map, thermal map and flow direction map are combined to generate a flow simulation map of the fluid.
[0185] The present disclosure obtains the specified area, specified flow time and specified flow direction of the fluid flowing in the initial grid, and divides the specified area into multiple grids; the initial grid is determined based on the scene information of the fluid simulation area; according to the scene information of the fluid simulation area, the expected height of the fluid in each grid is determined; and according to the expected height of the fluid in each grid, a height map is constructed; according to the specified flow time, the predicted time for the fluid to reach each grid is determined; and according to the predicted time for the fluid to reach each grid, a thermal map is constructed; according to the specified flow direction, the flow direction of the fluid in each grid is determined; and according to the flow direction of the fluid in each grid, a flow direction map is constructed; according to the height map, the thermal map and the flow direction map, a flow simulation map of the fluid is generated. The present disclosure can quickly and accurately construct a height map, a thermal map and a flow direction map of the fluid simulation area according to the scene information of the fluid simulation area, thereby improving the simulation efficiency, accuracy and authenticity of the flow simulation map of the fluid. And the present disclosure does not need to construct separate terrain data for different terrains, reducing the cost of fluid simulation.
[0186] In the embodiment of the present disclosure, an initial grid may be pre-constructed, and a method for constructing the initial grid includes:
[0187] According to the limited number of vertices of the preset platform and the preset shape of the mesh, the preset size of the mesh and the number of vertices per unit length are determined;
[0188] An initial mesh corresponding to the fluid simulation area is constructed according to the preset size and the number of vertices per unit length.
[0189] In the disclosed embodiment, the preset platform may be a platform for constructing a flow simulation diagram, which may include but is not limited to Unity, which is a real-time 3D interactive content creation and operation platform. The limit number of vertices of the preset platform can be obtained, and the preset shape of the mesh can be set, so as to determine the preset size of the mesh and the number of vertices per unit length according to the limit number of vertices and the preset shape. This embodiment does not perform too much calculation on the mesh, and all mesh modifications are placed on the graphics processing unit (GPU) side.
[0190] For example, you can first build a very large mesh plane, because the subsequent process needs to make different position offsets for the vertices to simulate the water flow, so in theory, the higher the number of faces, the better, but Unity will limit the number of vertices to 16 bits, that is, 65535 vertices; because the textures used later Figure 1Generally, it will be saved as an N*N square image, so the generated mesh can be a square. Combined with the above two restrictions, the initial mesh is finally determined to be a mesh of 10 meters × 10 meters with 25 vertices per meter. 10*10*25*25=62500. If the area of the fluid exceeds 10 meters, further determine the accuracy requirements. If the accuracy requirements are low, the fluid surface can be scaled; if the accuracy requirements are high, multiple patches can be generated for splicing.
[0191] In the embodiment of the present disclosure, obtaining the specified area, specified flow time, and specified flow direction of the fluid flowing in the initial grid includes:
[0192] Determine the fluid simulation area, and obtain scene information of the fluid simulation area; the scene information includes height information, rectangular area, number of pixels, flow direction and flow terrain addition;
[0193] According to the scene information of the fluid simulation area, the designated area, designated flow time and designated flow direction of the fluid in the initial grid are determined.
[0194] In the disclosed embodiments, the designated area for fluid flow can be determined based on the height information, rectangular area, and flow terrain addition of the fluid simulation area; the designated flow direction of the fluid can be determined based on the flow direction of the fluid simulation area; and the designated flow time for the fluid to flow through the fluid simulation area can be set based on the size of the designated area.
[0195] In the disclosed embodiment, the designated area, designated flow time and designated flow direction of the fluid flow in the initial grid can be preliminarily determined based on scene information such as height information of the fluid simulation area, rectangular area, number of pixels, flow direction and flow terrain addition, thereby facilitating the subsequent accurate construction of a height map, thermal map and flow direction map of the fluid in the fluid simulation area.
[0196] In the embodiment of the present disclosure, determining the expected height of the fluid in each grid according to the scene information of the fluid simulation area includes:
[0197] Determining the ground height of each grid and the liquid level height of the fluid in each grid according to the scene information of the fluid simulation area;
[0198] The sum of the ground height and the liquid level height corresponding to each grid is calculated to obtain the expected height of the fluid in each grid.
[0199] In the disclosed embodiment, the expected height of the fluid in each grid is the sum of the ground height and the liquid level height. Therefore, it is necessary to first determine the ground height of each grid and the liquid level height of the fluid in each grid based on the scene information of the fluid simulation area.
[0200] In the present disclosure, Figure 3 As shown, determining the ground height of each grid and the liquid level height of the fluid in each grid according to the scene information of the fluid simulation area includes:
[0201] S301: determining the ground height of each grid according to the scene information and coordinate information of the fluid simulation area;
[0202] S303: determining a first distance between each grid and the liquid outlet and a second distance between each grid and the edge of the fluid according to the scene information of the fluid simulation area;
[0203] S305: Determine the liquid level of the fluid in each grid according to the first distance and the second distance corresponding to each grid; wherein the liquid level decreases as the first distance increases and increases as the second distance increases.
[0204] In the disclosed embodiment, the ground height of each grid is determined according to the scene information and coordinate information of the fluid simulation area; illustratively, each grid can be individually rayed, and the ground height of each grid can be determined through the coordinate system; if only the terrain is concerned, the ground height of each grid can be determined by the terrain's Sampleheight interface method; if the focus is not only on the terrain, the Navmesh pathfinding solution can also be used. The height can be baked at the same time when the Navmesh is baked, so that the height of a certain position can be reached faster than raycasting. NavMesh (navigation mesh) is a technology for active pathfinding in the 3D game world. In addition, RaycastCommand can also be used to shoot rays. This solution can determine the ground height more quickly when the number of raycasts is relatively large. RaycastCommand is an efficient batch ray detection solution that comes with Unity. According to the scene information of the fluid simulation area, the first distance of each grid from the liquid outlet and the second distance of each grid from the fluid edge can be determined; thus, according to the first distance and the second distance corresponding to each grid, the liquid level of the fluid in each grid is determined; wherein, the liquid level decreases with the increase of the first distance and increases with the increase of the second distance; that is, the closer the liquid level is to the liquid outlet, the higher it is, and the closer it is to the fluid edge, the lower it is. The edge shape of the fluid refers to the irregular edge formed by the superposition of multiple trigonometric functions.
[0205] In the disclosed embodiment, the first distance of each grid from the liquid outlet and the second distance of each grid from the fluid edge can be determined based on the scene information of the fluid simulation area; thereby, the liquid level height of different terrains can be calculated quickly and accurately, thereby quickly and accurately determining the expected height of each grid.
[0206] In the present disclosure, Figure 4 As shown, determining the predicted time for the fluid to reach each grid according to the specified flow time includes:
[0207] S2051: Determine the height cost of the fluid to reach each grid according to the expected height of the fluid in each grid;
[0208] S2053: Determine the terrain corresponding to each grid according to the scene information of the fluid simulation area;
[0209] S2055: Determine the terrain cost of each grid according to the terrain corresponding to each grid;
[0210] S2057: Determine the predicted time for the fluid to reach each grid according to the specified flow time, the height cost for the fluid to reach each grid, and the terrain cost for each grid.
[0211] In the disclosed embodiment, when the fluid is water flow, the time for the water flow to reach each location (grid) can be calculated. The time for the water flow to reach each location should be related to the path cost to reach this location. The path cost is related to two factors:
[0212] (1) Height cost: Water flows to lower places. When calculating the cost, the height difference should be passed in as a coefficient. The height difference can be calculated by the expected height of the grid;
[0213] (2) Terrain cost: Some terrains do not allow water to pass through, such as obstacles; some terrains allow water to pass through with almost no consumption, such as rivers. Therefore, different terrain cost coefficients can be set for different terrains; for example, different functions can be set for different terrains to determine the terrain cost coefficients.
[0214] In the disclosed embodiment, the predicted time for the fluid to reach each grid can be accurately determined based on the height cost for the fluid to reach each grid, the terrain cost for each grid, and the specified flow time.
[0215] In the embodiment of the present disclosure, determining the predicted time for the fluid to reach each grid according to the specified flow time, the height cost for the fluid to reach each grid, and the terrain cost of each grid includes:
[0216] Each grid in the initial grid is traversed in turn, and the following operations are performed for each current grid traversed:
[0217] Determine adjacent grids of the current grid in the initial grid;
[0218] Determine the flow cost of the fluid flowing from the current grid to the adjacent grid according to the height cost of the fluid flowing from the current grid to the adjacent grid and the terrain cost;
[0219] The predicted time for the fluid to arrive at each grid is determined according to the designated flow time and the flow cost of the fluid flowing from the current grid to the adjacent grid.
[0220] In the disclosed embodiment, the current grid may correspond to adjacent grids in multiple directions, and the flow cost of each current grid flowing to the surrounding adjacent grids may be calculated in turn, so that the predicted time for the fluid to reach each grid may be calculated based on the specified flow time and flow cost. During the calculation process, the time coefficient for the fluid to reach the adjacent grid from each current grid may be calculated based on the flow cost of the fluid flowing from the current grid to the adjacent grid, and the sum of the time coefficients corresponding to all current grids may be calculated. For each current grid, the ratio of the time coefficient corresponding to the current grid to the sum of the time coefficients may be calculated to obtain the coefficient ratio, and then the product of the specified flow time and the coefficient ratio may be calculated to obtain the predicted time corresponding to the current grid, so that the predicted time for the fluid to reach each grid may be further determined.
[0221] In the disclosed embodiment, each grid in the initial grid can be traversed in turn. For each current grid traversed, the flow cost of the fluid flowing from the current grid to the adjacent grid can be accurately determined based on the height cost and terrain cost of the fluid flowing from the current grid to the adjacent grid, thereby facilitating further accurate determination of the predicted time for the fluid to arrive at each grid.
[0222] In the embodiment of the present disclosure, the current grid corresponds to a plurality of adjacent grids, and determining the flow direction of the fluid in each grid according to the specified flow direction includes:
[0223] According to the flow cost from the current grid to each adjacent grid, a grid with the lowest flow cost is selected from the plurality of adjacent grids as a selected adjacent grid;
[0224] Constructing a distance unit vector between the current grid and the selected adjacent grid;
[0225] Calculating the distance between the current grid and each adjacent grid;
[0226] Determine a distance vector from the current grid to each adjacent grid according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and each adjacent grid;
[0227] The target flow direction of the fluid in the current grid is determined according to the sum of the distance vectors corresponding to the plurality of adjacent grids.
[0228] In the disclosed embodiment, for each adjacent grid, after calculating the current distance between it and the current grid, the ratio of the above-mentioned distance unit vector to the current distance can be further calculated to obtain the distance vector between the current grid and the adjacent grid; after obtaining the distance vector between the current grid and each adjacent grid, the sum of the distance vectors corresponding to each adjacent grid can be calculated to determine the target flow direction of the fluid in the current grid.
[0229] Exemplarily, the current grid can correspond to adjacent grids in eight directions, and the grid with the lowest flow cost among the eight surrounding grids can be found to generate a distance unit vector. In order to make the flow more natural, other grids are calculated using convolution kernels: eight standardized vectors pointing from the current grid to the adjacent grids are generated. If the length of the vector pointing to the grid with the shortest distance is regarded as 1, the target flow direction of the fluid in the current grid is determined based on the sum of the distance vectors corresponding to the eight adjacent grids.
[0230] In the embodiment of the present disclosure, determining the distance vector from the current grid to each adjacent grid according to the distance unit vector from the current grid to the screened adjacent grid and the distance between the current grid and each adjacent grid includes:
[0231] Taking the grids among the plurality of adjacent grids except the screened adjacent grid as the remaining adjacent grids;
[0232] Determine a real-time distance vector between the current grid and the remaining adjacent grids according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and the remaining adjacent grids;
[0233] The step of determining the target flow direction of the fluid in the current grid according to the sum of the distance vectors corresponding to the plurality of adjacent grids includes:
[0234] Calculate the sum of the distance unit vector and the real-time distance vector to obtain a comprehensive distance vector corresponding to the current grid;
[0235] The comprehensive distance vector is normalized to obtain the target flow direction of the fluid in the current grid.
[0236] In the disclosed embodiment, for multiple adjacent grids except for the grid closest to the grid, the distance between each remaining adjacent grid and the current grid can be calculated in turn; then the sum of the distance unit vector and the real-time distance vector of each remaining adjacent grid is calculated to obtain the comprehensive distance vector corresponding to the current grid; and then the comprehensive distance vector is standardized to obtain the target flow direction of the fluid in the current grid.
[0237] In the disclosed embodiment, the influence of the distances in all directions around the current grid on the overall weight is fully considered, and the sum of the distance vectors in all directions is calculated, so that the formed vector field is no longer so "straight" but has some curvature, thereby improving the accuracy of determining the target flow direction.
[0238] In the present disclosure, Figure 5 As shown, generating the flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map includes:
[0239] S2091: Transmitting the height map, the heat map, and the flow direction map into a graphics processor, where the graphics processor includes an r channel, a g channel, and a ba channel;
[0240] S2093: Determine first filling data of the r channel based on the height map;
[0241] S2095: Determine second filling data for the g channel based on the heat map;
[0242] S2097: Determine third filling data of the ba channel based on the flow direction map;
[0243] S2099: Based on the graphics processor, fill the first filling data into the r channel, fill the second filling data into the g channel, and fill the third filling data into the ba channel to generate a flow simulation diagram of the fluid.
[0244] In the disclosed embodiment, the height map, the heat map and the flow direction map can all be generated in a central processing unit (CPU) and then transmitted to a graphics processing unit (GPU). The graphics processing unit may include an r channel, a g channel and a ba channel; wherein the ba channel includes two channels, namely, a b channel and an a channel; the first filling data of the r channel can be determined according to the height map; the second filling data of the g channel can be determined according to the heat map; the third filling data of the ba channel can be determined according to the flow direction map; thereby generating a flow simulation diagram of the fluid according to the filling data corresponding to each channel.
[0245] In the present disclosure, Figure 6As shown, determining the first filling data of the r channel based on the height map includes:
[0246] S20931: Determine the expected height of each grid at which the fluid flows based on the height map;
[0247] S20933: Determine a first height of the highest area and a second height of the lowest area in the fluid simulation area;
[0248] S20935: Determine first filling data of the r channel according to the first height, the second height, the height of the fluid flowing through each grid, and the expected height.
[0249] In the embodiment of the present disclosure, the expected height of the fluid flowing through each grid can be determined according to the height map, and the first height of the highest area and the second height of the lowest area in the fluid simulation area can be further determined according to the height map, and the first filling data can be calculated by the following formula:
[0250] The first filling data = the expected height of the current grid / (first height - second height + liquid level height).
[0251] In the embodiment of the present disclosure, determining the second filling data of the g channel based on the heat map includes:
[0252] Determining, according to the thermal map, a flow cost of the fluid flowing through each grid and a maximum flow cost of the fluid simulation area;
[0253] The second filling data of the g channel is determined according to the flow cost of the fluid flowing through each grid and the maximum flow cost of the fluid simulation area.
[0254] In the embodiment of the present disclosure, the calculation formula of the second filling data is as follows:
[0255] The second filling data = the flow cost of the current grid / the maximum flow cost of the fluid simulation area.
[0256] In the embodiment of the present disclosure, determining the third filling data of the ba channel based on the flow direction map includes:
[0257] Determining the flow direction of the fluid along the x-axis and the flow direction along the z-axis according to the flow direction diagram;
[0258] Determining filling data of channel b in channel ba according to the flow direction of the fluid along the x-axis;
[0259] Determining filling data of channel a in channel ba according to the flow direction of the fluid along the z-axis;
[0260] The filling data of the b channel and the filling data of the a channel are determined as the third filling data of the ba channel.
[0261] In the disclosed embodiment, the flow direction diagram can be analyzed to obtain the flow direction of the fluid along the x-axis and the flow direction along the z-axis; assuming that the current flow vector of the current grid is flowVec, then: b = flowVec.x 0.5 + 0.5; a = flowVec.y 0.5 + 0.5. Finally, the calculated unit vector is uniformly converted from the range of -1 to 1 to data in the range of 0 to 1. Thus, the filling data of the b channel in the ba channel and the filling data of the a channel in the ba channel are determined.
[0262] In the disclosed embodiment, the height map, the thermal map and the flow direction map can be transmitted to the graphics processor, so that the filling data of the r channel, the g channel and the ba channel in the graphics processor can be quickly determined based on these three types of maps, thereby realizing the rapid and accurate generation of the fluid flow simulation map.
[0263] In the embodiment of the present disclosure, generating the flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map includes:
[0264] determining a target height of a vertex in the fluid based on the height map, and determining a current flow process of the fluid based on the thermal map;
[0265] Determining a height offset according to the current flow process of the fluid and the flow direction diagram, and adjusting the target height of the vertex according to the height offset to obtain an updated target height of the vertex;
[0266] When the vertex moves in a quasi-circular motion with the wave, the waveform parameters in the running process are fused to obtain fused waveform parameters;
[0267] A flow simulation diagram of the fluid is generated according to the updated target height of the vertex and the fused waveform parameters.
[0268] In the disclosed embodiment, fluid flow is a dynamic effect, and the simulation effect cannot be achieved only by normal mapping. Ultimately, the flow effect is achieved mainly by making various changes to the vertices in the vertex shader, as follows:
[0269] The target height of the vertex can be known from the height map, and the current flow process can be calculated based on the thermal map to adjust the height. At the same time, when the fluid rises, the rising speed of the fluid must also be considered, so the height offset of the fluid caused by impact and rise is finally calculated; the vertex makes a quasi-circular motion with the waves, and the fusion of multiple waveform (wave) parameters can achieve better results. Waveform parameters refer to various parameters that describe the characteristics of the waveform, which may include amplitude, period, frequency, phase, wave speed, wavelength, power, etc. In the case where the vertex makes a quasi-circular motion with the waves, the waveform parameters in the running process are fused to obtain fused waveform parameters; thus, according to the updated target height of the vertex and the fused waveform parameters, a flow simulation diagram of the fluid is generated.
[0270] In the disclosed embodiment, the height offset of the vertex position in the fluid can be accurately calculated through the height map and the thermal map, thereby improving the simulation accuracy of the vertex fluctuation in the fluid.
[0271] In the disclosed embodiment, generating the flow simulation diagram of the fluid according to the updated target height of the vertex and the fused waveform parameter includes:
[0272] Generate a vertex change graph according to the updated target height of the vertex and the fused waveform parameters;
[0273] determining the impact progress of vertices in the fluid according to the thermal map;
[0274] Generate wavefront spray according to the impact process of the vertex and the screen depth;
[0275] A flow simulation diagram of the fluid is generated according to the vertex change diagram and the wave front ripples.
[0276] Exemplarily, generating wavefront spray according to the impact process of the vertex and the screen depth may include:
[0277] A foam map is constructed according to the impact process of the vertex and the screen depth; and the fluid color and the foam color are interpolated based on the foam map to generate wavefront spray.
[0278] In the disclosed embodiment, for the water flow in the fluid, the waves at the front of the flow are very obvious, because the impact force is the earliest and most obvious when it contacts other materials. Through the previous heat map, it can be obtained whether each vertex is just beginning to impact, and the relevant pixels can be specially processed based on this information. For more realism, the screen depth can be calculated, and after obtaining the edge area of the water head, a specific foam map is used, the foam channel is multiplied by the mask, and then the water color and the foam color are interpolated to generate wavefront spray.
[0279] In the disclosed embodiment, the wave front ripples in the fluid motion process can be accurately generated through the thermal map, thereby improving the authenticity of the fluid flow simulation map.
[0280] In the disclosed embodiment, generating the flow simulation diagram of the fluid according to the vertex change diagram and the wave front spray includes:
[0281] determining edge fluid based on the thermal map, and simulating white foam of the edge fluid based on Perlin noise;
[0282] A flow simulation diagram of the fluid is generated according to the vertex change diagram, the wave front ripples and the white foam of the edge fluid.
[0283] In the disclosed embodiment, the edge fluid can be determined according to the thermal map, and the white foam of the edge fluid can be simulated based on Perlin noise; finally, a flow simulation diagram of the fluid is generated according to the vertex change map, the wave front ripples and the white foam of the edge fluid; for the water flow in the fluid, some edge white foam can be added to the edge fluid that is not the wave head to increase the three-dimensional sense of water shaking, and Perlin noise (perlinNoise) can be used to simulate the white foam of water.
[0284] In the disclosed embodiment, the white foam of the edge fluid can be accurately simulated by the thermal map, thereby further improving the authenticity of the fluid flow simulation map.
[0285] In the disclosed embodiment, generating the flow simulation diagram of the fluid according to the vertex change diagram, the wave front spray and the white foam of the edge fluid includes:
[0286] Determining the advancing time of a target wave having a surge amplitude greater than a preset amplitude according to the current flow process of the fluid;
[0287] Determine the circular motion diameter and y-axis offset corresponding to the vertex of the target wave;
[0288] According to the advancing time, circular motion diameter and y-axis offset of the target wave, the color of the wave front spray is superimposed on the target wave to generate a wave highlight image;
[0289] A flow simulation diagram of the fluid is generated according to the vertex change diagram, the wave front spray, the white foam of the edge fluid and the wave highlight diagram.
[0290] In the disclosed embodiment, the waves near the outlet are relatively large, and the current flow process of the fluid can be determined according to the flow direction diagram, so as to determine the target wave with a surge amplitude greater than the preset amplitude; then, according to the advance time, circular motion diameter and y-axis offset of the target wave, the wave front spray color is superimposed on the target wave to generate a wave highlight map. For example, for floods, there are generally multiple waves with roughly regular wave crest surges, so some large waves are also required here, that is, target waves with a surge amplitude greater than the preset amplitude. The advance time of the large wave can be calculated according to the flow time, and the Gerstner Wave can be used to simulate the large wave. The Gerstner Wave is a way to simulate the surface waveform of the water body, which belongs to a linear waveform superposition method. There is also a sine wave in the same water body simulation method. Using Fourier's idea to understand that any periodic function can be regarded as the superposition of sine waves with different amplitudes and different phases. The real complex water body waveform simulation can be regarded as a combination of single different Gerstner Waves. In theory, the more superimposed waves, the better the simulation effect. However, the diameter of the circular motion of the vertex of the large wave will be very large, forming a feeling of the wave beating back and forth. At the same time, the y offset of large waves should be limited to greater than zero, and a layer of wavefront color can be superimposed on the basis of the large waves to highlight the color.
[0291] In the disclosed embodiment, a wave highlight map can be accurately generated according to the flow direction map, thereby further improving the authenticity of the fluid flow simulation map.
[0292] In the disclosed embodiment, the calculation of Runtime reduces the production cost and price of art resources, and can be calculated in real time according to different terrains, which also increases the richness and authenticity of the game. By combining the vector field pathfinding solution, the amount of calculation of fluid simulation is reduced to a level acceptable to Runtime, and the fluid simulation requirements for occasions with strict performance requirements are effectively solved; the effect of water flow simulation on the GPU side can also make up for the artistic effect of non-particle simulation and reduce the simulation cost while ensuring the authenticity of the simulation effect.
[0293] This embodiment can be connected to different projects. The CPU-side solution is irrelevant to the rendering effect. The GPU-side solution is also compatible with most water performance solutions; and it is adapted to different scenes and different terrains, without the need for additional preparation; and the amount of calculation is low. This solution is a fluid simulation based on pathfinding, so the runtime cost fully meets the requirements of most occasions.
[0294] Figure 7 is a block diagram of a device for generating a fluid simulation diagram according to an exemplary embodiment. Figure 7 , the device comprises:
[0295] The information acquisition module 710 is configured to acquire a specified area, a specified flow time, and a specified flow direction of the fluid in an initial grid, and divide the specified area into a plurality of grids; the initial grid is determined based on scene information of the fluid simulation area;
[0296] The expected height determination module 720 is configured to determine the expected height of the fluid in each grid according to the scene information of the fluid simulation area; and construct a height map according to the expected height of the fluid in each grid;
[0297] The heat map construction module 730 is configured to determine the predicted time for the fluid to arrive at each grid according to the specified flow time; and construct a heat map according to the predicted time for the fluid to arrive at each grid;
[0298] The flow direction diagram construction module 740 is configured to determine the flow direction of the fluid in each grid according to the specified flow direction; and construct a flow direction diagram according to the flow direction of the fluid in each grid;
[0299] The flow simulation diagram construction module 750 is configured to generate a flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map.
[0300] In an exemplary embodiment, the desired height determination module includes:
[0301] A liquid level determination unit, configured to determine the ground height of each grid and the liquid level of the fluid in each grid according to the scene information of the fluid simulation area;
[0302] The expected height determination unit is configured to calculate the sum of the ground height and the liquid level height corresponding to each grid to obtain the expected height of the fluid in each grid.
[0303] In an exemplary embodiment, the liquid level determination unit comprises:
[0304] A ground height determination subunit is configured to determine the ground height of each grid according to the scene information and coordinate information of the fluid simulation area;
[0305] a distance determination subunit, configured to determine a first distance between each grid and the liquid outlet and a second distance between each grid and the edge of the fluid according to scene information of the fluid simulation area;
[0306] The liquid level determination subunit is configured to determine the liquid level of the fluid in each grid according to the first distance and the second distance corresponding to each grid; wherein the liquid level decreases as the first distance increases and increases as the second distance increases.
[0307] In an exemplary embodiment, the heat map construction module includes:
[0308] A height cost determination unit, configured to determine a height cost for the fluid to reach each grid according to an expected height of the fluid at each grid;
[0309] A terrain determination unit, configured to determine the terrain corresponding to each grid according to the scene information of the fluid simulation area;
[0310] A terrain cost determination unit is configured to determine the terrain cost of each grid according to the terrain corresponding to each grid;
[0311] The predicted time determination unit is configured to determine the predicted time when the fluid reaches each grid according to the designated flow time, the height cost of the fluid reaching each grid, and the terrain cost of each grid.
[0312] In an exemplary implementation, the prediction time determination unit is further configured to sequentially traverse each grid in the initial grid, and for each current grid traversed, perform the following operations:
[0313] Determine adjacent grids of the current grid in the initial grid;
[0314] Determine the flow cost of the fluid flowing from the current grid to the adjacent grid according to the height cost of the fluid flowing from the current grid to the adjacent grid and the terrain cost;
[0315] The predicted time for the fluid to arrive at each grid is determined according to the designated flow time and the flow cost of the fluid flowing from the current grid to the adjacent grid.
[0316] In an exemplary embodiment, the flow direction map building module includes:
[0317] A screening unit is configured to screen out a grid with the lowest flow cost from the plurality of adjacent grids according to the flow cost from the current grid to each adjacent grid as a screened adjacent grid;
[0318] A distance unit vector construction unit is configured to execute construction of a distance unit vector between the current grid and the selected adjacent grid;
[0319] A distance calculation unit, configured to calculate the distance between the current grid and each adjacent grid;
[0320] a distance vector determining unit, configured to determine a distance vector from the current grid to each adjacent grid according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and each adjacent grid;
[0321] The target flow direction determining unit is configured to determine the target flow direction of the fluid in the current grid according to the sum of the distance vectors corresponding to each of the plurality of adjacent grids.
[0322] In an exemplary embodiment, the distance vector determining unit includes:
[0323] A remaining grid determination subunit is configured to execute the process of taking the grids among the plurality of adjacent grids except the screened adjacent grids as remaining adjacent grids;
[0324] A real-time distance vector determination subunit is configured to determine a real-time distance vector between the current grid and the remaining adjacent grids according to a distance unit vector pointing from the current grid to the screened adjacent grid and a distance between the current grid and the remaining adjacent grids;
[0325] The target flow direction determination unit comprises:
[0326] A comprehensive distance vector determination subunit is configured to calculate the sum of the distance unit vector and the real-time distance vector to obtain a comprehensive distance vector corresponding to the current grid;
[0327] The target flow direction determination subunit is configured to perform normalization processing on the comprehensive distance vector to obtain the target flow direction of the fluid in the current grid.
[0328] In an exemplary embodiment, the flow simulation diagram construction module includes:
[0329] A data input unit is configured to input the height map, the heat map and the flow direction map into a graphics processor, wherein the graphics processor includes an r channel, a g channel and a ba channel;
[0330] A first data determining unit is configured to determine first filling data of the r channel based on the height map;
[0331] A second data determination unit is configured to determine second filling data of the g channel based on the heat map;
[0332] A third data determination unit is configured to determine third filling data of the ba channel based on the flow direction map;
[0333] The simulation diagram generating unit is configured to execute, based on the graphics processor, filling the first filling data into the r channel, filling the second filling data into the g channel, and filling the third filling data into the ba channel to generate a flow simulation diagram of the fluid.
[0334] In an exemplary embodiment, the first data determination unit includes:
[0335] an expected height determination subunit, configured to determine an expected height of the fluid flowing through each grid based on the height map;
[0336] A height determination subunit, configured to determine a first height of a highest area and a second height of a lowest area in the fluid simulation area;
[0337] The first data determination subunit is configured to determine first filling data of the r channel according to the first height, the second height, the height of the fluid flowing through each grid, and the expected height.
[0338] In an exemplary embodiment, the second data determination unit includes:
[0339] A flow cost determination subunit, configured to determine the flow cost of the fluid flowing through each grid and the maximum flow cost of the fluid simulation area according to the thermal map;
[0340] The second data determination subunit is configured to determine the second filling data of the g channel according to the flow cost of the fluid flowing through each grid and the maximum flow cost of the fluid simulation area.
[0341] In an exemplary implementation, the third data determination unit includes:
[0342] a flow direction determination subunit, configured to determine the flow direction of the fluid along the x-axis and the flow direction along the z-axis according to the flow direction diagram;
[0343] A first filling data determination subunit is configured to determine filling data of channel b in channel ba according to a flow direction of the fluid along the x-axis;
[0344] A second filling data determination subunit is configured to determine the filling data of the a channel in the ba channel according to the flow direction of the fluid along the z-axis;
[0345] The third filling data determining subunit is configured to determine the filling data of the b channel and the filling data of the a channel as the third filling data of the ba channel.
[0346] In an exemplary embodiment, the flow simulation diagram construction module includes:
[0347] a flow process determination unit configured to determine a target height of a vertex in the fluid according to the height map, and to determine a current flow process of the fluid according to the thermal map;
[0348] a height updating unit, configured to determine a height offset according to a current flow process of the fluid and the flow direction diagram, and adjust a target height of the vertex according to the height offset to obtain an updated target height of the vertex;
[0349] A parameter fusion unit is configured to fuse the waveform parameters in the running process to obtain fused waveform parameters when the vertex moves in a quasi-circular motion with the wave;
[0350] The simulation diagram generating unit is configured to generate a flow simulation diagram of the fluid according to the updated target height of the vertex and the fused waveform parameters.
[0351] In an exemplary embodiment, the simulation diagram generating unit includes:
[0352] A vertex change graph generating subunit is configured to generate a vertex change graph according to the updated target height of the vertex and the fused waveform parameter;
[0353] an impact process determination subunit, configured to execute an impact process for determining vertices in the fluid according to the thermal map;
[0354] A wavefront spray sub-generation unit is configured to generate wavefront spray according to the impact process of the vertex and the screen depth;
[0355] The simulation graph generating subunit is configured to generate a flow simulation graph of the fluid according to the vertex change graph and the wave front ripples.
[0356] In an exemplary embodiment, the simulation diagram generating subunit includes:
[0357] A white foam simulation subunit, configured to determine the edge fluid based on the thermal map, and simulate the white foam of the edge fluid based on Perlin noise;
[0358] The graph simulation subunit is configured to generate a flow simulation graph of the fluid based on the vertex change graph, the wave front ripples and the foam of the edge fluid.
[0359] In an exemplary embodiment, the graph simulation subunit includes:
[0360] an advancement time determination subunit, configured to determine the advancement time of a target wave having a surge amplitude greater than a preset amplitude according to a current flow process of the fluid;
[0361] an offset determination subunit, configured to determine a circular motion diameter and a y-axis offset corresponding to the vertex of the target wave;
[0362] A wave highlight image generating subunit is configured to generate a wave highlight image by superimposing the wave front spray color on the target wave according to the advancing time, the circular motion diameter and the y-axis offset of the target wave;
[0363] The flow simulation graph generating subunit is configured to generate a flow simulation graph of the fluid according to the vertex change graph, the wave front ripples, the white foam of the edge fluid and the wave highlight graph.
[0364] In an exemplary embodiment, the information acquisition module includes:
[0365] A scene information acquisition unit is configured to determine the fluid simulation area and acquire scene information of the fluid simulation area; the scene information includes height information, rectangular area, number of pixels, flow direction and flow terrain addition;
[0366] The designated information determination unit is configured to determine the designated area, designated flow time and designated flow direction of the fluid in the initial grid according to the scene information of the fluid simulation area.
[0367] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0368] In an exemplary embodiment, an electronic device is also provided, comprising a processor; and a memory for storing instructions executable by the processor; wherein, when the processor is configured to execute the instructions stored in the memory, the method for generating a fluid simulation diagram provided in any of the above embodiments is implemented.
[0369] The electronic device may be a terminal, a server or a similar computing device. For example, the electronic device is a server. Figure 8 is a block diagram of an electronic device according to an exemplary embodiment. Figure 8As shown, the server 800 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 810 (the processor 810 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 830 for storing data, and one or more storage media 820 (such as one or more mass storage devices) for storing application programs 823 or data 822. Among them, the memory 830 and the storage medium 820 can be short-term storage or permanent storage. The program stored in the storage medium 820 may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, the central processing unit 810 can be configured to communicate with the storage medium 820 and execute a series of instruction operations in the storage medium 820 on the server 800. The server 800 may also include one or more power supplies 860, one or more wired or wireless network interfaces 850, one or more input and output interfaces 840, and / or one or more operating systems 821, such as Windows ServerTM, Mac OSXTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0370] The input / output interface 840 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the server 800. In one example, the input / output interface 840 includes a network adapter (Network Interface Controller, NIC), which may be connected to other network devices via a base station so as to communicate with the Internet. In one example, the input / output interface 840 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0371] It can be understood by those skilled in the art that Figure 8 The structure shown is for illustration only and does not limit the structure of the above electronic device. Figure 8 More or fewer components as shown, or with Figure 8 Different configurations shown.
[0372] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 830 including instructions, and the instructions can be executed by the processor 810 of the device 800 to complete the above method. Alternatively, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0373] In an exemplary embodiment, a computer program product is also provided, including a computer program, which, when executed by a processor, implements the method for generating a fluid simulation diagram provided in any of the above embodiments.
[0374] Fig. 9 is a block diagram of an electronic device for generating a fluid simulation diagram according to an exemplary embodiment. The electronic device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig. 9 As shown. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for generating a fluid simulation diagram is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a key, trackball or touchpad provided on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.
[0375] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present disclosure, and does not constitute a limitation on the electronic device to which the scheme of the present disclosure is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0376] The present disclosure obtains the specified area, specified flow time and specified flow direction of the fluid flowing in the initial grid, and divides the specified area into multiple grids; the initial grid is determined based on the scene information of the fluid simulation area; according to the scene information of the fluid simulation area, the expected height of the fluid in each grid is determined; and according to the expected height of the fluid in each grid, a height map is constructed; according to the specified flow time, the predicted time for the fluid to reach each grid is determined; and according to the predicted time for the fluid to reach each grid, a thermal map is constructed; according to the specified flow direction, the flow direction of the fluid in each grid is determined; and according to the flow direction of the fluid in each grid, a flow direction map is constructed; according to the height map, the thermal map and the flow direction map, a flow simulation map of the fluid is generated. The present disclosure can quickly and accurately construct a height map, a thermal map and a flow direction map of the fluid simulation area according to the scene information of the fluid simulation area, thereby improving the simulation efficiency, accuracy and authenticity of the flow simulation map of the fluid. And the present disclosure does not need to construct separate terrain data for different terrains, reducing the cost of fluid simulation.
[0377] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0378] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0379] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for generating a fluid simulation diagram, characterized in that: include: Acquire a specified area, a specified flow time, and a specified flow direction of the fluid in the initial grid, and divide the specified area into a plurality of grids; The initial grid is determined based on scene information of the fluid simulation area; Determining the expected height of the fluid in each grid according to the scene information of the fluid simulation area; and constructing a height map according to the expected height of the fluid in each grid; Determining a predicted time for the fluid to reach each grid according to the specified flow time; and constructing a thermal map according to the predicted time for the fluid to reach each grid; Determine the flow direction of the fluid in each grid according to the specified flow direction; and construct a flow direction diagram according to the flow direction of the fluid in each grid; A flow simulation diagram of the fluid is generated according to the height map, the thermal map and the flow direction map.
2. The method according to claim 1, characterized in that: The step of determining the expected height of the fluid in each grid according to the scene information of the fluid simulation area includes: Determining the ground height of each grid and the liquid level height of the fluid in each grid according to the scene information of the fluid simulation area; The sum of the ground height and the liquid level height corresponding to each grid is calculated to obtain the expected height of the fluid in each grid.
3. The method according to claim 2, characterized in that Determining the ground height of each grid and the liquid level height of the fluid in each grid according to the scene information of the fluid simulation area includes: Determining the ground height of each grid according to the scene information and coordinate information of the fluid simulation area; Determining, according to the scene information of the fluid simulation area, a first distance between each grid and the liquid outlet and a second distance between each grid and the edge of the fluid; The liquid level of the fluid in each grid is determined according to the first distance and the second distance corresponding to each grid; wherein the liquid level decreases as the first distance increases and increases as the second distance increases.
4. The method according to claim 1, characterized in that: Determining the predicted time for the fluid to reach each grid according to the specified flow time includes: Determine the height cost of the fluid to reach each grid according to the expected height of the fluid in each grid; Determining the terrain corresponding to each grid according to the scene information of the fluid simulation area; Determine the terrain cost of each grid based on the terrain corresponding to each grid; The predicted time for the fluid to reach each grid is determined according to the designated flow time, the height cost for the fluid to reach each grid, and the terrain cost of each grid.
5. The method according to claim 4, characterized in that Determining the predicted time for the fluid to reach each grid according to the specified flow time, the height cost of the fluid reaching each grid, and the terrain cost of each grid, comprises: Each grid in the initial grid is traversed in turn, and the following operations are performed for each current grid traversed: Determine adjacent grids of the current grid in the initial grid; Determine the flow cost of the fluid flowing from the current grid to the adjacent grid according to the height cost of the fluid flowing from the current grid to the adjacent grid and the terrain cost; The predicted time for the fluid to arrive at each grid is determined according to the designated flow time and the flow cost of the fluid flowing from the current grid to the adjacent grid.
6. The method according to claim 5, characterized in that The current grid corresponds to a plurality of adjacent grids, and determining the flow direction of the fluid in each grid according to the specified flow direction includes: According to the flow cost from the current grid to each adjacent grid, a grid with the lowest flow cost is selected from the plurality of adjacent grids as a selected adjacent grid; Constructing a distance unit vector between the current grid and the selected adjacent grid; Calculating the distance between the current grid and each adjacent grid; Determine a distance vector from the current grid to each adjacent grid according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and each adjacent grid; The target flow direction of the fluid in the current grid is determined according to the sum of the distance vectors corresponding to the plurality of adjacent grids.
7. The method according to claim 6, characterized in that The step of determining the distance vector from the current grid to each adjacent grid according to the distance unit vector from the current grid to the selected adjacent grid and the distance between the current grid and each adjacent grid comprises: Taking the grids among the plurality of adjacent grids except the screened adjacent grid as the remaining adjacent grids; Determine a real-time distance vector between the current grid and the remaining adjacent grids according to a distance unit vector from the current grid to the selected adjacent grid and a distance between the current grid and the remaining adjacent grids; The step of determining the target flow direction of the fluid in the current grid according to the sum of the distance vectors corresponding to the plurality of adjacent grids includes: Calculate the sum of the distance unit vector and the real-time distance vector to obtain a comprehensive distance vector corresponding to the current grid; The comprehensive distance vector is normalized to obtain the target flow direction of the fluid in the current grid.
8. The method according to claim 1, characterized in that Generating a flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map includes: The height map, the heat map and the flow direction map are transmitted to a graphics processor, wherein the graphics processor includes an r channel, a g channel and a ba channel; Determine first filling data for the r channel based on the height map; Determining second filling data for the g channel based on the heat map; Determining third filling data of the ba channel based on the flow direction map; Based on the graphics processor, the first filling data is filled into the r channel, the second filling data is filled into the g channel, and the third filling data is filled into the ba channel to generate a flow simulation diagram of the fluid.
9. The method according to claim 8, characterized in that The determining the first filling data of the r channel based on the height map comprises: Determining the expected height of each grid at which the fluid flows based on the height map; Determine a first height of the highest area and a second height of the lowest area in the fluid simulation area; The first filling data of the r channel is determined according to the first height, the second height, the height of the fluid flowing through each grid, and the expected height.
10. The method according to claim 8, characterized in that The determining the second filling data of the g channel based on the heat map includes: Determining, according to the thermal map, a flow cost of the fluid flowing through each grid and a maximum flow cost of the fluid simulation area; The second filling data of the g channel is determined according to the flow cost of the fluid flowing through each grid and the maximum flow cost of the fluid simulation area.
11. The method according to claim 8, characterized in that The determining, based on the flow direction map, third filling data of the ba channel comprises: Determining the flow direction of the fluid along the x-axis and the flow direction along the z-axis according to the flow direction diagram; Determining filling data of channel b in channel ba according to the flow direction of the fluid along the x-axis; Determining filling data of channel a in channel ba according to the flow direction of the fluid along the z-axis; The filling data of the b channel and the filling data of the a channel are determined as the third filling data of the ba channel.
12. The method according to claim 1, characterized in that Generating a flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map includes: determining a target height of a vertex in the fluid based on the height map, and determining a current flow process of the fluid based on the thermal map; Determining a height offset according to the current flow process of the fluid and the flow direction diagram, and adjusting the target height of the vertex according to the height offset to obtain an updated target height of the vertex; When the vertex moves in a quasi-circular motion with the wave, the waveform parameters in the running process are fused to obtain fused waveform parameters; A flow simulation diagram of the fluid is generated according to the updated target height of the vertex and the fused waveform parameters.
13. The method according to claim 12, characterized in that The step of generating a flow simulation diagram of the fluid according to the updated target height of the vertex and the fused waveform parameter comprises: Generate a vertex change graph according to the updated target height of the vertex and the fused waveform parameters; determining the impact progress of vertices in the fluid according to the thermal map; Generate wavefront spray according to the impact process of the vertex and the screen depth; A flow simulation diagram of the fluid is generated according to the vertex change diagram and the wave front ripples.
14. The method according to claim 13, characterized in that The step of generating a flow simulation diagram of the fluid according to the vertex change diagram and the wave front spray comprises: determining edge fluid based on the thermal map, and simulating white foam of the edge fluid based on Perlin noise; A flow simulation diagram of the fluid is generated according to the vertex change diagram, the wave front ripples and the white foam of the edge fluid.
15. The method according to claim 14, characterized in that The generating of the flow simulation diagram of the fluid according to the vertex change diagram, the wave front spray and the white foam of the edge fluid comprises: Determining the advancing time of a target wave having a surge amplitude greater than a preset amplitude according to the current flow process of the fluid; Determine the circular motion diameter and y-axis offset corresponding to the vertex of the target wave; According to the advancing time, circular motion diameter and y-axis offset of the target wave, the color of the wave front spray is superimposed on the target wave to generate a wave highlight image; A flow simulation diagram of the fluid is generated according to the vertex change diagram, the wave front spray, the white foam of the edge fluid and the wave highlight diagram.
16. The method according to claim 1, characterized in that The step of obtaining a specified area, a specified flow time, and a specified flow direction of the fluid flowing in the initial grid includes: Determine the fluid simulation area, and obtain scene information of the fluid simulation area; the scene information includes height information, rectangular area, number of pixels, flow direction and flow terrain addition; According to the scene information of the fluid simulation area, the designated area, designated flow time and designated flow direction of the fluid in the initial grid are determined.
17. A device for generating a fluid simulation diagram, characterized in that: include: An information acquisition module is configured to acquire a specified area, a specified flow time, and a specified flow direction of a fluid flowing in an initial grid, and divide the specified area into a plurality of grids; the initial grid is determined based on scene information of a fluid simulation area; An expected height determination module is configured to determine an expected height of the fluid in each grid according to scene information of the fluid simulation area; and construct a height map according to the expected height of the fluid in each grid; A heat map construction module is configured to determine the predicted time for the fluid to arrive at each grid according to the specified flow time; and construct a heat map according to the predicted time for the fluid to arrive at each grid; A flow direction diagram construction module is configured to determine the flow direction of the fluid in each grid according to the specified flow direction; and construct a flow direction diagram according to the flow direction of the fluid in each grid; The flow simulation diagram construction module is configured to generate a flow simulation diagram of the fluid according to the height map, the thermal map and the flow direction map.
18. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the instructions to implement the method for generating a fluid simulation diagram as described in any one of claims 1-16.
19. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for generating a fluid simulation diagram as described in any one of claims 1 to 16.
20. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the method for generating a fluid simulation diagram according to any one of claims 1 to 16 is implemented.