A Real-time Ocean Wave Simulation Method and Device Based on Clipmap Grid

Through the optimization processing of clipmap grid and Gerstner wave function, the problems of large-scale ocean drawing are solved, and efficient wave simulation effect is achieved.

CN117372650BActive Publication Date: 2025-07-18ZHEJIANG UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311303475.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-10
Publication Date
2025-07-18
Estimated Expiration
2043-10-10

AI Technical Summary

Technical Problem

The existing Gerstner wave functions have problems such as high performance overhead, high difficulty in debugging wave parameters, and undesired regular markings caused by grid gaps in large-scale ocean drawing.

Method used

The clipmap grid is used and the Gerstner wave function is preprocessed to generate hierarchical division information and random multi-level wave data. Combined with cone culling and interpolation transition technology, the wave superposition process is optimized.

Benefits of technology

It reduces the difficulty of debugging wave parameters, improves wave computing performance, reduces high-frequency wave information at distant places, eliminates undesired regular markings, and improves the drawing effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117372650B_ABST
    Figure CN117372650B_ABST
Patent Text Reader

Abstract

The present invention discloses a real-time ocean wave simulation method and device based on a clipmap grid, including: generating a base grid for a clipmap grid instance; preprocessing wave parameters reflected by a Gerstner wave function to generate hierarchical division information and random multi-level wave data; when performing real-time per-frame rendering, updating vertex data of the clipmap grid instance according to the camera view, and simultaneously performing frustum culling on the clipmap grid; calculating vertex offsets after wave superposition and the normal vectors after offset for each vertex in real time based on the multi-level wave data and the hierarchical division information; performing interpolation and transition on wave data of two levels at the boundary during wave superposition. This method and device reduce the difficulty of wave parameter debugging, improve the performance of the shader when calculating waves, and reduce high-frequency wave information in the distance based on LOD information, eliminating unwanted regular patterns.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of real-time rendering and ocean wave simulation, and particularly relates to a real-time ocean wave simulation method and device based on a clipmap grid. Background Art

[0002] Nowadays, with the continuous improvement of the Internet, virtual reality technology and hardware level, people have a demand for real-time ocean rendering in various different fields. Among them, the simulation of waves is an important part of ocean rendering.

[0003] For wave simulation, a suitable grid is required. Geometry Clipmap was proposed by Losasso and Hoppe in 2004 for large terrain rendering. This grid has the characteristics of LOD, smooth visual switching, and stable rendering speed, and has also been applied to large-scale ocean rendering many times.

[0004] Computer graphics uses a variety of ocean wave simulation models, which can be roughly divided into three categories: parametric models, spectral models, and computational fluid dynamics (CFD). The first category describes the water surface by using parametric equations obtained from real-world observations; the second category uses wave spectra to approximately represent the ocean surface, which is achieved by simulating the wave energy distribution of the ocean motion process in the frequency domain; the third category is computational fluid dynamics (CFD) combined with the Navier-Stokes equation (NSE), which can fully describe the dynamics of various fluids including the ocean.

[0005] Among them, due to the FFT calculation and a large number of sampling operations when calculating vertex offsets and shading in the spectral model, it will bring relatively large performance overhead in real-time rendering, and it is not suitable for use in many scenarios; computational fluid dynamics has extremely large performance overhead and can hardly be used for large-scale real-time rendering at the present stage; while the parametric model has stronger versatility due to the controllability of its performance.

[0006] Parametric models usually use a series of periodic functions superimposed to generate and simulate the ocean surface, and these function values change with time. The ocean surface is represented as a height map, and the height at each point in time is calculated as the sum of a set of sine functions. One characteristic of the sine function is that the result of the function image is smooth and round, which is more suitable for simulating water bodies such as calm ponds. However, for a rough ocean, it is more desirable to generate waves with sharp wave crests and wide wave troughs. Therefore, the Gerstner wave function is more commonly used in computer graphics for wave simulation, which can control each vertex to move towards the wave crest direction to form sharper wave crests.

[0007] The Gerstner wave optimizes the effect based on the sine wave. However, in large-scale ocean rendering, there are still certain problems in terms of performance, appearance, and ease of use. Performing a large number of wave superposition calculations on a large number of vertices will significantly affect performance. Moreover, as the LOD level increases, the gaps between the meshes increase, and the meshes cannot properly sample waves with smaller wavelengths, which may lead to unexpected regular patterns in the rendering results. At the same time, it is difficult to debug a suitable set of wave parameters with a large number of wave parameters. Summary of the Invention

[0008] Aiming at the deficiencies of the prior art, the purpose of the present invention is to provide a real-time ocean wave simulation method and device based on clipmap meshes, which reduces the difficulty of debugging wave parameters, improves the performance of the shader when calculating waves, and reduces the high-frequency wave information in the distance according to the LOD information, eliminating unexpected regular patterns.

[0009] To achieve the above invention purpose, a real-time ocean wave simulation method based on clipmap meshes provided by the present invention includes the following steps:

[0010] Generate a base mesh for the clipmap mesh instance;

[0011] Select the Gerstner wave function used for wave simulation, preprocess the wave parameters reflected by the Gerstner wave function, and generate hierarchical division information and random multi-level wave data;

[0012] When performing each frame rendering in real time, update the vertex data of the clipmap mesh instance according to the camera view, and at the same time perform frustum culling on the clipmap mesh;

[0013] Calculate the vertex offset and the offset normal after wave superposition for each vertex in real time according to the multi-level wave data and the hierarchical division information;

[0014] Interpolate and transition the wave data of two levels at the boundary during wave superposition.

[0015] Preferably, the base mesh includes a tiling mesh for tiling, a jump filling mesh to prevent jitter during movement, a filling mesh to handle the non-uniform LOD size of the mesh caused by the jump filling mesh, and a seam mesh to handle the seams at the LOD levels;

[0016] When performing frustum culling on the clipmap mesh, perform frustum culling on the tiling mesh, and reduce the culling range by expanding the culling boundary.

[0017] Preferably, when preprocessing the wave parameters, the wave parameters are classified hierarchically, and the information of each hierarchical division includes the following parameters: the weight W of the current layer, the number of generated waves N, the wavelength range (L min , L max ), the wavelength attenuation rate f L , the amplitude range (A min , A max ), the amplitude attenuation rate f A , the sharpness range of the wave (S min , S max ), the sharpness attenuation rate f S of the wave, the direction diffusion angle Spread, the randomness size R. At the same time, each wave in each layer shares a direction parameter D.

[0018] Preferably, multi-level wave data is randomly generated based on the hierarchical division information. Each wave in each layer has corresponding wave parameters of wavelength, amplitude, sharpness, and direction. The calculation process includes:

[0019] Randomly generate corresponding N wave data for each layer. For each wave, generate the attenuation base Alpha according to the randomness size R and the current wave number i;

[0020] Determine the interpolation parameter according to the attenuation base Alpha and the wavelength attenuation rate f L ; According to the interpolation parameter Linearly interpolate within the wavelength range (L min , L max ) to obtain the wavelength L i of each wave;

[0021] Determine the interpolation parameter according to the attenuation base Alpha and the amplitude attenuation rate f A ; According to the interpolation parameter Linearly interpolate within the amplitude range (A min , A max ) to obtain the amplitude A i of each wave;

[0022] Determine the interpolation parameter according to the attenuation base Alpha and the sharpness attenuation rate f S ; According to the interpolation parameter Linearly interpolate within the sharpness range (S min , S max ) to obtain the amplitude S i of each wave;

[0023] Randomly increase the direction diffusion angle Spread on the shared direction parameter D to obtain the direction D i。

[0024] Preferably, the attenuation base Alpha is calculated by the following formula:

[0025]

[0026] wherein, represents generating a random number between, clamp(x, min, max) means taking x when x is between the minimum value min and the maximum value max, taking min when less than the minimum value min, and taking max when greater than the maximum value max. In formula (2), x takes the value of

[0027] the direction D of each wave i is calculated by the following formula:

[0028]

[0029] wherein, represents generating a random number between.

[0030] Preferably, when waves are superimposed, for each LOD level j of the clipmap, the required range of the superimposed wave levels is [min(j, M), M], where M is the total number of wave levels; calculating the vertex offset after wave superposition for each vertex based on the multi-level wave data and the level division information, which is expressed by the formula:

[0031]

[0032] where P(x, z, t) is the offset of each vertex represented by the coordinates (x, z) at time t, y is the initial height of the current vertex, N is the number of waves, A i is the amplitude of the i-th wave, is the direction vector of the wave, which defines the propagation direction of the wave, Q i is a parameter used to control the sharpness of the wave, and Q i = S i / ω i A i N, ω i is the angular frequency of the wave, ω i = 2π / L i L i is the wavelength of the wave, is the moving speed of the wave, g is the acceleration due to gravity.

[0033] Preferably, the calculation process of the offset normal includes:

[0034] The tangent line B(x, z, t) and the subtangent line T(x, z, t) are calculated by taking the partial derivatives of x and z in formula (3), and the normal line Normal(x, z, t) is obtained by taking the cross product of B(x, z, t) and T(x, z, t).

[0035] Preferably, the method further includes: calculating the second-order partial derivative of formula (3) to obtain J xx , J zz , J xz and J zx , then the Jacobian determinant J = J xx J zz -J xz J zx , and the Jacobian determinant J is used for coloring calculation.

[0036] Preferably, when the waves are superimposed, interpolation transition is performed on the wave data of two levels at the boundary, including:

[0037] Calculating the interpolation coefficients α x and α z on the x-axis and z-axis, and comprehensively determining the interpolation coefficient α at the boundary based on the interpolation coefficients α x and α z as α = max(α x , α z );

[0038] According to the interpolation coefficient α, interpolation calculations are separately performed on the wave data of the high level and the low level, that is:

[0039] data final = lerp(data low , data high , α)

[0040] = lerp(data high + data diff , data high , α)

[0041] where data low is the wave data of the low level, data high is the wave data of the high level, data diff is the difference between the wave data of the two, data final represents the interpolated wave data, and lerp() represents the interpolation operation.

[0042] To achieve the above object of the invention, the embodiment further provides a real-time ocean wave simulation system based on a clipmap grid, including a basic network generation module, a level division and wave data generation module, a data update and frustum culling module, an offset calculation module, and an inter-level interpolation transition module;

[0043] The base network generation module is used to generate a base grid for the clipmap grid instance;

[0044] The hierarchical division and wave data generation module is used to select the Gerstner wave function for wave simulation, preprocess the wave parameters reflected by the Gerstner wave function, and generate hierarchical division information and random multi-level wave data;

[0045] The data update and frustum culling module is used to update the vertex data of the clipmap grid instance according to the camera view when performing each frame drawing in real time, and at the same time perform frustum culling on the clipmap grid;

[0046] The offset calculation module is used to calculate the vertex offset and the offset normal after wave superposition for each vertex in real time based on the multi-level wave data and the hierarchical division information;

[0047] The interpolation transition module between levels is used to perform interpolation transition on the wave data of two levels at the boundary during wave superposition.

[0048] Compared with the prior art, the beneficial effects of the present invention at least include:

[0049] By randomly generating the input wave parameters within a range, the usability of the Gerstner wave in practical applications is improved, and through the superposition and fusion of the LOD levels of the clipmap and the wave hierarchical division, the performance of wave calculation is improved, and the problem that grids with too large vertex intervals cannot apply high-frequency wave information is effectively solved, and the rendering effect is improved. Description of the Drawings

[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0051] Figure 1 is the flowchart of the real-time ocean wave simulation method based on the clipmap grid provided by the embodiment;

[0052] Figure 2 is an example diagram of the rendering result of the GeometryClipmap provided by the embodiment;

[0053] Figure 3 is an example diagram of the effect of superimposing multi-level Gerstner waves on the basis of grid rendering provided by the embodiment;

[0054] Figure 4 It is a schematic structural diagram of a real-time ocean wave simulation device based on a clipmap grid provided by the embodiment. Detailed implementation manners

[0055] To make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific implementation manners described herein are only used to explain the present invention and do not limit the protection scope of the present invention.

[0056] As Figure 1 shown, a real-time ocean wave simulation method based on a clipmap grid provided by an embodiment of the present invention includes the following steps:

[0057] S01, generating a base grid for a clipmap grid instance.

[0058] In the embodiment, the implementation of the clipmap grid is reproduced according to the paper Losasso, Hoppe. “Geometry clipmaps: Terrain rendering using nested regular grids” ACM Transactions on Graphics (Proceedings of SIGGRAPH 2004) 23(3), pp.769-776.

[0059] Specifically, according to the size of the planar grid required for the simulation, 4 types of base grids are generated for the clipmap grid instance at the CPU side, namely a tiling grid for tiling, a jump-fill grid for preventing jitter during movement, a fill grid for handling the non-uniform grid LOD size caused by the jump-fill grid, and a seam grid for handling the seams at the LOD levels, so as to obtain a

[0060] shown example drawing result of the rendering. Among them, the tiling grid for tiling is the main part of the overall clipmap grid instance, consisting of n×n vertices. The innermost grid has 16 instances, and each of the other clipmap levels has 12 instances. Each clipmap level has a jump-fill grid for preventing jitter during movement, and its orientation changes as the grid moves. The fill grid for handling the non-uniform grid LOD size caused by the jump-fill grid consists of 1xn vertices, and each clipmap level contains 4 instances. The seam grid for handling the seams at the LOD levels is a set of simple triangles used to connect the gaps caused by different vertex intervals at the edges of the clipmap levels, Figure 2 as shown in the example drawing result of the rendering.

[0061] S02, select the Gerstner wave function for wave simulation, preprocess the parameters of the Gerstner wave function, and generate random multi-level wave data and level division information within a range.

[0062] In the embodiment, the Gerstner wave function is selected for wave simulation, and each vertex can be controlled to move towards the wave crest direction to form a sharper wave crest. Its calculation formula is:

[0063]

[0064] Among them, P(x, z, t) is the offset of each vertex represented by the coordinates (x, z) at time t, y is the initial height of the current vertex, N is the number of waves, A i is the amplitude of the i-th wave, Q i is the parameter controlling the sharpness of the wave, ω i is the angular frequency of the wave, is the direction vector of the wave, which defines the propagation direction of the wave.

[0065] In the embodiment, the wave parameters represented by the input Gerstner wave function are processed, and the CPU generates random multi-level wave data within the parameter range according to certain rules. Each wave has four wave parameters corresponding to the wavelength, amplitude, sharpness, and direction.

[0066] Specifically, the wave parameters are classified into levels. Each level division information includes the following parameters: the number of generated waves N, the wavelength range (L min , L max ), the wavelength decay rate f L , the amplitude range (A min , A max ), the amplitude decay rate f A , the sharp range of the wave (S min , S max ), the sharpness decay rate f S , the direction diffusion angle Spread, the randomness size R. At the same time, the waves of each level share a direction parameter D.

[0067] After obtaining each level division information, N corresponding wave data are randomly generated for each level. For each wave, its decay base Alpha is generated according to its randomness size R and the current wave number i:

[0068]

[0069] Among them, represents the generation A random number between, clamp(x, min, max) means taking x when x is between the minimum value min and the maximum value max, taking min when less than the minimum value min, and taking max when greater than the maximum value max. In formula (2), the value of x is In the example, the value of min is 0.0 and the value of max is 1.0.

[0070] According to the attenuation base Alpha and the wavelength attenuation rate f L Calculate the wavelength L of the corresponding wave i :

[0071]

[0072] Among them, Indicates according to the interpolation parameter Perform linear interpolation between the minimum wavelength L min and the maximum wavelength L max Interpolation.

[0073] The calculation methods of the amplitude and sharpness of each wave are similar to those of the wavelength. Specifically, according to the attenuation base Alpha and the amplitude attenuation rate f A Calculate the amplitude A of the corresponding wave i , according to the attenuation base Alpha and the sharpness attenuation rate f S Calculate the sharpness S of the corresponding wave i :

[0074]

[0075]

[0076] Among them, Indicates according to Perform linear interpolation between the minimum amplitude A min and the maximum amplitude A max Interpolation, indicating Indicates according to Perform linear interpolation between the minimum sharpness S min and the maximum sharpness S max Interpolation.

[0077] Randomly increase the direction diffusion angle Spread on the shared direction parameter D to obtain the direction D of each wave i :

[0078]

[0079] Among them, Indicates generating A random number between.

[0080] S03. When performing per-frame rendering, update the vertex data of the clipmap grid instance according to the camera view, and perform frustum culling on the clipmap grid at the same time.

[0081] In the embodiment, when performing per-frame rendering on the CPU side, update the vertex data of the clipmap grid instance according to the camera view. The updated vertex data of the instance includes the displacement, scaling, and rotation data of the vertices.

[0082] At the same time, modify the frustum culling method according to the characteristics of ocean waves to prevent the problem of excessive culling. Specifically, perform frustum culling on the tiled grid according to the vertex data of the instance. The rendering of the other three grids consumes extremely little GPU performance, and performing frustum culling on the CPU side will instead cause a decrease in overall performance. Therefore, frustum culling is not performed.

[0083] During the process of performing frustum culling, due to the differences between the wave-induced vertex offsets and the terrain height map, there are offsets not only on the y-axis but also on the x-axis and z-axis. Therefore, precise culling may cause the grids at the screen edge to be culled. In the embodiment, to address this problem, when performing culling, the culling boundary is expanded and offset to reduce the culling range to prevent the occurrence of excessive culling.

[0084] S04. Calculate the vertex offset after wave superposition and the normal vector after offset for each vertex based on the multi-level wave data and the level division information.

[0085] In the embodiment, the multi-level wave data and the level division information preprocessed on the CPU side can be passed as uniforms to the GPU side for superposition rendering. For each LOD level j of the clipmap, the range of wave levels required for superposition is [min(j, M), M], where M is the total number of wave levels.

[0086] Here, two concepts need to be distinguished: the LOD level of the clipmap and the wave level. Among them, the LOD level of the Clipmap is the level of the grid, and the wave level refers to the multi-level division of the waves. The superposition and fusion of the LOD level and the wave level mean applying the corresponding wave levels according to the LOD level where the grid vertex is located. For example: there are 7 LOD grid levels and 7 wave levels. The vertices at level 0 will apply the data of wave levels 0 to 6. The vertices at level 1 will apply the data of wave levels 1 to 6 for superposition and fusion.

[0087] Specifically, calculate the vertex offset P(x, z, t) of each wave according to the Gerstner wave function and the wave data calculated in S03:

[0088]

[0089] For convenient parameter debugging, the embodiment makes a slight modification to formula (1), where y is the initial height of the current vertex, N is the number of waves, A i is the amplitude of the i-th wave, is the direction vector of the wave, which defines the propagation direction of the wave, Q i is a parameter used to control the sharpness of the wave, and Q i = S i / ω i A i N, ω i is the angular frequency of the wave, ω i = 2π / L i L i is the wavelength of the wave, is the moving speed of the wave, g is the acceleration due to gravity.

[0090] For the normal line after vertex offset, the tangent line B(x, z, t) and the binormal line T(x, z, t) are calculated by taking the partial derivatives of x and z in formula (7). For ease of understanding, first define:

[0091]

[0092]

[0093] Then the calculation formulas for B(x, z, t) and T(x, z, t) are as follows:

[0094]

[0095]

[0096] The normal line Normal(x, z, t) can be obtained by taking the cross product of B(x, z, t) and T(x, z, t):

[0097]

[0098] In the embodiment, the second-order partial derivatives of formula (7) are further calculated to obtain J xx , J zz , J xz and J zx , and the formulas are as follows:

[0099]

[0100]

[0101]

[0102] Then the Jacobian determinant J = J xx J zz -J xz J zx .

[0103] S05, when the waves are superimposed, interpolate and transition the wave data of the two levels at the boundary.

[0104] In the embodiment, superimposing different numbers of waves on different clipmap levels (levels) will cause discontinuities at the LOD grading of the clipmap. To handle the seam problem, interpolation calculations are performed on the wave data of the two levels at the edge of the clipmap level grading to obtain a new offset.

[0105] Among them, the calculation formula for the interpolation coefficient of the x-axis is as follows:

[0106]

[0107] Among them, x is the x-axis coordinate of the calculated vertex, v x is the x-axis coordinate of the camera, n is the number of vertices of the current level of the clipmap grid, w is the width of the level gradient. In the example, the minimum value in formula (16) is 0 and the maximum value is 1.

[0108] Similarly for the z-axis:

[0109]

[0110] Among them, z is the z-axis coordinate of the calculated vertex, v z is the z-axis coordinate of the camera, and the minimum value in formula (17) is 0 and the maximum value is 1.

[0111] Finally, the determination of the boundary needs to be calculated for both the x-axis and the z-axis, and the value closest to the boundary of the two is taken as the interpolation coefficient α, that is, α = max(α x , α z ).

[0112] Calculating the waves twice for each vertex at the boundary will cause a large performance loss. To improve performance and avoid repeated calculation of the wave data shared by the two levels, the wave data of the high level and the wave data used by the low level are separated for interpolation calculation, that is:

[0113] data final = lerp(data low , data high , α)

[0114] = lerp(data high + data aiff , datahigh , α)

[0115] Among them, data low is the low-level wave data, that is, close to the camera, and data high is the high-level wave data, that is, far from the camera, and data diff is the difference in wave data between the two. As shown in Figure 3 the effect diagram of the superimposed multi-level Gerstner waves is obtained.

[0116] Based on the same inventive concept, the embodiment also provides a real-time ocean wave simulation device 40 based on a clipmap grid, including a basic network generation module 41, a level division and wave data generation module 42, a data update and frustum culling module 43, an offset calculation module 44, and an inter-level interpolation transition module 45;

[0117] Among them, the basic network generation module 41 is used to generate a basic grid for the clipmap grid instance; the level division and wave data generation module 42 is used to select the Gerstner wave function for wave simulation, preprocess the wave parameters reflected by the Gerstner wave function, and generate level division information and random multi-level wave data; the data update and frustum culling module 43 is used to update the vertex data of the clipmap grid instance according to the camera view when performing each frame drawing in real time, and at the same time perform frustum culling of the clipmap grid; the offset calculation module 44 is used to calculate the vertex offset and the offset normal after wave superposition for each vertex in real time based on the multi-level wave data and the level division information; the inter-level interpolation transition module 45 is used to perform interpolation transition on the wave data of the two levels at the boundary when the waves are superimposed.

[0118] It should be noted that when the above-mentioned real-time ocean wave simulation device based on a clipmap grid performs the real-time ocean wave simulation method, the above-mentioned division of each functional module should be used for illustration, and the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the terminal or server is divided into different functional modules to complete all or part of the functions described above. In addition, the above-mentioned real-time ocean wave simulation device based on a clipmap grid and the embodiment of the real-time ocean wave simulation method based on a clipmap grid belong to the same inventive concept, and the specific implementation process can be seen in the embodiment of the real-time ocean wave simulation method based on a clipmap grid, which will not be elaborated here.

[0119] Based on the same inventive concept, the embodiment further provides a real-time ocean wave simulation system based on a clipmap grid, including a CPU side and a GPU side. Among them, the CPU side is used to implement S01-S03 in the above real-time ocean wave simulation method, and send the hierarchical division information, random multi-level wave data, and vertex data of the rendering pipeline to the GPU side. The GPU side is used to implement S04-S05 in the above real-time ocean wave simulation method.

[0120] The real-time ocean wave simulation method, device, and system based on a clipmap grid provided by the embodiments of the present invention can reduce the difficulty of wave parameter debugging, improve the performance of the shader when calculating waves, and reduce high-frequency wave information in the distance according to LOD information, eliminating unwanted regular patterns.

[0121] The specific embodiments described above have elaborated on the technical solutions and beneficial effects of the present invention. It should be understood that the above are only the most preferred embodiments of the present invention and are not used to limit the present invention. Any modifications, supplements, equivalent replacements, etc. made within the scope of the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A real-time ocean wave simulation method based on a clipmap grid, characterized in that, It includes the following steps: Generate a base mesh for the clipmap mesh instance; Select the Gerstner wave function for wave simulation, preprocess the wave parameters represented by the Gerstner wave function, and generate level division information and random multi-level wave data; When performing per-frame rendering in real time, update the vertex data of the clipmap mesh instance according to the camera view, and at the same time perform frustum culling on the clipmap mesh; Calculate the vertex offset and the offset normal after wave superposition for each vertex in real time based on the multi-level wave data and the level division information, including: Among them, P(x, z, t) is the offset of each vertex represented by coordinates (x, z) at time t, y is the initial height of the current vertex, N is the number of waves, A i is the amplitude of the i-th wave, k i is the direction vector of the wave, which defines the propagation direction of the wave, Q i is a parameter used to control the sharpness of the wave, ω i is the angular frequency of the wave, L i is the wavelength of the wave, is the moving speed of the wave, and g is the acceleration due to gravity; Calculate the tangent B(x, z, t) and the binormal T(x, z, t) by taking partial derivatives of x and z in formula (1), and obtain the normal Normal(x, z, t) by taking the cross product of B(x, z, t) and T(x, z, t); Interpolate and transition the wave data of two levels at the boundary during wave superposition.

2. The real-time ocean wave simulation method based on the clipmap grid according to claim 1, wherein The base mesh includes a tiling mesh for tiling, a jump fill mesh to prevent jitter during movement, a fill mesh to handle the inconsistent mesh LOD size caused by the jump fill mesh, and a seam mesh to handle the seams at the LOD levels; When performing frustum culling on the clipmap mesh, perform frustum culling on the tiling mesh, and reduce the culling range by expanding the culling boundary.

3. The real-time ocean wave simulation method based on clipmap grid according to claim 1, characterized in that, When preprocessing the wave parameters, classify the wave parameters into levels, and each level division information includes the following parameters: The weight W of the current level, the number of generated waves N, the wavelength range (L min , L max ), the wavelength attenuation rate f L , the amplitude range (A min , A max ), the amplitude attenuation rate f A , the sharpness range of the wave (S min , S max ), the sharpness attenuation rate of the wave f S , the direction diffusion angle Spread, the randomness magnitude R, and at the same time, the waves of each level share a direction parameter D.

4. The real-time ocean wave simulation method based on the clipmap grid according to claim 3, characterized in that, Randomly generate multi-level wave data based on the level division information. Each wave in each level has four wave parameters corresponding to wavelength, amplitude, sharpness, and direction. The calculation process includes: Randomly generate corresponding N wave data for each level. For each wave, generate the attenuation base Alpha according to the randomness size R and the current wave number i; According to the attenuation base Alpha and the wavelength attenuation rate f L Determine the interpolation parameter According to the interpolation parameter In the wavelength range (L min , L max ), linearly interpolate to obtain the wavelength L of each wave i ; According to the attenuation base Alpha and the amplitude attenuation rate f A Determine the interpolation parameter According to the interpolation parameter Within the amplitude range (A min , A max ), linearly interpolate to obtain the amplitude A of each wave i ; According to the attenuation base Alpha and the sharpness attenuation rate f S Determine the interpolation parameter According to the interpolation parameter Within the sharp range (S min , S max ), linearly interpolate to obtain the amplitude S of each wave i ; Randomly increase the direction diffusion angle Spread on the shared direction parameter D to obtain the direction D of each wave i .

5. The real-time ocean wave simulation method based on clipmap grid according to claim 4, characterized in that, The attenuation base Alpha is calculated by the following formula: Among them, represents generating a random number between, clamp(x, min, max) means taking x when x is between the minimum value min and the maximum value max, taking min when less than the minimum value min, and taking max when greater than the maximum value max. In formula (1), x takes the value of The direction D of each wave i is calculated by the following formula: Among them, represents generating a random number between...

6. The real-time ocean wave simulation method based on the clipmap grid according to claim 1, characterized in that During wave superposition, for each LOD level j of the clipmap, the wave level range required for superposition is [min(j, M), M], where M is the total number of wave levels.

7. The real-time ocean wave simulation method based on clipmap grid according to claim 6, characterized in that, It also includes: Obtain \(J\) by calculating the second partial derivative of the calculation formula (3) xx , \(J\) zz , \(J\) xz and \(J\) zx , then the Jacobian determinant \(J = J\) xx \(J\) zz - \(J\) xz \(J\) zx , and the Jacobian determinant \(J\) is used for coloring calculation.

8. The real-time ocean wave simulation method based on the clipmap grid according to claim 1, characterized in that, Interpolate and transition the wave data of two levels at the boundary during wave superposition, including: Calculate the interpolation coefficients α for the x-axis and the z-axis x and α Z , and the combined interpolation coefficient α x and α Z to determine the interpolation coefficient α at the boundary as α = max(α x , α z ); According to the interpolation coefficient α, perform interpolation calculations on the high-level wave data and the low-level wave data separately, that is: data final = lerp(data low , data high , α) = lerp(data high + data diff , data high , α) Among them, data low is the low-level wave data, data high is the high-level wave data, data diff is the difference in wave data between the two, da final represents the interpolated wave data, and lerp() represents the interpolation operation.

9. A real-time ocean wave simulation system based on a clipmap grid, characterized in that, It includes a base network generation module, a level division and wave data generation module, a data update and frustum culling module, an offset calculation module, and an inter-level interpolation and transition module; The base network generation module is used to generate a base mesh for the clipmap mesh instance; The level division and wave data generation module is used to select the Gerstner wave function for wave simulation, preprocess the wave parameters represented by the Gerstner wave function, and generate level division information and random multi-level wave data; The data update and frustum culling module is used to update the vertex data of the clipmap mesh instance according to the camera view when performing per-frame rendering in real time, and at the same time perform frustum culling on the clipmap mesh; The offset calculation module is used to calculate the vertex offset and the offset normal after wave superposition for each real-time vertex based on multi-level wave data and level division information, including: Among them, P(x, z, t) is the offset of each vertex represented by coordinates (x, z) at time t, y is the initial height of the current vertex, N is the number of waves, A i is the amplitude of the i-th wave, k i is the direction vector of the wave, which defines the propagation direction of the wave, Q i is a parameter used to control the sharpness of the wave, ω i is the angular frequency of the wave, L i is the wavelength of the wave, is the moving speed of the wave, and g is the acceleration due to gravity; Calculating the tangent line B(x, z, t) and the binormal line T(x, z, t) by taking partial derivatives of x and z in formula (1), and obtaining the normal line Normal(x, z, t) by taking the cross product of B(x, z, t) and T(x, z, t); The inter-level interpolation transition module is used to perform interpolation transition on the wave data of two levels at the boundary during wave superposition.

Citation Information

Patent Citations

  • A simulation method for large-scale terrain roam based on rule grid

    CN101261743A

  • Three-dimensional terrain model real-time smooth drawing method with combination of GPU technology

    CN105336003A