River flow velocity processing method and device, electronic equipment and storage medium
By generating and projecting a river surface model, calculating the river width, depth, and slope, and determining the water flow velocity based on mathematical formulas, this approach solves the problems of high time consumption and resource consumption in existing technologies, and achieves efficient river flow velocity processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU SNAP FINGER UNIVERSE TECH CO LTD
- Filing Date
- 2025-12-09
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, methods that rely on manually drawing flow direction maps or simple linear interpolation to determine river flow velocity are time-consuming and difficult to adapt to complex terrains. Fluid dynamics simulation consumes a lot of computing resources and is not suitable for real-time rendering or interactively generated game scenes.
By acquiring a preset river curve, an initial river surface model is generated and projected onto the terrain surface. The river width, depth, and slope at each vertex are determined. Based on these attributes, the actual water flow velocity is calculated, and the flow velocity is generated using normalized direction vectors and mathematical formulas.
It achieves physically consistent flow velocity generation based on terrain data, reduces manual intervention, improves river generation efficiency, adapts to any scene terrain, and is suitable for real-time rendering and dynamic adjustment of open world or large-scale PCG scenes.
Smart Images

Figure CN121997794A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of computer graphics and game development technology, and in particular to a method, apparatus, electronic device and storage medium for processing river flow velocity. Background Technology
[0002] In game river systems using related technologies, the direction and velocity of water flow are typically set by manually drawing flow direction maps or through simple linear interpolation. To improve accuracy, related technologies also employ fluid dynamics simulation to determine the direction and velocity of water flow.
[0003] However, relying on manually drawing flow maps or determining flow through simple linear interpolation is not only time-consuming but also difficult to adapt to complex terrain. Using fluid dynamics simulations consumes significant computational resources and is unsuitable for real-time rendering or interactively generated game scenes. Summary of the Invention
[0004] This disclosure provides a method, apparatus, electronic device, and storage medium for processing river flow velocity, at least addressing the problems of related technologies that rely on manually drawing flow direction maps or determining flow velocity through simple linear interpolation, which are not only time-consuming but also difficult to adapt to complex terrain. Using fluid dynamics simulation consumes significant computational resources and is unsuitable for real-time rendering or interactively generated game scenes. The technical solution of this disclosure is as follows: According to a first aspect of the present disclosure, a method for processing river flow velocity is provided, comprising: Obtain a preset river curve; generate an initial river surface model based on the preset river curve; The initial river surface model is projected onto the terrain surface; Obtain the terrain region covered by the initial river surface model in the terrain surface, and convert the terrain region into a mesh to obtain the updated river surface model; Determine the river width and river depth at each vertex of the updated river surface model, and determine the river slope at each vertex of the updated river surface model; The actual water flow velocity at each vertex is determined based on the river width, river depth, and river slope at each vertex. The actual water flow velocity information of each vertex is determined based on the normalized direction vector of each vertex and the actual water flow velocity of each vertex.
[0005] In an optional embodiment, the preset river curve includes a preset river width parameter, and generating an initial river surface model based on the preset river curve includes: At the starting point of the preset river curve or the origin of the world coordinate system, a cross-sectional curve is generated based on the preset river width parameter. The preset river curve is sampled to obtain a preset number of sampling points; Determine the tangential direction of each sampling point; The cross-sectional curve is copied at each sampling point, and the orientation of the cross-sectional curve at each sampling point is adjusted according to the tangent direction of each sampling point so that the orientation of the cross-sectional curve at each sampling point is consistent with the tangent direction of each sampling point. Connect the cross-sectional curves at each sampling point to obtain the initial river surface model.
[0006] In an optional embodiment, before generating the initial river surface model based on the preset river curve, the method further includes: Determine the gradient data of points on the preset river curve; After generating the initial river surface model based on the preset river curve, the method further includes: If it is determined that there is an overlapping area between the initial vertices in the initial river surface model in the vertical direction, the initial vertices located in the overlapping area are determined; the points on the preset river curve include the initial vertices; Determine the height difference between the initial vertices located in the overlapping region; Based on the height difference and the gradient data of the initial vertices located in the overlapping region, the height difference is merged to obtain a smoothed initial river surface model; the smoothed initial river surface model is used to project onto the terrain surface.
[0007] In an optional embodiment, determining the river width and river depth at each vertex of the updated river surface model includes: Obtain the attribute information of each vertex on the updated river surface model from the initial river surface model; Based on the attribute information of each vertex on the updated river surface model, the river width and river depth of each vertex on the updated river surface model are determined.
[0008] In an optional embodiment, obtaining the attribute information of each vertex on the updated river surface model from the initial river surface model includes: The target vertex is obtained by identifying the point in the vertical direction where the vertex in the updated river surface model intersects with the initial vertex in the initial river surface model. The attribute information of the target vertex on the initial river surface model is determined as the attribute information of the target vertex on the updated river surface model.
[0009] In an optional embodiment, the attribute information includes a normalized direction vector, and the step of determining the river width and river depth at each vertex of the updated river surface model based on the attribute information of each vertex on the updated river surface model includes: Rays are emitted vertically downwards from the position of each vertex to detect terrain collision points, thereby obtaining the river depth of the updated river surface model at each vertex; Using the perpendicular direction of the normalized direction vector of each vertex as a reference, emit a ray to each side to obtain the intersection points between the rays emitted from each side and the surface of the obstacle. The river width at each vertex is determined based on the distance between the reference point and the intersection points on both sides.
[0010] In an optional embodiment, the method further includes: Extract the intersection contour line of the intersection region between the updated river surface model and the obstacle, and determine the tangent direction of the vertex on the intersection contour line based on the surface normal of the obstacle; Identify the vertices on the updated river surface model that are adjacent to the vertices on the intersecting contour lines; Determine the angle between the tangent direction of the vertex on the intersecting contour line and the normalized direction vector of the adjacent vertex; When the included angle is greater than a preset angle, the tangent direction of the vertices on the intersecting contour lines is reversed to obtain an updated river surface model with corrected water flow direction; the updated river surface model with corrected water flow direction is used to determine the river width, river depth and river slope.
[0011] In an optional embodiment, determining the tangent direction of the vertices on the intersecting contour line based on the surface normal of the obstacle includes: Obtain obstacle coordinate information and obstacle identification information; the obstacle coordinate information is the coordinate information of candidate points on the obstacle whose distance to the vertex of the intersecting contour line is less than a preset distance threshold, and the obstacle identification information is the identification information of the face on the obstacle where the candidate points are located; Based on the obstacle coordinate information and the obstacle identification information, the surface normal of the face where the candidate point is located is sampled, and the sampled data is assigned to the vertices on the intersecting contour line to obtain the tangent direction of the vertices on the intersecting contour line.
[0012] In an optional embodiment, determining the river slope at each vertex on the updated river surface model includes: Determine the height difference between each vertex and a preset reference vertex, and determine the horizontal distance between each vertex and the preset reference vertex; the preset reference vertex and each vertex are within a preset area. The river slope at each vertex is obtained based on the height difference and the horizontal distance.
[0013] In an optional embodiment, determining the actual water flow velocity at each vertex based on the river width, river depth, and river slope at each vertex includes: Obtain the preset roughness coefficient; The hydraulic radius of each vertex is determined based on the river width and river depth of each vertex. The actual water flow velocity at each vertex is determined based on the hydraulic radius of each vertex, the river slope at each vertex, and the preset roughness coefficient.
[0014] According to a second aspect of the present disclosure, a river flow velocity processing device is provided, the device comprising: The preset river curve acquisition module is configured to acquire a preset river curve and generate an initial river surface model based on the preset river curve. The projection module is configured to project the initial river surface model onto the terrain surface; The model update module is configured to acquire the terrain region covered by the initial river surface model in the terrain surface, and convert the terrain region into a mesh to obtain the updated river surface model; The river information determination module is configured to determine the river width and river depth at each vertex of the updated river surface model, and to determine the river slope at each vertex of the updated river surface model. The water flow magnitude determination module is configured to determine the actual water flow velocity magnitude at each vertex based on the river width, river depth, and river slope at each vertex. The water flow velocity determination module is configured to perform a normalized direction vector for each vertex and the actual water flow velocity magnitude for each vertex to determine the actual water flow velocity information for each vertex.
[0015] In an optional embodiment, the preset river curve acquisition module includes: The cross-sectional curve generation unit is configured to generate a cross-sectional curve based on the preset river width parameter at the starting point or world coordinate origin of the preset river curve. The sampling unit is configured to perform sampling on the preset river curve to obtain a preset number of sampling points; A tangent direction determination unit is configured to determine the tangent direction of each of the sampling points; The cross-sectional curve processing unit is configured to perform the replication of the cross-sectional curve at each of the sampling points and adjust the orientation of the cross-sectional curve at each of the sampling points according to the tangent direction of each of the sampling points, so that the orientation of the cross-sectional curve at each of the sampling points is consistent with the tangent direction of each of the sampling points; The connection unit is configured to perform the connection of the cross-sectional curves on each of the sampling points to obtain the initial river surface model.
[0016] In an optional embodiment, the apparatus further includes: The data generation module is configured to determine gradient data for points on the preset river curve. Accordingly, the above methods also include: The overlapping vertex determination module is configured to determine the initial vertex located in the overlapping region when it is determined that the initial vertices in the initial river surface model have an overlapping region in the vertical direction; the points on the preset river curve include the initial vertices; The height difference determination module is configured to determine the height difference between initial vertices located in the overlapping region; The merging module is configured to merge the height difference based on the height difference and the gradient data of the initial vertices located in the overlapping region to obtain a smoothed initial river surface model; the smoothed initial river surface model is used to project onto the terrain surface.
[0017] In an optional embodiment, the river information determination module includes: The attribute information acquisition unit is configured to acquire the attribute information of each vertex on the updated river surface model from the initial river surface model; The width and depth determination unit is configured to determine the river width and river depth of each vertex on the updated river surface model based on the attribute information of each vertex on the updated river surface model.
[0018] In an optional embodiment, the attribute information acquisition unit includes: The target vertex determination subunit is configured to determine the point in the vertical direction where the vertex in the updated river surface model intersects with the initial vertex in the initial river surface model, thereby obtaining the target vertex; The target vertex processing subunit is configured to determine the attribute information of the target vertex on the initial river surface model as the attribute information of the target vertex on the updated river surface model.
[0019] In an optional embodiment, the width-depth determination unit includes: The depth determination subunit is configured to fire a ray vertically downward at the position of each vertex to detect terrain collision points and obtain the river depth of the updated river surface model at each vertex; The intersection point determination sub-unit is configured to execute a ray emitted to each side based on the perpendicular direction of the normalized direction vector of each vertex, thereby obtaining the intersection points between the rays emitted from each side and the surface of the obstacle. The width determination subunit is configured to determine the river width at each vertex based on the distance between the reference and the intersection points on both sides.
[0020] In an optional embodiment, the apparatus further includes: The vertex tangent direction determination module is configured to extract the intersection contour line of the intersection region between the updated river surface model and the obstacle, and determine the tangent direction of the vertex on the intersection contour line based on the surface normal of the obstacle; The adjacent vertex determination module is configured to determine the vertices on the updated river surface model that are adjacent to the vertices on the intersecting contour line; Angle determination module is configured to determine the angle between the tangent direction of a vertex on the intersecting contour line and the normalized direction vector of the adjacent vertex. The inversion module is configured to reverse the tangent direction of the vertices on the intersecting contour line when the included angle is greater than a preset angle, so as to obtain an updated river surface model with corrected water flow direction; the updated river surface model with corrected water flow direction is used to determine the river width, river depth and river slope.
[0021] In an optional embodiment, the vertex tangent direction determination module includes: The coordinate identification unit is configured to acquire obstacle coordinate information and obstacle identification information; the obstacle coordinate information is the coordinate information of candidate points on the obstacle whose distance to the vertex of the intersecting contour line is less than a preset distance threshold, and the obstacle identification information is the identification information of the face on the obstacle where the candidate points are located; The normal sampling unit is configured to sample the surface normal of the face where the candidate point is located based on the obstacle coordinate information and the obstacle identification information, assign the sampled data to the vertices on the intersecting contour line, and obtain the tangent direction of the vertices on the intersecting contour line.
[0022] In an optional embodiment, the river information determination module includes: The height distance determination unit is configured to determine the height difference between each vertex and a preset reference vertex, and to determine the horizontal distance between each vertex and the preset reference vertex; the preset reference vertex and each vertex are within a preset area. The river slope determination unit is configured to perform the operation of determining the river slope at each vertex based on the height difference and the horizontal distance.
[0023] In an optional embodiment, the water flow velocity determination module includes: The preset roughness coefficient acquisition unit is configured to acquire the preset roughness coefficient. The hydraulic radius determination unit is configured to determine the hydraulic radius of each vertex based on the river width and river depth of each vertex. The actual water flow velocity determination unit is configured to determine the actual water flow velocity of each vertex based on the hydraulic radius of each vertex, the river slope of each vertex, and the preset roughness coefficient.
[0024] According to a third aspect of the present disclosure, an electronic device for processing river flow velocity is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the river flow velocity processing method as described above.
[0025] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of a server, enables the server to perform the river flow rate processing method as described above.
[0026] According to a fifth aspect of the present disclosure, a computer program product is provided, the computer program product including a computer program stored in a readable storage medium, wherein at least one processor of a computer device reads from the readable storage medium and executes the computer program, causing the device to perform the above-described river flow velocity processing method.
[0027] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects: This disclosure provides a method for processing river flow velocity. The method involves: obtaining a preset river curve; generating an initial river surface model based on the preset river curve; projecting the initial river surface model onto a terrain surface; obtaining the terrain region covered by the initial river surface model on the terrain surface and converting the terrain region into a mesh to obtain an updated river surface model; determining the river width and river depth at each vertex of the updated river surface model, as well as the river slope at each vertex; determining the actual water flow velocity at each vertex based on the river width, river depth, and river slope at each vertex; and determining the actual water flow velocity information at each vertex based on the normalized direction vector and the actual water flow velocity at each vertex.
[0028] As can be seen, this disclosure calculates the flow velocity by using the geometric and terrain information (such as slope, actual river width, and actual depth) of the preset river curve through procedural content generation (PCG). Compared with traditional methods that use fixed velocity maps or offline simulation, this method achieves physically consistent flow velocity generation based on terrain data, reduces manual intervention, and improves river generation efficiency. Furthermore, this disclosure does not rely on complex fluid dynamics solutions; it can be completed through terrain sampling and mathematical formula calculations, consuming fewer computational resources and enabling real-time rendering. It is adaptable to river generation and dynamic adjustment in open-world or large-scale PCG scenes. In addition, this disclosure is applicable to any scene terrain and multi-river network structure, enabling batch generation and adaptive adjustment of river effects.
[0029] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0030] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0031] Figure 1 The example shown is merely one application environment of the river flow velocity processing method provided in this disclosure.
[0032] Figure 2 This is a flowchart illustrating a river flow velocity processing method according to an exemplary embodiment.
[0033] Figure 3 This is a schematic diagram illustrating a process for generating an initial river surface model according to an exemplary embodiment.
[0034] Figure 4This is a schematic diagram illustrating a process for determining the width and depth of a river according to an exemplary embodiment.
[0035] Figure 5 This is a flow velocity diagram illustrating the correction of water flow direction according to an exemplary embodiment.
[0036] Figure 6 This is a schematic diagram illustrating a process for determining the actual water flow velocity at each vertex, according to an exemplary embodiment.
[0037] Figure 7 This is a block diagram of a river flow velocity processing device according to an exemplary embodiment.
[0038] Figure 8 This is a block diagram illustrating an electronic device for processing river flow velocity according to an exemplary embodiment. Detailed Implementation
[0039] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0040] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar first objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0041] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0042] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating the application environment of a river flow velocity processing method according to an exemplary embodiment, such as... Figure 1 As shown, the application environment may include terminal 01 and server 02.
[0043] In an optional embodiment, server 02 can be used to generate actual water flow speed information. Exemplarily, server 02 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0044] In an optional embodiment, terminal 01 can be used to display the generated actual water flow velocity information. Specifically, terminal 01 can be, but is not limited to, electronic devices such as smartphones, desktop computers, tablets, laptops, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, and smart wearable devices. Terminal 01 is equipped with a resource processing platform terminal. Optionally, the operating system running on the electronic device can be, but is not limited to, Android, iOS, Linux, and Windows.
[0045] In addition, it should be noted that, Figure 1 The example shown is merely one application environment of the river flow velocity processing method provided in this disclosure. Other application environments may exist in other scenarios, and this disclosure does not limit them.
[0046] Figure 2 This is a flowchart illustrating a river flow velocity processing method according to an exemplary embodiment, such as... Figure 2 As shown, the execution target of this river flow velocity processing method is the server, and the method includes at least the following steps: In step S11, a preset river curve is obtained.
[0047] Optionally, the preset river curve can be edited and input into the server according to the actual game scene requirements. This disclosure does not limit the shape or size of the preset river curve.
[0048] It should be noted that the preset river curve can be at least one.
[0049] In step S12, an initial river surface model is generated based on a preset river curve.
[0050] In some embodiments, for each preset river curve, the server can use the sweep node in Houdini to generate an initial river surface model based on preset or input preset river width parameters. Optionally, the preset river width parameters can be included in the preset river curve or can be input separately to the server. Houdini refers to 3D animation and visual effects production software.
[0051] In other embodiments, the server may also use sample river curves as training data, use the real river surface model corresponding to the sample river curve as a label, pre-train a generative model of an initial river surface model, and then input the preset river curve into the trained model for prediction processing to obtain the initial river surface model corresponding to the preset river curve.
[0052] It should be noted that each initial vertex in the initial river surface model carries its own corresponding normalized direction vector. This normalized direction vector is determined by the tangent direction of each initial vertex and normalized to a unit vector. This normalized direction vector can represent the basic flow direction information of the river under ideal conditions.
[0053] Optionally, the calculation process for the normalized direction vector of each initial vertex includes: For the direction vector of an initial vertex that is not an endpoint: its direction vector is calculated by the position difference between the preceding and following initial vertices, that is, by subtracting the position of the preceding initial vertex from the position of the following initial vertex, a vector from the position of the following initial vertex to the position of the preceding initial vertex is obtained. This vector approximately represents the tangential direction at that initial vertex. Then, this vector is normalized.
[0054] For the direction vector of the initial vertex at the endpoint: Since there is no previous initial vertex, the position of the initial vertex can be subtracted from the position of the next initial vertex to obtain the vector of the initial vertex. This vector approximately represents the tangential direction at the initial vertex. Then, this vector is normalized.
[0055] For the direction vector of the initial vertex of the terminal: Since there is no subsequent initial vertex, we can use the position of this initial vertex and subtract the position of the previous initial vertex to obtain the vector of this initial vertex. This vector approximately represents the tangential direction at this initial vertex. Then, we normalize this vector.
[0056] Optionally, each initial vertex on the initial river surface model refers to a key discrete point that defines the river's geometry, location, and attributes. The initial vertices serve the following purposes: Geometric construction: Reconstruct the course of the river by using the positions and connections of the initial vertices.
[0057] Attribute carrying: It carries information such as elevation, flow direction, and flow velocity to support hydrological calculations and simulations.
[0058] Precision control: Balance model detail with computational efficiency by adjusting the initial number of vertices.
[0059] In step S13, the initial river surface model is projected onto the terrain surface.
[0060] In some embodiments, in order to make the river basin scene terrain fit, the server can project the initial river water surface model onto the terrain surface to perform projection and reconstruction of the river water surface and terrain.
[0061] It should be noted that if no terrain exists in the scene, a heightfield terrain layer with a height of zero is automatically created. The heightfield is a two-dimensional grid structure, where each grid point (or cell) stores the height value (Z-axis coordinate) at that location.
[0062] In step S14, the terrain area covered by the initial river surface model is obtained from the terrain surface, and the terrain area is converted into a mesh to obtain the updated river surface model.
[0063] In some embodiments, after projecting the initial river surface model onto the terrain surface, the terrain area covered by the initial river surface model can be extracted and converted from a Heightfield to a Mesh to generate a new water surface model, which is then defined as the updated river surface model.
[0064] The embodiments of this disclosure, through the steps of projecting and reconstructing river water surfaces and terrain, can obtain a complete water surface grid with uniform wiring, regular topology, and smooth connection at river intersections.
[0065] It should be noted that each vertex in the updated river surface model carries its own corresponding normalized direction vector. This normalized direction vector is determined by the tangent direction of each vertex and normalized to a unit vector. This normalized direction vector can represent the basic flow direction information of the river under ideal conditions.
[0066] Optionally, the calculation process for the normalized direction vector of each vertex includes: For the direction vector of a non-endpoint vertex: its direction vector is calculated by the position difference between the preceding and following vertices, that is, by subtracting the position of the preceding vertex from the position of the following vertex, resulting in a vector from the position of the following vertex to the position of the preceding vertex. This vector approximately represents the tangential direction at the initial vertex. Then, this vector is normalized.
[0067] For the direction vector of an endpoint vertex: since there is no preceding vertex, we can subtract the position of the next vertex from the position of the current vertex to obtain the vector of that vertex. This vector approximately represents the tangential direction at that vertex. Then, we normalize this vector.
[0068] For the direction vector of the terminal vertex: since there is no subsequent vertex, we can use the position of this vertex to subtract the position of the previous vertex to obtain the vector of this vertex. This vector approximately represents the tangential direction at this vertex. Then, we normalize this vector.
[0069] It should be noted that the "vertices" on the updated river surface model can be exactly the same as or not exactly the same as the "initial vertices" on the initial river surface model; there is no specific limitation on this.
[0070] In step S15, the river width and river depth of each vertex on the updated river surface model are determined, as are the river slope of each vertex on the updated river surface model.
[0071] In some embodiments, after generating an updated river surface model, the vertices of the newly generated updated river surface model can be used as sampling points to re-obtain relevant attributes from the initial river surface model. To obtain hydrological parameters that better fit the terrain and obstacles in the scene, the server can recalculate the river slope and river depth for each vertex of the newly generated updated river surface model.
[0072] Optionally, updating each vertex on the river surface model refers to: key discrete points that define the river's geometry, location, and attributes.
[0073] In some embodiments, the server can also calculate the river slope at each vertex.
[0074] In step S16, the actual water flow velocity of each vertex is determined based on the river width, river depth, and river slope of each vertex.
[0075] In some embodiments, after obtaining the river width, river depth, and river slope of each vertex, the actual water flow velocity of each vertex can be determined in various ways based on the river width, river depth, and river slope of each vertex.
[0076] In step S17, the actual water flow velocity information of each vertex is determined based on the normalized direction vector of each vertex and the actual water flow velocity of each vertex.
[0077] In some embodiments, the server can also determine the actual water flow velocity information of each vertex based on the normalized direction vector of each vertex and the actual water flow velocity magnitude of each vertex. For example, the actual water flow velocity information of each vertex can be obtained by calculating the product of the normalized direction vector of each vertex and the actual water flow velocity magnitude of each vertex.
[0078] As can be seen, this disclosure provides a method for calculating river flow velocity and direction based on PCG technology. This method uses a programmed algorithm to calculate the flow velocity based on the geometric and terrain information of the preset river curve (such as slope, actual river width, actual depth, etc.). Compared with traditional methods that use fixed velocity maps or offline simulation, this method achieves physically consistent flow velocity generation based on terrain data, reduces manual intervention, and improves river generation efficiency. Furthermore, this disclosure does not rely on complex fluid dynamics solutions; it can be completed through terrain sampling and mathematical formula calculations, consuming fewer computational resources and enabling real-time rendering. It can adapt to river generation and dynamic adjustment in open-world or large-scale PCG scenes. In addition, this disclosure is applicable to any scene terrain and multi-river network structure, enabling batch generation and adaptive adjustment of river effects.
[0079] Figure 3 This is a schematic diagram illustrating a process for generating an initial river surface model according to an exemplary embodiment, such as... Figure 3 As shown, in some embodiments, in step S12 above, generating an initial river surface model based on a preset river curve may include: In step S121, a cross-sectional curve is generated at the starting point of the preset river curve or the origin of the world coordinate system, based on the preset river width parameters.
[0080] In step S122, the preset river curve is sampled to obtain a preset number of sampling points.
[0081] In step S123, the tangential direction of each sampling point is determined.
[0082] In step S124, the cross-sectional curve is copied at each sampling point, and the orientation of the cross-sectional curve at each sampling point is adjusted according to the tangent direction of each sampling point so that the orientation of the cross-sectional curve at each sampling point is consistent with the tangent direction of each sampling point.
[0083] In step S125, the cross-sectional curves at each sampling point are connected to obtain the initial river surface model; wherein each initial vertex on the initial river surface model carries its corresponding normalized direction vector.
[0084] Optionally, when using the sweep node in Houdini to generate an initial river surface model based on a preset river curve, the server can first resample the preset river curve to ensure that the spacing between points on the curve is uniform, thereby maintaining topological consistency when generating the water surface in the future.
[0085] Next, the server generates a cross-sectional curve (for example, a horizontal straight line segment) at the starting point of the preset river curve or the world coordinate origin, based on the preset river width parameters. The length of this cross-sectional curve is determined by the preset river width parameters. The world coordinate origin refers to the origin of the 3D world coordinate system, which is the reference point for the position and transformation (translation / rotation / scaling) of all objects in the entire scene.
[0086] Next, the server calls the sweep node in Houdini, takes the preset river curve as the "backbone" and the cross-section curve as the "cross-section", and performs the sweep operation.
[0087] During the sweeping operation, the server samples a preset river curve, for example, by sampling at a fixed step size or by sampling uniformly according to the arc length, to obtain a preset number of sampling points. For each sampling point, the tangential direction needs to be calculated, which represents the flow direction / direction of the river at that point.
[0088] Next, the server replicates the cross-sectional curve at each sampling point and adjusts the orientation of the cross-sectional curve at each sampling point according to the tangent direction of that point. This ensures that the orientation of the cross-sectional curve at each sampling point aligns with the tangent direction of that point. Essentially, the core requirement for the cross-sectional curve is to "follow the riverbed," meaning the plane of the cross-sectional curve must be perpendicular to the tangent direction of the corresponding sampling point. Optionally, this process can be implemented by constructing a rotation matrix using Rodriguez's rotation formula. ; in, This refers to the angle between the normal vector of the cross-sectional curve (the orientation of the cross-sectional curve) and the tangent vector at the sampling point. This refers to the unit vector of the rotation axis. Applying this rotation matrix to the cross-sectional curve will rotate the orientation of the cross-sectional curve to the tangent direction of the corresponding sampling point.
[0089] Finally, the server connects the cross-sectional curves at each sampling point to obtain the initial river surface model. Optionally, the connection method can be to generate side surfaces between adjacent cross-sectional curves through linear interpolation or spline interpolation to ensure a smooth transition.
[0090] Therefore, by replicating the cross-sectional curve at each sampling point and adjusting the orientation of the cross-sectional curve at each sampling point according to the tangent direction of each sampling point, so that the orientation of the cross-sectional curve at each sampling point is consistent with the tangent direction of each sampling point, a smooth initial river surface model can be generated. This allows the subsequent generation of the water surface to maintain topological consistency, improves the generation accuracy of the initial river surface model, and thus improves the accuracy of determining the actual water flow velocity information.
[0091] In some embodiments, before generating the initial river surface model based on a preset river curve, the method further includes: Determine the gradient data for points on the preset river curve.
[0092] In this embodiment, to ensure that there are no abrupt changes at the confluence of multiple rivers, the server can determine the gradient data of points on a preset river curve before generating the initial river surface model. Optionally, the process of determining the gradient data of points on the preset river curve includes: setting the gradient data of the points on the preset river curve to 0, and gradually increasing the gradient data of points farther from the endpoint with a preset difference (e.g., 0.05) as the gradient value, until the gradient data is 1. It should be noted that since the initial river surface model is obtained by sampling the preset river curve, the points on the preset river curve include the initial vertices in the initial river surface model.
[0093] In some embodiments, after generating an initial river surface model based on a preset river curve, the above method further includes: If it is determined that there is an overlapping area between the initial vertices in the initial river surface model in the vertical direction, the initial vertices located in the overlapping area are determined; the points on the preset river curve include the initial vertices; Determine the height difference between the initial vertices located in the overlapping region; Based on the height difference and the gradient data of the initial vertices in the overlapping region, the height difference is merged to obtain a smoothed initial river surface model; the smoothed initial river surface model is used to project onto the terrain surface.
[0094] In this embodiment, after generating the initial river surface model, taking the generation of the initial river surface model through the sweep node as an example, the points on the initial river surface model use the intersection test function (intersect function) in the attribute processing node to calculate whether there is an overlapping area in the vertical direction. This overlapping area is the river intersection. For the initial vertex located in the overlapping area, the gradient data of the initial vertex can be used as the weight value to merge the height difference of the initial vertices in the overlapping area, so that the water surface forms a smooth transition in the continuous area.
[0095] Optionally, for difference merging, the server can calculate the height difference between adjacent initial vertices in the overlapping region, and merge the height differences based on the height differences and the gradient data of the initial vertices. Assuming the adjacent initial vertices in the overlapping region are A, B, C, and D, with corresponding gradients of gradient A, gradient B, gradient C, and gradient D, and corresponding heights of HA, HB, HC, and HD, then the height difference between the adjacent initial vertices is: ΔHAB=HB HA (elevation difference from A to B); ΔHBC=HC HB (elevation difference from B to C); ΔHCD=HD HC (the height difference between C and D); The weight of ΔHAB = (gradientA, gradientB) / 2; The weight of ΔHBC = (gradientB, gradientC) / 2; The weight of ΔHCD = (gradientC, gradientD) / 2.
[0096] Total merged difference = weight of ΔHAB × ΔHAB + weight of ΔHBC × ΔHBC + weight of ΔHCD × ΔHCD.
[0097] Therefore, to ensure that there are no abrupt changes at the confluence of multiple rivers, a gradient data is determined for each initial vertex before generating the initial river surface model. After generating the initial river surface model, the height difference of the initial vertices located in the overlapping area in the vertical direction is merged based on the gradient data, so that the water surface forms a smooth transition in the connecting area, thereby ensuring that there are no abrupt changes at the confluence of multiple rivers and improving the accuracy of river flow velocity processing.
[0098] Figure 4 This is a schematic diagram illustrating a process for determining river width and river depth according to an exemplary embodiment, such as... Figure 4 As shown, in an optional embodiment, in step S15 above, determining and updating the river width and river depth at each vertex on the river surface model includes: In step S151, the attribute information of each vertex on the updated river surface model is obtained from the initial river surface model.
[0099] In some embodiments, the server can use the vertices in the newly generated updated river surface model as sampling points to re-obtain relevant attributes from the initial river surface model.
[0100] In one approach, the server can pre-train an attribute acquisition model that has the ability to acquire attribute information for vertices in one river surface model from another river surface model. With the completed attribute acquisition model, the server can acquire the attribute information for each vertex in the updated river surface model from the initial river surface model.
[0101] In another approach, the aforementioned method of obtaining attribute information for each vertex on the updated river surface model from the initial river surface model includes: The target vertex is obtained by identifying the point in the vertical direction where the vertex in the updated river surface model intersects with the initial vertex in the initial river surface model.
[0102] The attribute information of the target vertex on the initial river surface model is determined as the attribute information of the target vertex on the updated river surface model.
[0103] In this embodiment, the `intersect` function, a high-efficiency compiled scripting language (VEX), can be used in the `attribute wrangle` node to calculate the vertical intersection point between the vertices in the updated river surface model and the initial vertices in the initial river surface model, thus obtaining the target vertex. Then, the `primuv` function is used to obtain the attribute information (e.g., attribute values) of the target vertex in the initial river surface model. This attribute information of the target vertex in the initial river surface model is then used as the attribute information of the target vertex in the updated river surface model. For example, if the target vertices are vertex 1, vertex 2, and vertex 3, the `primuv` function is used to obtain the attribute information of vertex 1 in the initial river surface model and uses it as the attribute information of vertex 1 in the updated river surface model. Similarly, the `primuv` function is used to obtain the attribute information of vertex 2 in the initial river surface model and uses it as the attribute information of vertex 2 in the updated river surface model. The `primuv` function is a utility function used to obtain or set the UV coordinates at the geometric primitive level.
[0104] Optionally, this attribute information includes, but is not limited to: the normalized direction vector of the vertex, other external input parameters, etc.
[0105] This disclosure improves the accuracy of the newly generated updated river surface model by obtaining relevant attributes from the initial river surface model.
[0106] In step S153, based on the attribute information of each vertex on the updated river surface model, the river width and river depth of each vertex on the updated river surface model are determined.
[0107] In some embodiments, to obtain hydrological parameters that better fit the terrain and obstacles in the scene, the server can recalculate the river width and river depth for each vertex on the newly generated updated river surface model based on the attribute information of each vertex on the updated river surface model.
[0108] In one approach, a prediction model can be pre-trained to predict the river depth and width of vertices based on their attribute information. When in use, the attribute information of each vertex on the updated river surface model is input into this prediction model, which automatically outputs the updated river width and depth for each vertex on the updated river surface model.
[0109] In another approach, determining the river width and depth at each vertex of the updated river surface model based on the attribute information of each vertex can include: Rays are fired downwards from the location of each vertex to detect terrain collision points, thereby obtaining the updated river surface model and the river depth at each vertex.
[0110] Using the perpendicular direction of the normalized direction vector of each vertex as a reference, emit a ray to each side to obtain the intersection points between the rays emitted from each side and the surface of the obstacle.
[0111] The width of the river at each vertex is determined based on the distance between the reference point and the intersection points on both sides.
[0112] In this embodiment, the server can use VEX code to emit rays downwards along the vertical direction using the intersect function at the position of each vertex to detect terrain collision points, thereby obtaining the river width h at each vertex.
[0113] Simultaneously, using the perpendicular direction of the normalized direction vector v of each vertex as a reference, rays are emitted once to each side, intersecting the obstacle surface to obtain the intersection points between the rays emitted from each side and the obstacle surface. The distances between the reference and the intersection points on both sides are calculated, and the distances on both sides are added together to obtain the river width w at each vertex.
[0114] Therefore, by emitting rays vertically downwards at each vertex to detect river depth, and by emitting rays to both sides based on the perpendicular direction of the normalized direction vector of each vertex to detect river width, the system can automatically consider terrain undulations and obstacle distribution, and achieve dynamic adaptive calculation of river width and depth. This allows for obtaining hydrological parameters in the scene that better fit the terrain and obstacles, enabling batch generation and adaptive adjustment of river effects.
[0115] Therefore, by obtaining the attribute information of each vertex on the updated river surface model from the initial river surface model, and determining the method of updating the river width and river depth of each vertex on the updated river surface model based on the attribute information of each vertex on the updated river surface model, the method can automatically consider the terrain undulations and obstacle distribution, realize the dynamic adaptive calculation of river width and river depth, thereby obtaining hydrological parameters that are more in line with the terrain and obstacles in the scene, and realize the batch generation and adaptive adjustment of river effects. Moreover, this disclosure does not rely on complex fluid dynamics solutions, and can complete the calculation of river depth and river width through terrain sampling and mathematical formula calculation, which consumes less computing resources and has high generation efficiency.
[0116] In some embodiments, this disclosure also discloses a method for calculating the tangential direction of the obstacle's influence area, and a method for correcting the water flow direction and simulating flow at the obstacle edge. This method can automatically adjust the flow direction when a river passes over obstacles such as rocks and bridge piers, making the generated flow direction more consistent with real physical laws. Accordingly, Figure 5 This is a schematic diagram illustrating a flow velocity correction method for water flow direction according to an exemplary embodiment, such as... Figure 5 As shown, the above method may further include: In step S21, the intersection contour line of the intersection area between the updated river surface model and the obstacle is extracted, and the tangent direction of the vertex on the intersection contour line is determined based on the surface normal of the obstacle.
[0117] In step S22, the vertices on the updated river surface model that are adjacent to the vertices on the intersecting contour lines are determined.
[0118] In step S23, the tangent direction of the vertex on the intersecting contour line is determined, and the angle between it and the normalized direction vector of the adjacent vertex is determined.
[0119] In step S24, when the included angle is greater than a preset angle, the tangent direction of the vertices on the intersecting contour lines is reversed to obtain the updated river surface model after the water flow direction is corrected; the updated river surface model after the water flow direction is corrected is used to determine the river width, river depth and river slope.
[0120] In this embodiment, in step S21 above, the server can use the intersection analysis node to analyze and update the intersection area between the river surface model and obstacles such as terrain and rocks, and extract the intersection contour line of the intersection area. The server samples the three-dimensional coordinates of each vertex on the intersection contour line and uses the surface normal of the obstacle to determine the tangent direction of the vertex on the intersection contour line. Here, the intersection contour line refers to the boundary line of the intersection area. The Intersection analysis node is a dedicated node used to detect the intersection relationship between two geometric objects and output detailed intersection information.
[0121] In an optional embodiment, the above-described determination of the tangent direction of vertices on intersecting contour lines based on the surface normal of the obstacle may include: Obtain obstacle coordinate information and obstacle identification information. The obstacle coordinate information refers to the coordinates of candidate points on the obstacle whose distance to a vertex on the intersecting contour line is less than a preset distance threshold. The obstacle identification information refers to the identification information of the face on the obstacle containing the candidate points. Based on the obstacle coordinate information and obstacle identification information, sample the surface normal of the face containing the candidate points, and assign the sampled data to the vertices on the intersecting contour line to obtain the tangent direction of the vertices on the intersecting contour line.
[0122] In this embodiment, since the surface normals on the obstacle are perpendicular to the obstacle surface and face outwards by default, the coordinate information (e.g., uv coordinate values uvw) of candidate points on the obstacle whose distance to vertices on the intersecting contour line is less than a preset distance threshold can be calculated using the 3D coordinate distance function (xyzdist function) in the VEX code. This yields the obstacle coordinate information and the identification information of the face on which the candidate point is located on the obstacle (e.g., face number prim). Optionally, "distance less than the preset distance threshold" can refer to the minimum distance.
[0123] Next, the server samples the surface normal of the candidate point using uvw and prim, and assigns the sampled value to the corresponding vertex on the intersection contour line using the primuv function. This allows the corresponding vertex on the intersection contour line to obtain an outward vector perpendicular to the obstacle surface, which is the tangent direction of the vertex on the intersection contour line.
[0124] In one specific embodiment, the above method can be implemented in the attribute wrangle node using VEX code, with the intersecting contour lines and obstacles connecting the first and second input ports of the attribute wrangle node, respectively.
[0125] Since the surface normals on the obstacle model are perpendicular to the obstacle surface and face outwards by default, this disclosure samples the surface normals of the candidate point based on the obstacle coordinate information and obstacle identification information. The sampled data is then assigned to the vertices on the intersecting contour lines to obtain the tangent direction of the vertices on the intersecting contour lines. This method can accurately obtain the outward vector of the obstacle surface, improve the accuracy of determining the tangent direction of the vertices on the intersecting contour lines, thereby improving the accuracy of water flow correction and making the generated flow direction more consistent with real physical laws.
[0126] In steps S22-S24 above, after calculating the tangent direction of the vertices on the intersecting contour line, this disclosure can further perform water flow direction correction and obstacle edge flow simulation operations. During this process, the server can determine and update the vertices adjacent to the vertices on the intersecting contour line in the updated river surface model. Then, the calculated tangent direction of the vertices on the intersecting contour line is transferred to the adjacent vertices through the attribute transfer node. Next, the difference between the tangent direction of the vertices on the intersecting contour line and the normalized direction vector V (i.e., the basic water flow direction) of the adjacent vertices is calculated. Then, the angle between the tangent direction of the vertices on the intersecting contour line and the normalized direction vector V of the adjacent vertices is calculated. If this angle is greater than a preset angle, the tangent direction of the vertices on the intersecting contour line is reversed to obtain the updated river surface model after water flow direction correction, ensuring that the water flow direction is always downstream rather than upstream. This updated river surface model after water flow direction correction is used to determine the river width, river depth, and river slope. Optionally, the "angle greater than a preset angle" can be an angle greater than 90°.
[0127] Therefore, this disclosure effectively simulates the phenomenon of rivers flowing around rocks or terrain protrusions by calculating the tangential direction of the area affected by obstacles and by correcting the direction of water flow and simulating the flow at the edge of obstacles. This method can automatically adjust the flow direction when the river passes through obstacles such as rocks and bridge piers, making the generated flow direction more consistent with the real physical laws.
[0128] In some embodiments, in step S15 above, determining the river slope at each vertex of the updated river surface model may include: Determine the height difference between each vertex and a preset reference vertex, and determine the horizontal distance between each vertex and the preset reference vertex. The preset reference vertex and each vertex are within a preset area.
[0129] The river slope at each vertex is obtained based on the height difference and horizontal distance.
[0130] Optionally, the slope at each point on the river surface can be calculated using a measure node and converted into a scalar value using the length function. Specifically, the updated river surface model after terrain projection is input into the measure node. In the measure node's "Measure" parameter, the "Slope" mode is selected. This mode calculates the ratio between the aforementioned height difference and the horizontal distance, obtaining the slope value for each vertex on the updated river surface model. The calculation formula can be as follows: S = tan(θ) = Δh / Δl; Where S refers to the river slope at each vertex, Δh refers to the height difference between each vertex and the preset reference vertex, Δl refers to the horizontal distance between each vertex and the preset reference vertex, and θ refers to the local terrain inclination angle.
[0131] It should be noted that the preset reference vertex is located within a preset region of each vertex. This preset region can be a small region, meaning that the preset reference vertex can be considered as a neighboring reference point of each vertex.
[0132] During the calculation, the measure node automatically analyzes the normal direction of the geometric surface and calculates the angle between the normal and the world horizontal plane. The result is recorded as the vector attribute slope of each point. The direction of the vector represents the maximum downward direction of the river surface at that point, and the length of the vector represents the local slope, the value of which is proportional to the angle between the surface normal and the horizontal plane.
[0133] In some embodiments, since subsequent calculations require the use of the scalar value S of the slope, after obtaining the slope vector attribute, the system can use VEX code in the attribute wrangle node to extract the length of the slope vector as a scalar.
[0134] Therefore, by using the height difference and horizontal distance between each vertex and the preset reference vertex, the river slope of each vertex can be calculated accurately and efficiently, thereby improving the efficiency and accuracy of river generation.
[0135] In some embodiments, the actual water flow velocity can be calculated using the Manning formula. Figure 6 This is a schematic diagram illustrating a process for determining the actual water flow velocity at each vertex according to an exemplary embodiment, such as... Figure 6 As shown, in step S16 above, determining the actual water flow velocity at each vertex based on the river width, river depth, and river slope at each vertex may include: In step S161, a preset roughness coefficient is obtained.
[0136] In step S162, the hydraulic radius of each vertex is determined based on the river width and river depth of each vertex.
[0137] In step S163, the actual water flow velocity of each vertex is determined based on the hydraulic radius of each vertex, the river slope of each vertex, and the preset roughness coefficient.
[0138] In this embodiment, the server can obtain a preset roughness coefficient, which can be set according to actual business needs, and there are no specific limitations on it.
[0139] The server then calculates the hydraulic radius R of each vertex using the following formula: ; Where h refers to the river depth at each vertex, and w refers to the river width at each vertex.
[0140] Next, the server substitutes the hydraulic radius of each vertex, the river slope of each vertex, and the preset roughness coefficient into the Manning formula to obtain the actual water flow velocity at each vertex. The calculation formula can be as follows: ; Where Vx refers to the actual water flow velocity at each vertex, and n is the preset roughness coefficient.
[0141] Therefore, by introducing the Manning formula for physical water velocity calculation, the calculated actual water flow velocity is physically related to parameters such as slope, depth, river width, and roughness. Furthermore, the formula uses slope, roughness coefficient, and hydraulic radius as variables, making the generated results consistent with the characteristics of real river dynamics. Compared with empirical parameters or baked velocity fields, this method can improve the interpretability of the actual water flow velocity and the convenience of parameter control.
[0142] In other embodiments, the actual water flow velocity can also be calculated using the Chezy Formula, the specific process of which includes: Replacing the roughness parameter n in Manning's formula with the Chezy coefficient C, the calculation formula is as follows: ; Where V refers to the actual water flow velocity, R refers to the hydraulic radius, and J refers to the slope.
[0143] In other embodiments, the actual water flow velocity can also be calculated using the Energy Gradient Method, the specific process of which includes: The average flow velocity of the river section is estimated by using elevation difference and energy loss, without explicitly using the roughness parameter.
[0144] In some embodiments, after obtaining the actual water flow velocity at each vertex, Houdini's flowmap to color node can be used to convert the actual water flow velocity in three-dimensional space into two-dimensional vector data in tangent space, and store it in the x and y components of the vertex color attribute Cd. This data can be directly exported as a flowmap texture, used in game engines to drive the dynamic flow effects of river surface materials, achieving high-precision and automated water flow animation.
[0145] The following is a general explanation of the above-mentioned methods for processing river flow velocity: 1) Generation of the initial river surface model and calculation of the basic flow direction At the starting point of the preset river curve or the origin of the world coordinate system, a cross-sectional curve is generated based on the preset river width parameters; the preset river curve is sampled to obtain a preset number of sampling points; the tangential direction of each sampling point is determined; the cross-sectional curve is copied at each sampling point, and the orientation of the cross-sectional curve at each sampling point is adjusted according to the tangential direction of each sampling point so that the orientation of the cross-sectional curve at each sampling point is consistent with the tangential direction of each sampling point; the cross-sectional curves at each sampling point are connected to obtain the initial river surface model.
[0146] To ensure no abrupt changes at the confluence of multiple rivers, the gradient data of each initial vertex is determined on a pre-defined river curve before generating the initial river surface model. After generating the initial river surface model, given that there are overlapping regions between the initial vertices in the initial river surface model in the vertical direction, the initial vertices located in the overlapping regions are identified; the height differences between the initial vertices located in the overlapping regions are determined; and based on the height differences and the gradient data of the initial vertices located in the overlapping regions, the height differences are merged to obtain a smoothed initial river surface model.
[0147] Each initial vertex in the initial river surface model carries its own corresponding normalized direction vector. This normalized direction vector is determined by the tangent direction of each initial vertex and normalized to a unit vector. The vector direction at this point represents the basic flow direction information of the river under ideal conditions.
[0148] 2) Projection and reconstruction of river surface and topography To ensure the river blends seamlessly with the scene terrain, the server projects the initial river surface model vertically onto the terrain surface. If no terrain exists in the scene, a Heightfield terrain layer with zero height is automatically created.
[0149] After projection, the terrain regions covered by the initial river surface model are extracted and converted from Heightfield to Mesh, thereby generating a new, updated river surface model. This step yields a complete water surface mesh with uniform wiring, regular topology, and smooth connections at river intersections.
[0150] 3) Resampling and mapping of river surface attribute data The server uses the vertices of the newly generated updated river surface model as sampling points to re-obtain relevant attributes from the initial river surface model.
[0151] Optionally, the server can determine the point in the vertical direction where the vertices in the updated river surface model intersect with the initial vertices in the initial river surface model, thus obtaining the target vertex; and determine the attribute information of the target vertex in the initial river surface model as the attribute information of the target vertex in the updated river surface model. This ensures that the updated river surface model inherits the flow direction and input parameters of the initial river surface model.
[0152] 4) Automatic calculation of actual width and depth To obtain hydrological parameters that better reflect the terrain and obstacles in the scene, the system recalculates the river width and depth for each vertex of the updated river surface model.
[0153] Optionally, a ray is emitted vertically downwards at the position of each vertex to detect terrain collision points and obtain the river depth of the updated river surface model at each vertex; a ray is emitted to each side based on the perpendicular direction of the normalized direction vector of each vertex, and the intersection points between the rays emitted from each side and the obstacle surface are obtained; the river width of each vertex is determined based on the distance between the reference and the intersection points on both sides.
[0154] 5) Calculation of tangential direction of the area affected by the obstacle Extract the intersection contour lines of the intersecting regions between the updated river surface model and the obstacles, and determine the tangent directions of the vertices on the intersection contour lines based on the surface normals of the obstacles.
[0155] Optionally, the above-mentioned determination of the tangent direction of vertices on the intersecting contour line based on the surface normal of the obstacle includes: Obtain obstacle coordinate information and obstacle identification information; obstacle coordinate information refers to the coordinate information of candidate points on the obstacle whose distance to the vertex on the intersecting contour line is less than a preset distance threshold, and obstacle identification information refers to the identification information of the face on the obstacle where the candidate points are located; based on obstacle coordinate information and obstacle identification information, sample the surface normal of the face where the candidate points are located, and assign the sampled data to the vertex on the intersecting contour line to obtain the tangent direction of the vertex on the intersecting contour line.
[0156] 6) Water flow direction correction and obstacle edge flow simulation The server can determine the vertices adjacent to vertices on the intersecting contour line in the updated river surface model. It determines the angle between the tangent direction of the vertices on the intersecting contour line and the normalized direction vectors of the adjacent vertices; if the angle is greater than a preset angle, it reverses the tangent direction of the vertices on the intersecting contour line to obtain the updated river surface model with corrected water flow direction. (Gyroscope) This process effectively simulates the phenomenon of rivers flowing around rocks or terrain protrusions, making the generated flow direction more consistent with real physical laws.
[0157] 7) Calculation of water velocity based on Manning's formula Determine the height difference between each vertex and the preset reference vertex, and determine the horizontal distance between each vertex and the preset reference vertex; based on the height difference and horizontal distance, obtain the river slope of each vertex.
[0158] Next, obtain the preset roughness coefficient; determine the hydraulic radius of each vertex based on the river width and river depth of each vertex; substitute the hydraulic radius of each vertex, the river slope of each vertex, and the preset roughness coefficient into the Manning formula to determine the actual water flow velocity of each vertex.
[0159] 8) Visualization and export of flow velocity vectors After obtaining the actual water flow velocity at each vertex, Houdini's flowmap to color node can be used to convert the 3D water flow velocity vector into 2D vector data in tangent space, and store it in the x and y components of the vertex color attribute Cd. This data can be directly exported as a flowmap texture, used in game engines to drive the dynamic flow effects of river surface materials, achieving high-precision and automated water flow animation.
[0160] The river flow velocity processing method provided in this disclosure has the following beneficial effects: 1) Dynamic flow velocity calculation mechanism combined with terrain parameters: This disclosure calculates the river flow velocity using a programmed algorithm based on the geometric and terrain information of the river channel (such as slope, actual river width, actual depth, etc.). Compared with the traditional method of using fixed velocity mapping or offline simulation, it can automatically generate the real flow direction according to the terrain and obstacles without manual adjustment, realizing programmed adaptive physical consistency flow velocity generation based on terrain data.
[0161] 2) Introducing Manning's formula for real-time approximate calculations in the game: Manning's formula from hydraulic engineering is introduced into the game's PCG river generation system to calculate the river's flow velocity during the generation phase. This formula uses slope, roughness coefficient, and hydraulic radius as variables, and the results are physically related to parameters such as slope, depth, river width, and roughness. This makes the generated results conform to the dynamic characteristics of real rivers. Compared with empirical parameters or baked velocity fields, it has the advantages of high physical accuracy, strong interpretability, and convenient parameterized control.
[0162] 3) Real-time adaptation for programmed river generation (PCG): When the terrain or river path changes, the velocity field can be automatically recalculated without resimulation or manual adjustment, which significantly improves iteration efficiency.
[0163] 4) Lightweight computational model, suitable for use during game runtime: This algorithm does not rely on complex fluid dynamics solutions. It can be completed only through terrain sampling and mathematical formula calculations. It has a small computational load, can be executed in real time, and is suitable for river generation and dynamic adjustment in open world or large-scale PCG scenarios.
[0164] 5) It has scalability and parameter controllability: parameters such as roughness coefficient, slope threshold, and flow velocity correction coefficient can be adjusted in real time in the editor to achieve different styles of river effects (turbulent / gentle), and can be linked with fluid effects, particles, and floating object physics systems to achieve unified speed drive.
[0165] 6) Results visualization and game usability: The flowmap in the tangent space is directly output and can be seamlessly integrated with game engines.
[0166] 7) Highly scalable: Applicable to any scene terrain and multi-river network structure, suitable for batch generation.
[0167] This disclosure also provides a river flow velocity processing device. Figure 7 This is a block diagram illustrating a river flow velocity treatment device according to an exemplary embodiment. (Refer to...) Figure 7 As shown, the device includes: The preset river curve acquisition module 31 is configured to acquire a preset river curve and generate an initial river surface model based on the preset river curve. Projection module 32 is configured to project the initial river surface model onto the terrain surface; The model update module 33 is configured to acquire the terrain area covered by the initial river surface model in the terrain surface, and convert the terrain area into a mesh to obtain the updated river surface model; The river information determination module 34 is configured to determine the river width and river depth at each vertex of the updated river surface model, and to determine the river slope at each vertex of the updated river surface model. The water flow magnitude determination module 35 is configured to determine the actual water flow velocity magnitude at each vertex based on the river width, river depth, and river slope at each vertex. The water flow velocity determination module 36 is configured to perform a normalized direction vector for each vertex and the actual water flow velocity magnitude for each vertex to determine the actual water flow velocity information for each vertex.
[0168] In an optional embodiment, the preset river curve acquisition module includes: The cross-sectional curve generation unit is configured to generate a cross-sectional curve based on the preset river width parameter at the starting point or world coordinate origin of the preset river curve. The sampling unit is configured to perform sampling on the preset river curve to obtain a preset number of sampling points; A tangent direction determination unit is configured to determine the tangent direction of each of the sampling points; The cross-sectional curve processing unit is configured to perform the replication of the cross-sectional curve at each of the sampling points and adjust the orientation of the cross-sectional curve at each of the sampling points according to the tangent direction of each of the sampling points, so that the orientation of the cross-sectional curve at each of the sampling points is consistent with the tangent direction of each of the sampling points; The connection unit is configured to perform the connection of the cross-sectional curves on each of the sampling points to obtain the initial river surface model.
[0169] In an optional embodiment, the apparatus further includes: The data generation module is configured to determine gradient data for points on the preset river curve. Accordingly, the above methods also include: The overlapping vertex determination module is configured to determine the initial vertex located in the overlapping region when it is determined that the initial vertices in the initial river surface model have an overlapping region in the vertical direction; the points on the preset river curve include the initial vertices; The height difference determination module is configured to determine the height difference between initial vertices located in the overlapping region; The merging module is configured to merge the height difference based on the height difference and the gradient data of the initial vertices located in the overlapping region to obtain a smoothed initial river surface model; the smoothed initial river surface model is used to project onto the terrain surface.
[0170] In an optional embodiment, the river information determination module includes: The attribute information acquisition unit is configured to acquire the attribute information of each vertex on the updated river surface model from the initial river surface model; The width and depth determination unit is configured to determine the river width and river depth of each vertex on the updated river surface model based on the attribute information of each vertex on the updated river surface model.
[0171] In an optional embodiment, the attribute information acquisition unit includes: The target vertex determination subunit is configured to determine the point in the vertical direction where the vertex in the updated river surface model intersects with the initial vertex in the initial river surface model, thereby obtaining the target vertex; The target vertex processing subunit is configured to determine the attribute information of the target vertex on the initial river surface model as the attribute information of the target vertex on the updated river surface model.
[0172] In an optional embodiment, the width-depth determination unit includes: The depth determination subunit is configured to fire a ray vertically downward at the position of each vertex to detect terrain collision points and obtain the river depth of the updated river surface model at each vertex; The intersection point determination sub-unit is configured to execute a ray emitted to each side based on the perpendicular direction of the normalized direction vector of each vertex, thereby obtaining the intersection points between the rays emitted from each side and the surface of the obstacle. The width determination subunit is configured to determine the river width at each vertex based on the distance between the reference and the intersection points on both sides.
[0173] In an optional embodiment, the apparatus further includes: The vertex tangent direction determination module is configured to extract the intersection contour line of the intersection region between the updated river surface model and the obstacle, and determine the tangent direction of the vertex on the intersection contour line based on the surface normal of the obstacle; The adjacent vertex determination module is configured to determine the vertices on the updated river surface model that are adjacent to the vertices on the intersecting contour line; Angle determination module is configured to determine the angle between the tangent direction of a vertex on the intersecting contour line and the normalized direction vector of the adjacent vertex. The inversion module is configured to reverse the tangent direction of the vertices on the intersecting contour line when the included angle is greater than a preset angle, so as to obtain an updated river surface model with corrected water flow direction; the updated river surface model with corrected water flow direction is used to determine the river width, river depth and river slope.
[0174] In an optional embodiment, the vertex tangent direction determination module includes: The coordinate identification unit is configured to acquire obstacle coordinate information and obstacle identification information; the obstacle coordinate information is the coordinate information of candidate points on the obstacle whose distance to the vertex of the intersecting contour line is less than a preset distance threshold, and the obstacle identification information is the identification information of the face on the obstacle where the candidate points are located; The normal sampling unit is configured to sample the surface normal of the face where the candidate point is located based on the obstacle coordinate information and the obstacle identification information, assign the sampled data to the vertices on the intersecting contour line, and obtain the tangent direction of the vertices on the intersecting contour line.
[0175] In an optional embodiment, the river information determination module includes: The height distance determination unit is configured to determine the height difference between each vertex and a preset reference vertex, and to determine the horizontal distance between each vertex and the preset reference vertex; the preset reference vertex and each vertex are within a preset area. The river slope determination unit is configured to perform the operation of determining the river slope at each vertex based on the height difference and the horizontal distance.
[0176] In an optional embodiment, the water flow velocity determination module includes: The preset roughness coefficient acquisition unit is configured to acquire the preset roughness coefficient. The hydraulic radius determination unit is configured to determine the hydraulic radius of each vertex based on the river width and river depth of each vertex. The actual water flow velocity determination unit is configured to determine the actual water flow velocity of each vertex based on the hydraulic radius of each vertex, the river slope of each vertex, and the preset roughness coefficient.
[0177] Regarding the apparatus in the above embodiments, the specific manner in which each set of modules performs operations has been described in detail in the embodiments related to the method, and will not be elaborated here.
[0178] In an exemplary embodiment, an electronic device for processing river flow velocity is also provided, including a processor; a memory for storing processor-executable instructions; wherein, when the processor is configured to execute the instructions stored in the memory, it implements the steps of any of the river flow velocity processing methods described above.
[0179] The electronic device can be a terminal, a server, or a similar computing device. Taking a server as an example... Figure 8 This is a block diagram illustrating an electronic device for processing river flow velocity according to an exemplary embodiment. The electronic device 40 can vary considerably depending on its configuration or performance, and may include one or more central processing units (CPUs) 41 (CPUs 41 may include, but are not limited to, microprocessors (MCUs) or programmable logic devices (FPGAs), a memory 43 for storing data, and one or more storage media 42 (e.g., one or more mass storage devices) for storing application programs 423 or data 422. The memory 43 and storage media 42 may be temporary or persistent storage. The program stored in the storage media 42 may include one or more modules, each module including a series of instruction operations on the electronic device. Furthermore, the CPU 41 may be configured to communicate with the storage media 42 and execute the series of instruction operations in the storage media 42 on the electronic device 40. Electronic device 40 may also include one or more power supplies 46, one or more wired or wireless network interfaces 45, one or more input / output interfaces 44, and / or one or more operating systems 421, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0180] The input / output interface 44 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 40. In one example, the input / output interface 44 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In an exemplary embodiment, the input / output interface 44 can be a radio frequency (RF) module for wireless communication with the Internet.
[0181] Those skilled in the art will understand that Figure 8 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, electronic device 40 may also include... Figure 8The more or fewer components shown, or having the same Figure 8 The different configurations shown.
[0182] In an exemplary embodiment, a computer-readable storage medium is also provided, which, when executed by a processor of an electronic device, enables the electronic device to perform the steps of any of the river flow velocity processing methods described above.
[0183] In an exemplary embodiment, a computer program product is also provided, including a computer program that, when executed by a processor, implements the river flow velocity processing method provided in any of the above embodiments.
[0184] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this disclosure can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0185] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0186] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method for processing river flow velocity, characterized in that, The method includes: Obtain a preset river curve; generate an initial river surface model based on the preset river curve; The initial river surface model is projected onto the terrain surface; Obtain the terrain region covered by the initial river surface model in the terrain surface, and convert the terrain region into a mesh to obtain the updated river surface model; Determine the river width and river depth at each vertex of the updated river surface model, and determine the river slope at each vertex of the updated river surface model; The actual water flow velocity at each vertex is determined based on the river width, river depth, and river slope at each vertex. The actual water flow velocity information of each vertex is determined based on the normalized direction vector of each vertex and the actual water flow velocity of each vertex.
2. The river flow velocity processing method according to claim 1, characterized in that, The preset river curve includes preset river width parameters, and the step of generating an initial river surface model based on the preset river curve includes: At the starting point of the preset river curve or the origin of the world coordinate system, a cross-sectional curve is generated based on the preset river width parameter. The preset river curve is sampled to obtain a preset number of sampling points; Determine the tangential direction of each sampling point; The cross-sectional curve is copied at each sampling point, and the orientation of the cross-sectional curve at each sampling point is adjusted according to the tangent direction of each sampling point so that the orientation of the cross-sectional curve at each sampling point is consistent with the tangent direction of each sampling point. Connect the cross-sectional curves at each sampling point to obtain the initial river surface model.
3. The river flow velocity processing method according to claim 2, characterized in that, Before generating the initial river surface model based on the preset river curve, the method further includes: Determine the gradient data of points on the preset river curve; After generating the initial river surface model based on the preset river curve, the method further includes: If it is determined that there is an overlapping area between the initial vertices in the initial river surface model in the vertical direction, the initial vertices located in the overlapping area are determined; the points on the preset river curve include the initial vertices; Determine the height difference between the initial vertices located in the overlapping region; Based on the height difference and the gradient data of the initial vertices located in the overlapping region, the height difference is merged to obtain a smoothed initial river surface model; the smoothed initial river surface model is used to project onto the terrain surface.
4. The river flow velocity processing method according to claim 1, characterized in that, Determining the river width and river depth at each vertex of the updated river surface model includes: Obtain the attribute information of each vertex on the updated river surface model from the initial river surface model; Based on the attribute information of each vertex on the updated river surface model, the river width and river depth of each vertex on the updated river surface model are determined.
5. The river flow velocity processing method according to claim 4, characterized in that, The step of obtaining the attribute information of each vertex on the updated river surface model from the initial river surface model includes: The target vertex is obtained by identifying the point in the vertical direction where the vertex in the updated river surface model intersects with the initial vertex in the initial river surface model. The attribute information of the target vertex on the initial river surface model is determined as the attribute information of the target vertex on the updated river surface model.
6. The river flow velocity processing method according to claim 4, characterized in that, The attribute information includes a normalized direction vector. The step of determining the river width and river depth at each vertex of the updated river surface model based on the attribute information of each vertex includes: Rays are emitted vertically downwards from the position of each vertex to detect terrain collision points, thereby obtaining the river depth of the updated river surface model at each vertex; Using the perpendicular direction of the normalized direction vector of each vertex as a reference, emit a ray to each side to obtain the intersection points between the rays emitted from each side and the surface of the obstacle. The river width at each vertex is determined based on the distance between the reference point and the intersection points on both sides.
7. The river flow velocity processing method according to claim 1, characterized in that, The method further includes: Extract the intersection contour line of the intersection region between the updated river surface model and the obstacle, and determine the tangent direction of the vertex on the intersection contour line based on the surface normal of the obstacle; Identify the vertices on the updated river surface model that are adjacent to the vertices on the intersecting contour lines; Determine the angle between the tangent direction of the vertex on the intersecting contour line and the normalized direction vector of the adjacent vertex; When the included angle is greater than a preset angle, the tangent direction of the vertices on the intersecting contour lines is reversed to obtain an updated river surface model with corrected water flow direction; the updated river surface model with corrected water flow direction is used to determine the river width, river depth and river slope.
8. The river flow velocity processing method according to claim 7, characterized in that, Determining the tangent direction of the vertices on the intersecting contour line based on the surface normal of the obstacle includes: Obtain obstacle coordinate information and obstacle identification information; the obstacle coordinate information is the coordinate information of candidate points on the obstacle whose distance to the vertex of the intersecting contour line is less than a preset distance threshold, and the obstacle identification information is the identification information of the face on the obstacle where the candidate points are located; Based on the obstacle coordinate information and the obstacle identification information, the surface normal of the face where the candidate point is located is sampled, and the sampled data is assigned to the vertices on the intersecting contour line to obtain the tangent direction of the vertices on the intersecting contour line.
9. The river flow velocity processing method according to any one of claims 1 to 8, characterized in that, Determining the river slope at each vertex on the updated river surface model includes: Determine the height difference between each vertex and a preset reference vertex, and determine the horizontal distance between each vertex and the preset reference vertex; the preset reference vertex and each vertex are within a preset area. The river slope at each vertex is obtained based on the height difference and the horizontal distance.
10. The river flow velocity processing method according to any one of claims 1 to 8, characterized in that, The determination of the actual water flow velocity at each vertex, based on the river width, river depth, and river slope at each vertex, includes: Obtain the preset roughness coefficient; The hydraulic radius of each vertex is determined based on the river width and river depth of each vertex. The actual water flow velocity at each vertex is determined based on the hydraulic radius of each vertex, the river slope at each vertex, and the preset roughness coefficient.
11. A river flow velocity treatment device, characterized in that, The device includes: The preset river curve acquisition module is configured to acquire a preset river curve and generate an initial river surface model based on the preset river curve. The projection module is configured to project the initial river surface model onto the terrain surface; The model update module is configured to acquire the terrain region covered by the initial river surface model in the terrain surface, and convert the terrain region into a mesh to obtain the updated river surface model; The river information determination module is configured to determine the river width and river depth at each vertex of the updated river surface model, and to determine the river slope at each vertex of the updated river surface model. The water flow magnitude determination module is configured to determine the actual water flow velocity magnitude at each vertex based on the river width, river depth, and river slope at each vertex. The water flow velocity determination module is configured to perform a normalized direction vector for each vertex and the actual water flow velocity magnitude for each vertex to determine the actual water flow velocity information for each vertex.
12. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the river flow velocity processing method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the server, the server is able to perform the river flow velocity processing method as described in any one of claims 1 to 10.