Method and system for real-time rendering of hydrodynamic data

By standardizing hydrodynamic data and utilizing UV channels and shader technology, high-precision real-time rendering of hydrodynamic data was achieved, solving the problems of long calculation time and insufficient accuracy in existing technologies, and meeting the needs of real-time rendering and practical applications.

CN120931793APending Publication Date: 2025-11-11ECCOM NETWORK SYST CO LTD

Patent Information

Application Number
CN202511154730.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-18
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing technologies cannot achieve high-precision and real-time rendering of hydrodynamic data. In particular, the complexity and diversity of hydrological data lead to excessively long computation times and insufficient accuracy, which cannot meet the needs of real-time rendering.

Method used

By acquiring hydrodynamic data, a mesh model is constructed after normalization. Data from multiple time periods is stored using UV channels, and ripples and normals of the simulated water body are constructed using vertex and pixel shaders. Interpolation optimization is performed using computational shaders to achieve efficient real-time rendering.

Benefits of technology

It achieves high-precision real-time rendering of hydrodynamic data, reduces scientific calculation time, improves the simulation accuracy of water morphology simulation, and meets the requirements of real-time rendering and practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120931793A_ABST
    Figure CN120931793A_ABST
Patent Text Reader

Abstract

The invention provides a method and system for real-time rendering of hydrodynamic data, and the method comprises the steps: obtaining hydrodynamic result data, carrying out the standardized processing of the hydrodynamic result data according to a target format, and obtaining a standardized result; reading vertex coordinate data and triangular grid index data of the standardized result, traversing a vertex coordinate data set based on values of the triangular grid index data, and further constructing a grid; the hydrodynamic result data of the current time period are packaged and transmitted to the water body grid models, and then grid vertex coordinate data of the water body grid models of the two different time periods are stored into a plurality of UV channels; creating a shader, reading vertex coordinate data in the UV channel and forming three-dimensional vector coordinate data; and constructing the texture of the water body to obtain a rendering result. According to the method, through a mode of reading the hydrodynamic data of multiple time periods in real time and rendering the data, the time for scientific calculation is shortened, and real-time rendering is supported.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention pertains to computer graphics rendering, specifically, to a method and system for real-time rendering of hydrodynamic data. More specifically, it relates to a method for real-time rendering of hydrodynamic data. Background Technology

[0002] Hydrological and hydrodynamic data are crucial scientific research findings, used for predicting floods, droughts, water quality issues, and formulating water resource planning and management policies. However, the complexity and diversity of hydrological and hydrodynamic data make accurate real-time rendering of water bodies in target watersheds a persistently challenging problem in computer graphics and simulation research.

[0003] Currently, common real-time water body rendering solutions in the simulation field rely on Dem data and oblique photogrammetry data for low-precision real-time simulation. However, the accuracy and precision of the results obtained by this type of solution are too low to meet the requirements of predicting and extrapolating hydrodynamic data in practical applications; it can only be considered a simulation of water body morphology.

[0004] In reality, accurate prediction and real-time rendering of hydrodynamic data for a target watershed require the integration of other hydrological data, such as water level, flow rate, sediment, precipitation, ice conditions, evaporation, water temperature, water quality, soil moisture content, groundwater, and historical water levels, into a scientifically calculated dataset. Only then can truly valuable hydrodynamic data be obtained for reference and practical application. However, because this hydrological data is obtained through real-time monitoring of the spatiotemporal distribution and changes of water in nature by hydrological monitoring stations, its complexity and diversity mean that the calculations required far exceed the real-time computing capabilities of current computer hardware. Furthermore, the higher the accuracy of the calculation, the longer it takes. This results in the fact that in common practical applications, the calculated results obtained after a long period are often only suitable for static data observation and research, and cannot be effectively rendered in real time, significantly reducing the real-time visualization capabilities of the data.

[0005] Patent document CN118780199A discloses a hydrodynamic simulation method, apparatus, electronic device, and storage medium. The method includes: meshing a geometric model of the region to be simulated to obtain a mesh model of the region; dividing the mesh model into multiple subdomains, each subdomain containing multiple meshes; for each subdomain, storing the mesh topology data and initial hydrodynamic data of that subdomain, along with its data input area, into a computing unit corresponding to that subdomain, wherein the meshes in direct contact with that subdomain within other subdomains constitute the data input area of ​​that subdomain; and performing parallel computation of the hydrodynamic simulation results for each subdomain based on the computing unit corresponding to each subdomain. This scheme cannot render in real time and has low accuracy.

[0006] In summary, the current limitations of existing technologies for simulating hydrodynamic data in the simulation field include: 1. Real-time simulation of water morphology using only DEM data and oblique photography data has too low accuracy and precision, resulting in a significant discrepancy with reality.

[0007] 2. The time required for scientific calculation based on all hydrological data, including DEM and oblique photogrammetry data, is too long to enable real-time rendering. Summary of the Invention

[0008] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method and system for real-time rendering of hydrodynamic data.

[0009] A method for real-time rendering of hydrodynamic data according to the present invention includes: Step S1: Obtain hydrodynamic result data, and normalize the hydrodynamic result data according to the target format to obtain the normalized result; Step S2: Read the vertex coordinate data and triangle mesh index data of the normalized result. Based on the value of the triangle mesh index data, traverse the vertex coordinate data set to construct the mesh. Step S3: Based on the grid, package the hydrodynamic results data for the current time period and transmit it to the water body grid model, and then store the grid vertex coordinate data of the water body grid models for two different time periods into multiple UV channels; Step S4: Create a shader, read the vertex coordinate data in the UV channel and construct three-dimensional vector coordinate data; create a two-dimensional ordinary noise numerical map, and then construct the texture of the water body to obtain the rendering result.

[0010] Preferably, in step S1, the hydrodynamic result data is obtained based on hydrological data; the hydrodynamic result data includes: coordinates, flow direction, flow velocity, and flow rate; The coordinates in the hydrodynamic results data are the vertex coordinates used to construct the water body network model; wherein, the flow direction, flow velocity, and flow rate are water body data, and are stored together in the vertex coordinates; The hydrodynamic results data are standardized by determining whether the vertex coordinates can be shared. If the result is yes, the vertex coordinates are divided into those that can be shared and no further processing is performed. If the result is no, the flow direction, velocity and flow rate at the centroid position of each grid are interpolated and stored. The current centroid position is used as the vertex coordinate data set, and then all vertex coordinates are traversed to re-divide the vertex coordinates that can be shared.

[0011] Preferably, in step S1, it is determined whether the result after standardization is complete. If the result is yes, no processing is performed; if the result is no, the missing data is calculated by interpolation and the calculation result is filled into the corresponding data set.

[0012] Preferably, in step S2, the grid is a triangular grid; the triangular grid is established based on three index values, i.e., triangular grid index data, with triangles as units. The vertex coordinate data, i.e., vertex coordinates; The triangular grid index data is arranged in a counter-clockwise order to display the water body data.

[0013] Preferably, in step S3, four UV channels are set, namely UV0, UV1, UV2 and UV3; The x and y bits of UV0 store the x and y values ​​of the vertex coordinates in the previous time period, and the x bit of UV1 stores the z value of the vertex coordinates in the previous time period; the x and y bits of UV2 store the x and y values ​​of the vertex coordinates in the current time period, and the x bit of UV3 stores the z value of the vertex coordinates in the current time period. The y-bit storage flow of UV1; the y-bit storage flow direction of UV3; The mathematical expressions for the water body grid model, namely UV0, UV1, UV2, and UV3, are as follows from top to bottom:

[0014]

[0015]

[0016]

[0017] Where P1 represents the peak of the previous time period, and P2 represents the peak of the next time period; This represents the x-coordinate value of vertex P1. This represents the y-coordinate value of vertex P1. This represents the x-coordinate value of vertex P2. L represents the y-coordinate of vertex P2, L represents flow data, and D represents flow direction data.

[0018] Preferably, in step S4, the shader includes a vertex shader, a tessellation shader, and a pixel shader.

[0019] The vertex shader can linearly interpolate the vertex coordinates, resulting in smooth rendering. The mathematical expression is:

[0020] in, Represents spherical linear interpolation. Indicates the weights in spherical linear interpolation; The value and The values ​​are the vertex coordinates for the current time period and the previous time period, respectively, in the model's local coordinate system. and Extend from the origin to the point respectively (x1, y1, z1) and point (x2, y2, z2), for and The included angle value; The vertex shader and the pixel shader can construct simulated water ripples, and the process includes: Step A1: Create a 2D ordinary noise numerical map using the vertex shader; Step A2: Assign flow direction attributes to the two-dimensional ordinary noise numerical map to obtain the flow direction map; Step A3: Based on the flow map, sample twice at different time periods and mix the noise texture of the water body on the repeated time gradient line to obtain the ripples of the simulated water body; In step S4, the normal data is reconstructed to make the lighting results of the pixel shader match the ripples of the simulated water body. The process includes: Step B1: Calculate the pixel-by-pixel normal value relative to the screen pixel intensity value in the world space coordinate system; Step B2: Construct the TBN matrix based on the pixel-by-pixel normal values; Step B3: Switch the TBN matrix to the tangent space coordinate system, and then blend the normal map.

[0021] Preferably, in step A1, the mathematical expression for the two-dimensional ordinary noise numerical map is:

[0022] in, This represents the noise value, i.e., the value of ordinary two-dimensional noise. Indicates linear interpolation; , , and These represent the generation of pseudo-random values ​​at the four vertices of the UV coordinate system of the current point; This represents the value of the x-bit of T; This represents the value of the y-bit of T; Indicates the smooth interpolation weights; The mathematical expression for the smooth interpolation weights is:

[0023] in, Indicates the smooth interpolation weights. A function that takes only the decimal part; The The mathematical expression is:

[0024] in, and All are extreme values; For interpolation weights; The , , and The mathematical expressions are as follows, from top to bottom:

[0025]

[0026]

[0027]

[0028] in, Represents a random function; This represents the floor function; Represents the U-coordinate value of the current pixel in the texture coordinate system; This represents the V coordinate value of the current pixel in the texture coordinate system.

[0029] Preferably, in step A2, the mathematical expression of the flow diagram is:

[0030] in, This represents a function used to obtain the new UV coordinate values ​​of the current pixel after it has been affected by the flow data. represents a two-dimensional vector formed by the current texture coordinate values; rad represents the flow direction in each y-channel of the 4 UV channels; represents the gradient value that increases with time per unit time; represents the normalization function; The mathematical expression of the ripples of the simulated water body is:

[0031]

[0032] where, represents the texture value of the final noise, that is, the ripples of the simulated water body; represents the sampling function; The mathematical expression of is:

[0033] where, represents the gradient value that increases with time within one unit time, that is, 0 < time < 1, time represents the unit time; t represents time, and s represents the flow rate of time; represents the value of the flow rate stored in the x-channel of the vertex color.

[0034] Preferably, in the step B2, the mathematical expression of the TBN matrix is: TBN =

[0035] where, TBN represents the TBN matrix, where, represents the tangent vector in the world coordinate system, , and are respectively the bit, bit and bit values of T; represents the normal vector in the world coordinate system, , and are respectively the 's bit, bit and bit values; represents the binormal vector in the world coordinate system, , and are respectively the bit, bit and bit values of B; In step B3, normal data N1 and normal data N2 are used to create the hybrid normal map, the mathematical expression of which is:

[0036] in, This represents a function that calculates the value of the normal line. Indicates a blended normal map; , and These represent the normal data N1 respectively. Bit, Position and The value of the bit; , and These represent the normal data N2 respectively. Bit, Position and The value of the bit; An intensity value is added to the hybrid normal map to control the intensity of the normal values. The mathematical expression is:

[0037] in, This represents the value that controls the intensity of the normal. The x and y positions of the normal vector form a two-dimensional vector. This represents the value of the z-bit of N; Indicates linear interpolation; This involves interpolating the z-bit values ​​of 1 and n, with the interpolation weights constrained between 0 and 1. Parameter values; This represents an operation function that restricts the value to the range of 0 to 1.

[0038] A system for real-time rendering of hydrodynamic data according to the present invention includes: Module M1: Acquires hydrodynamic results data, standardizes the hydrodynamic results data according to the target format, and obtains the standardized results; Module M2: Reads the vertex coordinate data and triangle mesh index data of the standard result, and traverses the vertex coordinate data set based on the value of the triangle mesh index data to construct the mesh; Module M3: Based on the grid, it packages the hydrodynamic results data for the current time period and transmits them to the water body grid model, and then stores the grid vertex coordinate data of the water body grid models for two different time periods into multiple UV channels; Module M4: Creates a shader, then reads the vertex coordinate data in the UV channel and constructs three-dimensional vector coordinate data; creates a two-dimensional ordinary noise numerical map, then constructs the texture of the water body, and obtains the rendering result.

[0039] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention reduces the time required for scientific calculations by reading and rendering hydrodynamic data from multiple time periods in real time, and also supports real-time rendering.

[0040] 2. This invention uses hydrological data as input parameters for scientific calculation, and finally outputs hydrodynamic data that includes different time periods in the past, present and future. This data is used as the basis for real-time rendering, which improves the simulation accuracy of real-time simulation of water body morphology. The hydrological data includes: water level, flow rate, sediment, precipitation, ice conditions, evaporation, water temperature, water quality, soil moisture content, groundwater and historical water level.

[0041] 3. This invention overcomes the problem that the complexity and diversity of scientific data obtained from real-time monitoring exceed the real-time computing requirements of computer hardware by performing scientific calculations on hydrological data in advance and standardizing and correcting the output data before outputting it to rendering. Attached Figure Description

[0042] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is a schematic diagram of the process provided by the present invention. Detailed Implementation

[0043] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the protection scope of the present invention.

[0044] The technical problem solved by this invention is to overcome the shortcomings of existing technologies and provide a solution that can combine hydrodynamic data obtained through high-precision scientific calculations of complex and diverse hydrological data with real-time rendering at high frame rates. This ensures that the final rendering result meets both the requirements for real-time rendering and the high accuracy requirements of hydrodynamic data in practical applications.

[0045] This invention provides a method for outputting, processing, and storing hydrodynamic data; a method for preloading hydrodynamic data; a method for representing water level changes between different time periods by processing vertex coordinate data in a vertex shader; and a method for constructing ripples and reconstructing normals of simulated water bodies in vertex and pixel shaders.

[0046] In other words, the software system flow of the method for real-time rendering of hydrodynamic data provided by the present invention includes: Step S1: Obtain hydrodynamic result data, and normalize the hydrodynamic result data according to the target format to obtain the normalized result; Step S2: Read the vertex coordinate data and triangle mesh index data of the normalized result. Based on the value of the triangle mesh index data, traverse the vertex coordinate data set to construct the mesh. Step S3: Based on the grid, package the hydrodynamic results data for the current time period and transmit it to the water body grid model, and then store the grid vertex coordinate data of the water body grid models for two different time periods into multiple UV channels; Step S4: Create a shader, read the vertex coordinate data in the UV channel and construct three-dimensional vector coordinate data; create a two-dimensional ordinary noise numerical map, and then construct the texture of the water body to obtain the rendering result.

[0047] In this embodiment, in step S1, the hydrodynamic result data is a set of data generated by scientifically calculating the coordinates, flow direction, velocity, and flow rate of the water body in multiple time periods, i.e., custom time periods, and which can be defined as future time periods to play a predictive and early warning role. This data is based on other hydrological data such as water level, flow rate, sediment, precipitation, ice conditions, evaporation, water temperature, water quality, soil moisture content, groundwater, and historical water level as input data from Dem, oblique photography, and various sensors.

[0048] In other words, this invention provides a method for outputting, processing, and storing hydrodynamic data.

[0049] First, preliminary calculations are performed to obtain hydrodynamic data. To ensure the accuracy of the final data, other hydrological data such as DEM (Depth Emission Measurement), oblique photography, current water level, flow rate, sediment, precipitation, ice conditions, evaporation, water temperature, water quality, soil moisture content, groundwater, and historical water levels need to be prepared in advance as input data.

[0050] The final hydrodynamic results data should be output in the following format: 1. The data needs to include a set of vertex coordinate data for building the water body grid model, a set of vertex indices for each triangular grid, sorted counterclockwise, and water flow direction data for each location, i.e., radian value, velocity data, and flow rate data.

[0051] 2. Hydrodynamic data needs to be stored by combining the flow direction of the water body, i.e., radian value, velocity, flow rate, and coordinates of each model grid vertex as the basic unit.

[0052] 3. The vertices of the water body mesh model will share data at the same points.

[0053] 4. For data that needs to reflect different time periods, the hydrodynamic data for each time period will be stored separately.

[0054] 5. Hydrodynamic data will be calculated based on the accuracy required in actual applications to avoid wasting computing power.

[0055] If the hydrodynamic data cannot meet the above requirements after acquisition, a second normalization process will be performed on the data: 1. If vertices in the output data cannot be shared, the flow direction, velocity, and flow rate of each triangular mesh centroid will be recalculated and the newly obtained centroid position will be used as a new set of vertex coordinate data for combination and storage. Alternatively, all vertex data can be directly traversed, points with the same vertex coordinate values ​​can be divided into shared vertices, and then the average value of the data contained in each vertex can be calculated to obtain a new set of vertex data with shared attributes.

[0056] 2. If the data for each vertex is incomplete or even lacks data of a certain major category, such as flow direction or rate, then the incomplete data needs to be re-interpolated and calculated, using the method described above, and then filled into the corresponding dataset. For data lacking a certain major category, normalized unit data can be directly filled in; it is crucial not to leave it as null.

[0057] After data processing is complete, the hydrodynamic results are directly stored on a server or local hardware storage device. Subsequently, the data is preloaded via network communication or local retrieval. This preloads the data from the server or local hard drive into memory, facilitating faster CPU access and data transfer to the GPU. This is a crucial step to meet the real-time requirements of rendering.

[0058] The present invention provides a method for preloading hydrodynamic data as follows: 1. Allocate two memory spaces to store the received hydrodynamic data for the current time period and the previous time period, respectively. During initialization, the data for the first and second time periods will be loaded first by default.

[0059] 2. Monitor data refresh messages in real time. Once a time period update message is detected, immediately update the data in memory for the two different time periods.

[0060] For example, the hydrodynamic data pre-simulation period for a target small watershed is divided into 10 stages, meaning the data for ten different time periods is stored on a server or local hardware storage device. When preloading begins, the data for the first and second time periods is first loaded into memory. Upon receiving a new refresh message, the data is immediately incremented and updated to the second and third time periods.

[0061] Once the data preloading is complete and the drawing command is received, a triangular mesh is constructed for the water body in the target time period. The steps are as follows: 1. Read the vertex coordinates and triangle mesh index data from the hydrodynamic data of the current time period in memory.

[0062] 2. Traverse the vertex coordinate data set based on the triangle mesh index values. Since the model mesh is constructed in units of triangles, the construction of one triangle mesh requires three index values. That is, when traversing the vertex data, it is necessary to perform a loop cycle with every three index values.

[0063] 3. After obtaining the vertex coordinates of each triangle based on the index, mesh construction can begin directly.

[0064] Since the ultimate goal of this invention is to perform accurate real-time rendering based on hydrodynamic data, it is necessary to utilize the powerful parallel processing capabilities of the GPU to meet the real-time requirements.

[0065] First, since the hydrodynamic data required for the current period is stored in memory, if the CPU directly accesses the data from memory in real time, then packages the data and transmits it to the GPU memory, it will significantly weaken the real-time performance of data transmission, greatly increase CPU latency, and reduce the frame rate.

[0066] Therefore, after the water body mesh construction process is completed, the hydrodynamic data for the current time period needs to be packaged and transmitted to the water body mesh model's own properties immediately in this frame. This allows the rendering pipeline to easily transmit the data to the GPU by reading the model information at any time. Furthermore, since the GPU processes data in parallel, either per vertex or per pixel, it means that no matter how large the hydrodynamic data is, the GPU can process and render all the data in parallel at once, according to the final rendering requirements.

[0067] Based on the characteristics of the model's own properties, the vertex coordinates of the water body model mesh from two different time periods need to be stored in four UV channels, i.e., texture coordinate channels. These four UV channels are then designated as UV0, UV1, UV2, and UV3, and their mathematical expressions are as follows:

[0068]

[0069]

[0070]

[0071] Where P1 represents the peak of the previous time period, and P2 represents the peak of the next time period; This represents the x-coordinate value of vertex P1. This represents the y-coordinate value of vertex P1. This represents the x-coordinate value of vertex P2. L represents the y-coordinate of vertex P2, L represents flow data, and D represents flow direction data.

[0072] Furthermore, it's important to note that although UV texture coordinates are a 4-element vector type in traditional graphics programming languages, because UV texture coordinates essentially represent coordinate values ​​in a 2D coordinate system, rendering engines, in order to optimize the process, directly define them as a 2-element vector type. Due to the characteristics of the rendering engine, it can only be set as a 2-element vector type, but to express the 3D coordinate values ​​of a vertex, at least 3 elements are needed. Therefore, this invention combines the 4 UV channels in pairs.

[0073] First, the x and y bits of UV0 are used to store the x and y values ​​of the vertex coordinates in the hydrodynamic data of the previous time period. Then, the x bits of UV1 are used to store its z value. Similarly, the x and y bits of the UV2 channel and the x bits of the UV3 channel are combined to store the x, y, and z values ​​of the vertex coordinates in the hydrodynamic data of the current time period.

[0074] This completes the operation of storing the model mesh vertex coordinates from the hydrodynamic data into the model texture coordinate set.

[0075] Similarly, in addition to storing the vertex coordinates of the water body model mesh, it is also necessary to process the values ​​of flow direction, velocity, and flow rate in the hydrodynamic data. Since the four UV channels are used in pairs, they can store a total of 8 dimensions. However, the vertex coordinate data of the model mesh for the two time periods that have just been stored only occupy 6 bits. In order to make reasonable use of storage space, the remaining y bits in UV1 are used to store float-type flow rate data, and the y bits in UV3 are used to store float-type flow direction data.

[0076] It is important to note that the flow direction data in hydrodynamic data represents the radian value of the angle between x and y in a two-dimensional coordinate system formed by the X and Z axes in three-dimensional space. Because this is crucial to the final rendered appearance of the fluid, it needs to be pre-interpolated and optimized using a Compute Shader before being stored in the corresponding UV channels to obtain smoother and more realistic flow direction data. Otherwise, if the hydrodynamic data accuracy is too low, the final water effect will appear triangular because the interpolator in the shader interpolates based on the vertices of the triangles that make up the model.

[0077] The detailed optimization principles in computation shaders are as follows:

[0078] The inverse distance interpolation method is used here. It represents the product.

[0079] Where P represents the target point derived from the flow direction data, i.e., the flow direction radian value of the point to be interpolated; i is the index coefficient of the known point data currently used in the calculation process; and n represents the total number of known points, i.e., the upper limit of i. This represents the flow direction in radians at the i-th known point. This represents the distance between the current target point and the known point in the current calculation. "power" represents the square coefficient of this distance value, which is usually 2.

[0080] The advantage of using computational shaders to handle this interpolation operation is that computational shaders utilize the GPU for parallel computation and can customize the data range in real time. This advantage allows for the rapid calculation of the interpolated and optimized hydrodynamic data, ensuring the reasonableness of rendering even with low-precision hydrodynamic data. Besides flow direction data, hydrodynamic data such as flow rate and velocity, stored as discrete points, can also be interpolated and optimized using this method. After interpolation optimization, the new values ​​can be directly stored in the UV channels or output as a flow direction map.

[0081] After all four UV channels are used up, one crucial water flow rate data point remains to be stored in the model properties. However, due to engine rendering limitations, no additional UV channels can be created. Nevertheless, other types of properties can be used in the model properties. Given that hydrodynamic data is per-vertex, vertex colors can be prioritized for storing the water flow rate data. After creating the vertex color dataset, since vertex colors are 3-element vectors while water flow rate data is only 1-dimensional, this invention only needs to obtain the x-bit of the vertex color and transfer the water flow rate data therein.

[0082] Once all the hydrodynamic data has been preloaded from the server or local storage hardware into the model properties, the remaining rendering work needs to be done using the GPU.

[0083] The GPU-side aspects mainly involve the per-vertex and per-pixel processing of model data by the graphics shader. How to reproduce the rendering effect of hydrodynamic data using the GPU is the main focus of this invention, and the method includes the following: First, create the various types of shaders needed for real-time rendering: Vertex Shader, which performs low-precision interpolation per-vertex data processing; Tessellation Shader, which is used for mesh subdivision functionality to render advanced details; and Fragment Shader, which is used for the main pixel rendering work.

[0084] This invention provides a method for representing water level changes between different time periods by processing vertex coordinate data in the vertex shader.

[0085] First, the hydrodynamic data stored in the model properties is retrieved. Vertex coordinates from different time periods within the hydrodynamic data of the four UV channels are read and reconstructed into two new 3D vector coordinate data. By setting a public variable in the vertex shader to detect whether the time period is refreshed, the hydrodynamic data can be refreshed in real time during rendering. When the data is refreshed, linear interpolation is performed on the mesh vertex coordinate values ​​of the current and previous time periods. This linear interpolation uses spherical linear interpolation, and its mathematical formula is:

[0086] in, Represents spherical linear interpolation. Indicates the weights in spherical linear interpolation; The value and The values ​​are the vertex coordinates for the current time period and the previous time period, respectively, in the model's local coordinate system. and Extend from the origin to the point respectively (x1, y1, z1) and point (x2, y2, z2), for and The included angle value; In other words, , The value represents the vertex coordinates of the current time period and the previous time period. and Consider it as extending from the origin to the point in the local coordinate system of the model. (x1, y1, z1) and point Given two three-dimensional vectors (x2, y2, z2), therefore, the view For vectors sum vector The angle between the two points is T, where T is the interpolation weight between them, i.e., the weight in spherical linear interpolation. Using spherical linear interpolation ensures that the current vertex coordinates are within the range of T. and The transition between values ​​is achieved through weighted spherical linear interpolation, resulting in a smoother and more reasonable rendering of water level data changes in hydrodynamics.

[0087] This invention also provides a method for constructing ripples and reconstructing normals of simulated water bodies in vertex shaders and pixel shaders.

[0088] First, a two-dimensional ordinary noise map is created in the vertex shader using an algorithm to simulate the most delicate water ripple texture. The mathematical principle behind this is as follows: First, leveraging the unpredictable nature of floating-point arithmetic, a pseudo-random value function is created, as shown in the following formula:

[0089] in, Represents a pseudo-random value function; express function, UV It is a binary vector composed of the current horizontal and vertical values ​​in a two-dimensional texture coordinate system, which is calculated here. UV The dot product with a constant vector is used, and a sine function and a large multiplier are applied to increase the complexity of the result. Finally, via... The operation takes its decimal part, so that the result of the function operation is always limited to the range of 0 to 1.

[0090] Then, a linear interpolation function is created. Unlike the spherical linear interpolation used previously for water level changes, this method employs the linear interpolation with the smallest computational scale, as shown in the formula below:

[0091] in, This represents linear interpolation operations; in, and These are two extreme values ​​that need to be transitioned. As the interpolation weight, this linear method can obtain its linear interpolation results with minimal computation.

[0092] Then, a noise value generation function is created.

[0093] First, generate pseudo-random values ​​at the four vertices of the current point in the UV coordinate system. The mathematical expression is as follows:

[0094]

[0095]

[0096]

[0097] in, Represents a random function; The function represents "rounding down". If the parameter is positive, it only takes the integer part of the decimal. If the parameter is negative, it takes the integer part that is one place smaller than the current decimal. Represents the U-coordinate value of the current pixel in the texture coordinate system; Represents the V coordinate value of the current pixel in the texture coordinate system; In this process, by performing a floor operation on the UV, the integer part can be obtained, so that R0, R1, R2, and R3 represent the pseudo-random values ​​of the four vertices of the texture coordinate system, namely the lower left, lower right, upper left, and upper right corners.

[0098] After obtaining pseudo-random values, to create a smooth interpolation effect, Hermite polynomials will be used to obtain smooth interpolation weights, the mathematical expression of which is:

[0099] in, Indicates the smooth interpolation weights. A function that takes only the decimal part.

[0100] Subsequently, using this weighted interpolation, linear interpolation is performed on the pseudo-random values ​​of the four vertices in the x and y directions respectively, thus obtaining the smoothed noise value, as shown in the following formula:

[0101] in, This represents the smoothed noise value, i.e., the noise value. Represents a linear interpolation function; This represents the value of the x-bit of T; This represents the value of the y-bit of T; The smooth interpolation weight is represented by a binary vector.

[0102] After the simple noise numerical map is created, a second set of noise numerical maps will be constructed to simulate the overall morphology of the water body. Due to the characteristics of the overall morphology of the water body, the noise map required by this invention needs to exhibit wave-like, continuous movement with sharp crests and gentle troughs. The mathematical principles used are as follows: First, we construct an auxiliary function for generating pseudo-random binary vectors, with the mathematical expression:

[0103] in, This represents an auxiliary function used to generate pseudo-random binary vectors; symbol Indicates multiplication; subscript " " indicates that the value of a single dimension of the multivariate vector is retrieved; The UV coordinate vector values ​​and offset value F are used as input parameters. M is a customizable 2x2 matrix (because it is pseudo-random, four complex numerical values ​​with decimals can be input to fill the matrix; in this example, (15.27, 47.63, 99.41, 89.98)). The UV vector is multiplied by the matrix M, and chaos and nonlinear changes are introduced through multiplication and the Sin function to generate pseudo-randomness. Pseudo-random numbers are then generated by multiplying a large constant by Sin and taking the decimal part. The Frac function takes the decimal part of the Sin function's return value, ensuring that the value is within the range of 0 to 1. The final returned random vector has its x and y components calculated using sine and cosine functions, respectively, and its values ​​are mapped to the range [0,1] by multiplying by 0.5 and adding 0.5.

[0104] Specifically, since the results of sine and cosine values ​​are both between -1 and +1, multiplying by 0.5 and then adding 0.5 can remap them to 0-1.

[0105] Additionally, we need to first create a function to calculate the Euclidean distance between two vectors, which is the straight-line distance between two points in a two-dimensional coordinate system. The mathematical expression is:

[0106] Then, a pseudo-random offset coordinate point function is created, as shown in the following formula:

[0107]

[0108] Here, UV still represents the current texture coordinate value, F represents the pseudo-random offset coefficient, and S represents the current UV scaling coefficient value. The UV coordinates within the range (-1,-1) to (1,1) are traversed using floor calculations, and the distances to these coordinates and their scaled values ​​(T) are accumulated, ultimately resulting in a randomly distributed, irregularly sized noise value within each quadrant. Specifically, the UV coordinates are texture coordinates, and texture coordinate values ​​are a type of two-dimensional vector data.

[0109] In short, this implementation divides the input UV coordinates into a noisy grid, then finds the nearest perturbation point in that grid and its neighboring grids, using a random vector generation function to randomly perturb each grid point, and finally calculates and outputs the distance. Finally, a remapping function is used to limit its value to a range of -1 to 1, as shown in the following formula:

[0110] in, Let represent the remapping function; a, b, c, d, and p represent the new minimum limit, the new maximum limit, the old minimum limit, the old maximum limit, and the current input value, respectively. This formula can limit all previously obtained noise values ​​to between -1 and 1. This is because the maximum distance between the pseudo-random perturbation points in the two quadrants represented by this noise value does not exceed... Since the minimum distance is 0, the final noise values ​​are as follows:

[0111] Next, blend the previously created noise map used to simulate the fine texture of water ripples with it. This adds a delicate texture to the overall water texture. The blending method can be simply multiplication.

[0112] Subsequently, a flow direction attribute is assigned to the noise map, allowing the extraction of the previously stored water flow direction arc values ​​from the y-channel of the fourth set of UV coordinates. These values ​​are then applied to the UV coordinate system of the mixed noise map. Alternatively, an interpolated and optimized flow direction map can be used, as follows:

[0113] in, This represents a function used to obtain the new UV coordinate values ​​of the current pixel after it has been affected by the flow data. This represents the normalization function; Here, UV is a two-dimensional vector composed of the current texture coordinates of the mixed noise map. In this case, the UV values ​​are the vertex coordinates of the model after interpolation by the vertex shader. rad is the flow direction radian value data stored in the y-channel of the model's fourth UV coordinate system (pre-interpolated and optimized). t is a two-dimensional vector composed of the displacements of uv. The new coordinates of a point in a two-dimensional coordinate system after displacement are the results of adding the offset displacement to both the x-axis and y-axis components of the coordinate system. However, if a direction is to be added to the increased displacement, a normalized direction vector needs to be provided. Based on basic trigonometric principles, the new coordinates of a point in a two-dimensional coordinate system after rotation in radians can be represented by a 2x2 matrix. To indicate; Because normalization was performed and multiplied by the offset, it's equivalent to adding a length value to a unit direction vector or adding a direction to a scalar value. Adding this to the UV 2D vector then yields the displacement in rads.

[0114] In addition, the offset in the above formula also represents the gradient value that increases with time within a unit time, i.e., 0 < time < 1, and it needs to be associated with the flow rate (stored in the x-channel of the vertex color) to correctly represent the water flow rate. The specific implementation formula is as follows:

[0115] Among them, offset represents the gradient value that increases with time within a unit time, i.e., 0 < time < 1; represents the value of the water flow rate stored in the x-channel of the vertex color, that is, the value of the flow rate; time represents the unit time; Among them, t is the time, s represents the flow rate of time, to facilitate the later macroscopic control of the time coefficient of the water flow. The time is always restricted within the range of 0 - 1 through the Frac function to ensure that offset is always within a unit time. Since the hydrodynamic flow rate data has been stored in the x-channel of the vertex color of the model before, it can be directly obtained and multiplied here.

[0116] According to the above formula, as time passes, the difference between different coordinates in the uv coordinate system of the water body, that is, the texture coordinate system, will be gradually amplified, ultimately resulting in the stretching and deformation of the water body appearance.

[0117] Therefore, it is necessary to sample the noise texture of the water body twice at different time periods and mix it on the repeated time gradient line. The final formula is as follows:

[0118] Among them, represents the texture value of the final noise; represents the sampling function, that is, sampling the coordinate position indicated by the parameter to obtain the texture sampling value at that position.

[0119] The mixing method still uses spherical linear interpolation here, that is way. After sampling the two noise maps located at time t and t + 0.5, use , by performing a simple operation of +0.5 multiplied by 2 on the time value within the unit time period and then taking its absolute value, the time weight value used for the interpolation mixing operation is remapped from the original (0 - 1) to (1 - 0 - 1). Also, because the time interval between the two maps for sampling is only 0.5, it is possible to seamlessly mix the noise maps sampled at two different time periods t and t + 0.5 at the beginning and end.

[0120] If explained by time periods in sequence, it can be understood as follows: First, when the time t is 0, the noise Figure 1The weight of the noise graph (at time t) is 1, and the weight of the noise graph 2 (at time t+0.5) is 0, meaning that noise is currently being fully displayed. Figure 1 .

[0121] II. As time t gradually transitions to 0.5, the noise... Figure 1 The weights transition to 0, and the weights of noise graph 2 transition to 1, meaning that noise graph 2 is now fully displayed.

[0122] Third, by repeating this process, the sampling time period of the two noise maps is always maintained between 0-0.5-1, and they are mixed by weight values ​​maintained between 1-0-1, which can avoid the problem of stretching and deformation of the water body appearance.

[0123] At this point, the noise texture of the simulated water body, containing the flow direction and velocity data from the hydrodynamic data, has been completed in the vertex shader.

[0124] Furthermore, since the above algorithm is calculated at the vertex shader stage of the water body, its normal data needs to be reconstructed based on the transformed vertex coordinates to ensure that the lighting calculation results at the pixel shader stage match the vertex positions corresponding to the water body model. In addition, the normal data reconstructed from the vertices needs to be mixed with the data from the custom normal map to finally obtain normal data that is correct both overall and in detail.

[0125] The specific method for reconstructing normal data in this invention is as follows: First, modern graphics cards' rendering cores are based on SIMD (Single Instruction Multiple Data) architecture, employing 2x2 or 4x4 pixel blocks for parallel processing. All four pixels share the same instruction stream but process different data. Based on this existing hardware capability, this invention utilizes its characteristics to create pixel partial derivatives in screen space coordinates. These derivatives represent the rate of change of screen pixel values. Since the input here is vertex coordinates, geometrically it represents the slope of a point on a fixed surface. The calculation principle is as follows: Partial derivative in the horizontal direction:

[0126] Partial derivative in the vertical direction:

[0127] in, The partial derivative in the horizontal direction; The partial derivative in the vertical direction; Can be viewed as screen pixel coordinates The value of is given, where d is the distance between two pixels. Since the pixel is the most basic unit in screen space coordinates, the distance d between adjacent pixels can be directly considered as 1. After obtaining the slope of each pixel in screen space, it is equivalent to obtaining the trend between each pixel. This value can then be used to calculate the pixel-by-pixel normal value relative to the screen pixel intensity value in world space coordinates through cross product and normalization operations. The formula is as follows:

[0128] in, This represents a function that calculates the value of the normal line. This value represents the current pixel position; here, it is the height value in the world coordinate system. This represents the cross product operation function.

[0129] After obtaining the normal values ​​in the world space coordinate system, they need to be linearly transformed to the tangent space coordinate system through matrix calculations. This is because the final purpose of this invention is to calculate the lighting related to the normals in the pixel shader, and the model vertices are always in a state of motion transformation. Keeping them in tangent space ensures that the final result is accurate and stable. The method for transforming to tangent space is as follows: First, obtain the values ​​of the TBN matrix elements:

[0130]

[0131]

[0132] in, Represents the tangent vector in the world coordinate system; Represents the normal vector in the world coordinate system; Represents the values ​​of the x, y, and z bits of the vector; This represents the dot product function; Where Matrix_ObjectToWorld is the transformation matrix from the local coordinate system to the world coordinate system, Tangent is the original tangent data provided by the model, and Normal... New secondary tangent data can be obtained through cross product operation:

[0133] in, Represents the bitangent vector in the world coordinate system; This represents a four-dimensional vector, which is the w-bit value of the data before tangency. It is used to control the direction of the secondary tangent and ensure the correct chirality of the tangent space. tangent.w is usually +1 or -1.

[0134] Then, the TBN matrix is ​​constructed:

[0135] Finally, by multiplying the normal value obtained from the pixel partial derivative with the TBN matrix, the normal value can be linearly transformed from the world space coordinate system to the tangent space coordinate system:

[0136] in, This represents a function that calculates the value of the normal line.

[0137] After reconstructing the new vertex normals, they can be blended with the water surface normal map used to simulate water surface details. The method for blending the two normal values, i.e., the normal map, is as follows: First, the channel values ​​of the two sets of normal data N1 and N2 are mixed and reconstituted into a new ternary vector:

[0138] Then, an intensity value is added to control the overall normal value intensity after blending:

[0139] in, This represents the value that controls the intensity of the normal. The x and y positions of the normal vector form a two-dimensional vector. This represents the value of the z-bit of N; Indicates linear interpolation; This involves interpolating the z-bit values ​​of 1 and n, with the interpolation weights constrained between 0 and 1. Parameter values; This represents an operation function that restricts the value to the range of 0 to 1.

[0140] At this point, all the steps regarding vertex normal reconstruction and blending for real-time transformations are complete.

[0141] This invention also provides a new lighting model for real-time simulation of subsurface scattering of water, simulation of specular reflection zones, and simulation of water splashes and foams based on the traditional PBR lighting model under the condition that the vertices are constantly moving. The specific implementation scheme is as follows.

[0142] First, obtain the observer coordinates Cam_world in the world space coordinate system and the world coordinates Pix_world of each pixel after interpolation by the vertex interpolator. Then, calculate the difference between them to obtain the direction vector from the pixel to the observer. =Pix_world- Cam_world in, This is the direction vector from the pixel to the observer.

[0143] Using the previously mentioned normal reconstruction method, the normal value N_world in the world space coordinate system after vertex motion is obtained. Through dot product operations, the angle between the pixel and the observer in the current frame can be obtained. Since this calculation process occurs at the pixel shader stage, it is equivalent to calculating the range of water bodies facing the observer, expressed as:

[0144] in, Indicates the angle between the current pixel and the observer; This represents the dot product operation function.

[0145] Then, the previously obtained mixed noise value NoiseValue is obtained, and the difference between the peaks and troughs of the noise value is increased by exponential calculation to form a range separation. This range is then applied to the range of the water body facing the observer, and the thickness of the water body currently facing the observer can be obtained, which is the thickness value of the water surface facing the observer in the subsurface scattering calculation.

[0146] Here, the noise separation index is set to power, and its expression is:

[0147] in, This indicates the thickness of the water surface facing the observer. This indicates that the power operation is performed on the mixed noise value.

[0148] Furthermore, the interpolated speed of the current pixel after passing through the vertex interpolator can be obtained and stored in the vertex color x channel. Similarly, since it is calculated in the pixel shader, speed can be represented as a range within which the transition of the water flow speed is represented.

[0149] By sampling the foam splash texture within this range and performing the same double sampling and blending operation as the normal texture, the foam splash can create a flow effect according to the direction and velocity within this range. However, since the water flow conditions vary from basin to basin, the peak velocity in some basins may exceed that of other basins by tens or even hundreds of times. Therefore, velocity range clamping is also required in this area, expressed as:

[0150] This remapping method clamps the speed between specified values ​​of a and b. Values ​​outside this range are forcibly assigned 0 or 1. Based on experience from analyzing numerous hydrodynamic data, clamping the speed within the range of 0-50 km / h is most suitable. This is because beyond 50 km / h, the local morphology of the fluid becomes indistinguishable, making the specific flow trajectory impossible to discern. Foam splash maps are directly sampled for simulation, and then the sampled foam splash map is multiplied by the line-of-sight value to ensure that excessively dense splashes are not visible at a distance and that splashes are not too dense nearby. This distance is set between 50 and 1000 meters, and the formula is as follows:

[0151] in, This indicates the final color value of the water foam. This represents speed, which is the value of the flow rate raised to the power of power. This represents a function that clamps a value within a specified range.

[0152] Finally, the various color values ​​of the diffuse channel are mixed:

[0153] in, Indicates color mixing; for .

[0154] in, The main color of the water body For the color of the wave crest where the water thickness is very small, subsurface dispersion uses the water thickness (SSS) value as a weighting value. and Spherical linear interpolation is performed between them to simulate subsurface scattering.

[0155] It is the color value of the ambient light reflected from a distance. 1-Dir represents the range in the direction away from the observer, and this range is adjusted by the exponential power. Finally, it is multiplied by the color value of the ambient skylight to express the content of the highlight reflection area.

[0156] The present invention also provides a system for real-time rendering of hydrodynamic data. The system for real-time rendering of hydrodynamic data can be implemented by executing the process steps of the method for real-time rendering of hydrodynamic data. That is, those skilled in the art can understand the method for real-time rendering of hydrodynamic data as a preferred embodiment of the system for real-time rendering of hydrodynamic data.

[0157] A system for real-time rendering of hydrodynamic data according to the present invention includes: Module M1: Acquires hydrodynamic results data, standardizes the hydrodynamic results data according to the target format, and obtains the standardized results; Module M2: Reads the vertex coordinate data and triangle mesh index data of the standard result, and traverses the vertex coordinate data set based on the value of the triangle mesh index data to construct the mesh; Module M3: Based on the grid, it packages the hydrodynamic results data for the current time period and transmits them to the water body grid model, and then stores the grid vertex coordinate data of the water body grid models for two different time periods into multiple UV channels; Module M4: Creates a shader, then reads the vertex coordinate data in the UV channel and constructs three-dimensional vector coordinate data; creates a two-dimensional ordinary noise numerical map, then constructs the texture of the water body, and obtains the rendering result.

[0158] Specifically, in module M1, the hydrodynamic results data are obtained based on hydrological data; the hydrodynamic results data include: coordinates, flow direction, flow velocity, and flow rate; The coordinates in the hydrodynamic results data are the vertex coordinates used to construct the water body network model; wherein, the flow direction, flow velocity, and flow rate are water body data, and are stored together in the vertex coordinates; The hydrodynamic results data are standardized by determining whether the vertex coordinates can be shared. If the result is yes, the vertex coordinates are divided into those that can be shared and no further processing is performed. If the result is no, the flow direction, velocity and flow rate at the centroid position of each grid are interpolated and stored. The current centroid position is used as the vertex coordinate data set, and then all vertex coordinates are traversed to re-divide the vertex coordinates that can be shared.

[0159] Specifically, in module M1, it is determined whether the result after standardization is complete. If the result is yes, no processing is performed; if the result is no, interpolation is performed to calculate the missing data and the calculation result is filled into the corresponding data set.

[0160] Specifically, in module M2, the grid is a triangular grid; the triangular grid is built based on three index values, namely triangular grid index data, with triangles as the unit. The vertex coordinate data, i.e., vertex coordinates; The triangular grid index data is arranged in a counter-clockwise order to display the water body data.

[0161] Preferably, in step S3, four UV channels are set, namely UV0, UV1, UV2 and UV3; The x and y bits of UV0 store the x and y values ​​of the vertex coordinates of the previous time period, and the x bit of UV1 stores the z value of the vertex coordinates of the previous time period; the x and y bits of UV2 store the x and y values ​​of the vertex coordinates of the current time period, and the x bit of UV3 stores the z value of the vertex coordinates of the current time period.

[0162] The y-bit storage flow of UV1; the y-bit storage flow direction of UV3.

[0163] The mathematical expressions for the water body grid model, namely UV0, UV1, UV2, and UV3, are as follows from top to bottom:

[0164]

[0165]

[0166]

[0167] Where P1 represents the peak of the previous time period and P2 represents the peak of the next time period; This represents the x-coordinate value of P1. This represents the y-coordinate value of P1. This represents the x-coordinate value of vertex P2. L represents the y-coordinate of vertex P2, L represents flow data, and D represents flow direction data.

[0168] Where P1 represents the peak of the previous time period, and P2 represents the peak of the next time period; This represents the x-coordinate value of vertex P1. This represents the y-coordinate value of vertex P1. This represents the x-coordinate value of vertex P2. L represents the y-coordinate of vertex P2, L represents flow data, and D represents flow direction data.

[0169] Specifically, in module M4, the shader includes a vertex shader, a tessellation shader, and a pixel shader.

[0170] The vertex shader can linearly interpolate the vertex coordinates, resulting in smooth rendering. The mathematical expression is:

[0171] in, Represents spherical linear interpolation. Indicates the weights in spherical linear interpolation; The value and The values ​​are the vertex coordinates for the current time period and the previous time period, respectively, in the model's local coordinate system. and Extend from the origin to the point respectively (x1, y1, z1) and point (x2, y2, z2), for and The included angle value; The vertex shader and the pixel shader can construct simulated water ripples, and the process includes: Module A1: Creates a 2D ordinary noise numerical map using a vertex shader; Module A2: Assign flow direction attributes to the two-dimensional ordinary noise numerical map to obtain the flow direction map; Module A3: Based on the flow diagram, sampling is performed twice at different time periods, and the noise texture of the water body is mixed on the repeated time gradient line to obtain the ripples of the simulated water body; In module M4, the normal data is reconstructed to make the lighting results of the pixel shader match the ripples of simulated water, including: Module B1: Calculates the pixel-by-pixel normal value relative to the screen pixel intensity value in the world space coordinate system; Module B2: Construct the TBN matrix based on the pixel-by-pixel normal values; Module B3: Switch the TBN matrix to the tangent space coordinate system, and then blend the normal map.

[0172] Specifically, in module A1, the mathematical expression for the two-dimensional ordinary noise numerical map is:

[0173] in, This represents the noise value, i.e., the value of ordinary two-dimensional noise. Indicates linear interpolation; , , and These represent the generation of pseudo-random values ​​at the four vertices of the UV coordinate system of the current point; This represents the value of the x-bit of T; This represents the value of the y-bit of T; This represents the smooth interpolation weight.

[0174] The mathematical expression for the smooth interpolation weights is:

[0175] in, Indicates the smooth interpolation weights. A function that takes only the decimal part.

[0176] The The mathematical expression is:

[0177] in, and All are extreme values; These are the interpolation weights.

[0178] The , , and The mathematical expressions are as follows, from top to bottom:

[0179]

[0180]

[0181]

[0182] in, Represents a random function; This represents the floor function; Represents the U-coordinate value of the current pixel in the texture coordinate system; This represents the V coordinate value of the current pixel in the texture coordinate system.

[0183] Specifically, in module A2, the mathematical expression for the flow diagram is:

[0184] in, This represents a function used to obtain the new UV coordinate values ​​of the current pixel after it has been affected by the flow data. This represents a two-dimensional vector composed of the current texture coordinate values; rad represents the flow direction in each of the y channels of the four UV channels. This represents the gradient value that increases with time per unit time. This represents the normalization function.

[0185] The mathematical expression for the ripples of the simulated water body is:

[0186]

[0187] in, The texture value represents the final noise, i.e., the ripples of the simulated water body; Represents the sampling function; The mathematical expression is:

[0188] Among them, represents the gradient value that increases with time within a unit time, i.e., 0 < time < 1, where time represents the unit time; t represents time, and s represents the flow rate of time. represents the value of the flow rate stored in the x-channel of the vertex color.

[0189] Specifically, in the module B2, the mathematical expression of the TBN matrix is: TBN =

[0190] Among them, TBN represents the TBN matrix, where represents the tangent vector in the world coordinate system, and and are respectively the bit, bit and bit values of T; represents the normal vector in the world coordinate system, and and are respectively the bit, bit and bit values of ; represents the binormal vector in the world coordinate system, and and are respectively the bit, bit and bit values of B.

[0191] In the module B3, assuming the normal data N1 and the normal data N2, the mathematical expression of the mixed normal map is:

[0192] Among them, represents the function for obtaining the normal value; represents the mixed normal map; and and are respectively the bit, bit and bit values of the normal data N1; and and are respectively the bit, bit and bit values of the normal data N2.

[0193] An intensity value is added to the hybrid normal map to control the intensity of the normal values. The mathematical expression is:

[0194] in, This represents the value that controls the intensity of the normal. The x and y positions of the normal vector form a two-dimensional vector. This represents the value of the z-bit of N; Indicates linear interpolation; This involves interpolating the z-bit values ​​of 1 and n, with the interpolation weights constrained between 0 and 1. Parameter values; This represents an operation function that restricts the value to the range of 0 to 1.

[0195] Those skilled in the art will understand that, besides implementing the system and its various devices, modules, and units provided by this invention in the form of purely computer-readable program code, the same functions can be achieved entirely through logical programming of the method steps, making the system and its various devices, modules, and units of this invention function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices, modules, and units provided by this invention can be considered as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices, modules, and units for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0196] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.

Claims

1. A method for real-time rendering of hydrodynamic data, characterized in that, include: Step S1: Obtain hydrodynamic result data, and normalize the hydrodynamic result data according to the target format to obtain the normalized result; Step S2: Read the vertex coordinate data and triangle mesh index data of the normalized result. Based on the value of the triangle mesh index data, traverse the vertex coordinate data set to construct the mesh. Step S3: Based on the grid, package the hydrodynamic results data for the current time period and transmit it to the water body grid model, and then store the grid vertex coordinate data of the water body grid models for two different time periods into multiple UV channels; Step S4: Create a shader, read the vertex coordinate data in the UV channel and construct three-dimensional vector coordinate data; A two-dimensional ordinary noise numerical map is created, and then the texture of the water body is constructed to obtain the rendering result.

2. The method for real-time rendering of hydrodynamic data according to claim 1, characterized in that, In step S1, the hydrodynamic results data are obtained based on hydrological data; the hydrodynamic results data include: coordinates, flow direction, flow velocity, and flow rate. The coordinates in the hydrodynamic results data are the vertex coordinates used to construct the water body network model; wherein, the flow direction, flow velocity, and flow rate are water body data, and are stored together in the vertex coordinates; The hydrodynamic results data are standardized by determining whether the vertex coordinates can be shared. If the result is yes, the vertex coordinates are divided into those that can be shared and no further processing is performed. If the result is no, the flow direction, velocity and flow rate at the centroid position of each grid are interpolated and stored. The current centroid position is used as the vertex coordinate data set, and then all vertex coordinates are traversed to re-divide the vertex coordinates that can be shared.

3. The method for real-time rendering of hydrodynamic data according to claim 2, characterized in that, In step S1, it is determined whether the result after standardization is complete. If the result is yes, no processing is performed; if the result is no, the missing data is calculated by interpolation and the calculation result is filled into the corresponding data set.

4. The method for real-time rendering of hydrodynamic data according to claim 2, characterized in that, In step S2, the grid is a triangular grid; the triangular grid is established based on three index values, i.e., triangular grid index data, with triangles as the unit. The vertex coordinate data, i.e., vertex coordinates; The triangular grid index data is arranged in a counter-clockwise order to display the water body data.

5. The method for real-time rendering of hydrodynamic data according to claim 1, characterized in that, In step S3, four UV channels are set, namely UV0, UV1, UV2 and UV3; The x and y bits of UV0 store the x and y values ​​of the vertex coordinates in the previous time period, and the x bit of UV1 stores the z value of the vertex coordinates in the previous time period; the x and y bits of UV2 store the x and y values ​​of the vertex coordinates in the current time period, and the x bit of UV3 stores the z value of the vertex coordinates in the current time period. The y-bit storage flow of UV1; the y-bit storage flow direction of UV3; The mathematical expressions for the water body grid model, namely UV0, UV1, UV2, and UV3, are as follows from top to bottom: Where P1 represents the peak of the previous time period and P2 represents the peak of the next time period; This represents the x-coordinate value of P1. This represents the y-coordinate value of P1. This represents the x-coordinate value of vertex P2. L represents the y-coordinate of vertex P2, L represents flow data, and D represents flow direction data.

6. The method for real-time rendering of hydrodynamic data according to claim 5, characterized in that, In step S4, the shader includes a vertex shader, a tessellation shader, and a pixel shader. The vertex shader can linearly interpolate the vertex coordinates, resulting in smooth rendering. The mathematical expression is: in, Represents spherical linear interpolation. Indicates the weights in spherical linear interpolation; The value and The values ​​are the vertex coordinates for the current time period and the previous time period, respectively, in the model's local coordinate system. and Extend from the origin to the point respectively (x1, y1, z1) and point (x2, y2, z2), for and The included angle value; The vertex shader and the pixel shader can construct simulated water ripples, and the process includes: Step A1: Create a 2D ordinary noise numerical map using the vertex shader; Step A2: Assign flow direction attributes to the two-dimensional ordinary noise numerical map to obtain the flow direction map; Step A3: Based on the flow map, sample twice at different time periods and mix the noise texture of the water body on the repeated time gradient line to obtain the ripples of the simulated water body; In step S4, the normal data is reconstructed to make the lighting results of the pixel shader match the ripples of the simulated water body. The process includes: Step B1: Calculate the pixel-by-pixel normal value relative to the screen pixel intensity value in the world space coordinate system; Step B2: Construct the TBN matrix based on the pixel-by-pixel normal values; Step B3: Switch the TBN matrix to the tangent space coordinate system, and then blend the normal map.

7. The method for real-time rendering of hydrodynamic data according to claim 6, characterized in that, In step A1, the mathematical expression for the two-dimensional ordinary noise numerical map is: in, This represents the noise value, i.e., the value of ordinary two-dimensional noise. Represents a linear interpolation function; , , and These represent the generation of pseudo-random values ​​at the four vertices of the UV coordinate system of the current point; This represents the value of the x-bit of T; This represents the value of the y-bit of T; Indicates the smooth interpolation weights; The mathematical expression for the smooth interpolation weights is: in, Indicates the smooth interpolation weights. A function that represents "taking only the decimal part"; The The mathematical expression is: in, and All are extreme values; For interpolation weights; The , , and The mathematical expressions are as follows, from top to bottom: in, Represents a random function; This represents the floor function; Represents the U-coordinate value of the current pixel in the texture coordinate system; This represents the V coordinate value of the current pixel in the texture coordinate system.

8. The method for real-time rendering of hydrodynamic data according to claim 7, characterized in that, In step A2, the mathematical expression for the flow diagram is: in, This represents a function used to obtain the new UV coordinate values ​​of the current pixel after it has been affected by the flow data. This represents a two-dimensional vector composed of the current texture coordinate values; rad represents the flow direction in each of the y channels of the four UV channels. This represents the gradient value that increases with time per unit time. This represents the normalization function; The mathematical expression for the ripples of the simulated water body is: in, The texture value represents the final noise, i.e., the ripples of the simulated water body; Represents the sampling function; The mathematical expression is: Among them, represents the gradient value that increases with time within a unit time, that is, 0 < time < 1, where time represents the unit time; t represents time, and s represents the flow rate of time; represents the value of the flow rate stored in the x-channel of the vertex color.

9. The method for real-time rendering of hydrodynamic data according to claim 6, characterized in that, In step B2, the mathematical expression for the TBN matrix is: TBN= Where TBN represents the TBN matrix, where... Represents the tangent vector in the world coordinate system. , and T respectively Bit, Position and The value of the bit; This represents the normal vector in the world coordinate system. , and They are respectively of Bit, Position and The value of the bit; This represents the bitangent vector in the world coordinate system. , and They are B respectively Bit, Position and The value of the bit; In step B3, normal data N1 and normal data N2 are used to create the hybrid normal map, the mathematical expression of which is: in, This represents a function that calculates the value of the normal line. This indicates a blended normal map; , and These represent the normal data N1 respectively. Bit, Position and The value of the bit; , and These represent the normal data N2 respectively. Bit, Position and The value of the bit; An intensity value is added to the hybrid normal map to control the intensity of the normal values. The mathematical expression is: in, This represents the value that controls the intensity of the normal. The x and y positions of the normal vector form a two-dimensional vector; This represents the value of the z-bit of N; Indicates linear interpolation; This represents interpolating the z-bit values ​​of 1 and n, with the interpolation weights constrained between 0 and 1. Parameter values; This represents an operation function that restricts the value to the range of 0 to 1.

10. A system for real-time rendering of hydrodynamic data, characterized in that, include: Module M1: Acquires hydrodynamic results data, standardizes the hydrodynamic results data according to the target format, and obtains the standardized results; Module M2: Reads the vertex coordinate data and triangle mesh index data of the standard result, and traverses the vertex coordinate data set based on the value of the triangle mesh index data to construct the mesh; Module M3: Based on the grid, it packages the hydrodynamic results data for the current time period and transmits them to the water body grid model, and then stores the grid vertex coordinate data of the water body grid models for two different time periods into multiple UV channels; Module M4: Creates a shader, then reads the vertex coordinate data in the UV channel and constructs three-dimensional vector coordinate data; A two-dimensional ordinary noise numerical map is created, and then the texture of the water body is constructed to obtain the rendering result.

Citation Information

Patent Citations

  • Hydrodynamic simulation method and device, electronic equipment and storage medium

    CN118780199A

Cited By

  • High-quality water body surface rendering method

    CN122049161A