Foam effect rendering method, rendering device, electronic equipment, storage medium

CN116012512BActive Publication Date: 2026-08-21NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211714665.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2026-08-21
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

但使用雅克比矩阵需要消耗较大的硬件资源,对于硬件资源有限的终端设备,这种渲染方式容易导致系统运行卡顿,以及终端设备的发热现象

Benefits of technology

[0022]本发明的其他特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116012512B_ABST
    Figure CN116012512B_ABST
Patent Text Reader

Abstract

The application provides a foam effect rendering method, a rendering device, an electronic device and a storage medium, and relates to the technical field of computers.The foam effect rendering method comprises the following steps: acquiring vertex normal information of a target water body model; determining a first initial area on the target water body model based on the normal information; in the first initial area, the degree of change of the normal direction is higher than a preset degree threshold; determining a second initial area on the target water body model according to a preset height mask function; the position height of the vertex in the second initial area is higher than a preset height threshold; determining a first foam rendering area based on the first initial area and the second initial area, rendering the first foam rendering area based on a preset first foam texture map, and obtaining the foam effect of the target water body model.The foam effect rendering method provided in the application can simulate the sea foam effect on the target water body model with lower performance overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for rendering a bubble effect. Background Technology

[0002] In virtual scenes, to simulate realistic dynamic water bodies, foam effects need to be rendered on the water surface. Related technologies typically use a Jacobian matrix to identify the wave crest regions of the water, determine the foam rendering area based on these regions, and then render the foam effect within that area. However, using a Jacobian matrix consumes significant hardware resources. For terminal devices with limited hardware resources, this rendering method can easily lead to system lag and overheating. Summary of the Invention

[0003] In view of this, the present invention provides a rendering method, rendering device, electronic device, and storage medium for foam effects, which can simulate marine foam effects on a target water body model with lower performance overhead.

[0004] In a first aspect, embodiments of the present invention provide a method for rendering a foam effect, comprising: acquiring vertex normal information of a target water body model; wherein the normal information includes: the normal direction of vertices on the target water body model; determining a first initial region on the target water body model based on the normal information; wherein, in the first initial region, the normal direction of the vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset degree threshold; determining a second initial region on the target water body model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold; determining a first foam rendering region based on the first initial region and the second initial region; rendering the first foam rendering region based on a preset first foam texture map to obtain a foam effect of the target water body model.

[0005] According to the foregoing embodiments of the first aspect of the present invention, the step of determining a first initial region on the target water body model based on the normal information includes: determining the gradient result of the normal direction corresponding to at least two vertices having a specified distance on the target water body model; determining the vertex whose gradient result is greater than a preset gradient threshold as a first vertex; and forming a first initial region through the first vertex.

[0006] According to any of the foregoing embodiments of the first aspect of the present invention, the step of determining a second initial region on the target water body model according to a preset height masking function includes: determining a reference height of the target water body model; determining a second vertex as a vertex on the target water body model whose position height is higher than the reference height and whose height difference between the position height and the reference height is greater than a preset height difference threshold; and forming a second initial region through the second vertex.

[0007] According to any of the foregoing embodiments of the first aspect of the present invention, the step of determining a first foam rendering region based on the first initial region and the second initial region includes: determining the intersection region of the first initial region and the second initial region as the first foam rendering region.

[0008] According to any of the foregoing embodiments of the first aspect of the present invention, the method further includes: determining a shore region on the target water body model according to the preset height masking function; wherein the position height of the vertices in the shore region is within a preset height range; acquiring a terrain model adjacent to the target water body model; wherein, in the height direction of world space, the target water body model occludes a portion of the terrain model; determining a shore region from the terrain model based on the height information of the terrain model; determining a second foam rendering region from the shore region based on the region edge of the shore region; wherein the nearest distance between the vertices in the second foam rendering region and the region edge is less than a preset distance threshold; rendering the second foam rendering region based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model.

[0009] According to any of the foregoing embodiments of the first aspect of the present invention, the step of determining the shore area on the target water body model according to the preset height masking function includes: determining the reference height of the target water body model; determining the vertex on the target water body model whose position height is lower than the reference height and whose height difference with the reference height is within a preset height difference range as the third vertex; and forming the shore area through the third vertex.

[0010] According to any of the foregoing embodiments of the first aspect of the present invention, the step of determining the shore area from the terrain model based on the height information of the terrain model includes: determining the reference height of the target water body model; determining a fourth vertex from the terrain model whose position height is higher than the reference height, and forming the shore area through the fourth vertex.

[0011] According to any of the foregoing embodiments of the first aspect of the present invention, the step of determining a second foam rendering region from the shore region based on the region edge of the shore region includes: determining the nearest distance between a vertex in the shore region and the region edge for each vertex in the shore region; determining a fifth vertex in the shore region whose nearest distance is less than a preset distance threshold, and forming a second foam rendering region through the fifth vertex.

[0012] According to any of the foregoing embodiments of the first aspect of the present invention, the step of rendering the second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model includes: obtaining weather state parameters in world space, determining foam movement parameters based on the weather state parameters; determining foam movement trajectory based on the foam movement parameters; and rendering vertices on the foam movement trajectory based on the preset second foam texture map to obtain the foam effect of the target water body model.

[0013] According to any of the foregoing embodiments of the first aspect of the present invention, the weather state parameters include: wind direction parameters and wind speed parameters; the step of determining foam movement parameters based on the weather state parameters includes: determining the foam movement direction based on the wind direction parameters; determining the foam movement phase based on the wind speed parameters; and determining the foam movement direction and the foam movement phase as foam movement parameters.

[0014] According to any of the foregoing embodiments of the first aspect of the present invention, after the step of determining the bubble movement trajectory based on the bubble movement parameters, the method further includes: obtaining the height difference between a vertex in the second bubble rendering region and a vertex at a specified location in the terrain model; wherein, in the height direction of world space, the vertex in the second bubble rendering region overlaps with the vertex at the specified location in the terrain model; and determining the bubble fluctuation amplitude corresponding to the vertex in the second bubble rendering region based on the height difference.

[0015] According to any of the foregoing embodiments of the first aspect of the present invention, after the step of determining the foam movement trajectory based on the foam movement parameters, the method further includes: obtaining the minimum distance between a vertex in the second foam rendering region and the edge of the region, and determining the foam wave wavelength corresponding to the vertex in the second foam rendering region based on the minimum distance.

[0016] According to any of the foregoing embodiments of the first aspect of the present invention, the step of rendering the second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model includes: acquiring preset foam image texture and foam noise texture; wherein the foam noise texture is generated by a random noise function; superimposing the foam image texture and the foam noise texture to obtain a superposition result; and rendering the vertices on the foam movement trajectory based on the superposition result to obtain the foam effect of the target water body model.

[0017] Secondly, embodiments of the present invention provide a rendering apparatus for a foam effect, the apparatus comprising: a normal information acquisition module, configured to acquire vertex normal information of a target water body model; wherein the normal information includes: the normal direction of vertices on the target water body model; a first initial region determination module, configured to determine a first initial region on the target water body model based on the normal information; wherein, in the first initial region, the normal direction of the vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset degree threshold; a second initial region determination module, configured to determine a second initial region on the target water body model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold; and a first foam rendering module, configured to determine a first foam rendering region based on the first initial region and the second initial region, and to render the first foam rendering region based on a preset first foam texture map to obtain a foam effect of the target water body model.

[0018] According to the foregoing embodiment of the second aspect of the present invention, the foam effect rendering apparatus further includes: a shore area determination module, configured to determine a shore area on the target water body model according to the preset height masking function; wherein the position height of the vertices in the shore area is within a preset height range; a terrain model acquisition module, configured to acquire a terrain model adjacent to the target water body model; wherein, in the height direction of world space, the target water body model occludes a portion of the terrain model; a shore area determination module, configured to determine a shore area from the terrain model based on the height information of the terrain model; a second foam rendering module, configured to determine a second foam rendering area from the shore area based on the area edge of the shore area; wherein the nearest distance between the vertices in the second foam rendering area and the area edge is less than a preset distance threshold; and a module for rendering the second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model.

[0019] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement a method for rendering a bubble effect according to any of the foregoing embodiments of the first aspect of the present invention.

[0020] Fourthly, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement a method for rendering a bubble effect according to any of the foregoing embodiments of the first aspect of the present invention.

[0021] According to embodiments of the present invention, a method, apparatus, electronic device, and machine-readable storage medium for rendering foam effects acquire vertex normal information of a target water body model. On one hand, based on the normal information, a first initial region is determined on the target water body model, where the degree of change in the normal direction is higher than a preset threshold. On the other hand, according to a preset height masking function, a second initial region is determined on the target water body model, where the position height of the vertices in the second initial region is higher than a preset height threshold. Then, a first foam rendering region is determined based on the first and second initial regions, which is equivalent to obtaining a region in the target water body model where the normal changes drastically and the height is also high. This region is the wave crest region in the target water body model, and the first foam rendering region can simulate the region of drastic wave movement on a real sea surface. The first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water body model, i.e., to simulate a sea foam effect on the target water body model. The above embodiments, in simulating a sea foam effect, no longer use a Jacobian matrix to obtain the first foam rendering region, which can greatly save on hardware performance consumption, thereby simulating a sea foam effect on the target water body model with lower performance overhead.

[0022] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.

[0023] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0024] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0025] Figure 1 A flowchart illustrating a method for rendering a foam effect according to an embodiment of the present invention;

[0026] Figure 2 A graphical user interface diagram illustrating the determination of a first foam rendering area in a foam effect rendering method provided in an embodiment of the present invention;

[0027] Figure 3 This is a graphical user interface diagram illustrating the rendering of a first foam rendering area to obtain a foam effect in a foam effect rendering method provided in an embodiment of the present invention.

[0028] Figure 4 A flowchart of a method for rendering a foam effect according to another embodiment of the present invention;

[0029] Figure 5 A schematic diagram of the interface for the height information texture in a foam effect rendering method provided in another embodiment of the present invention;

[0030] Figure 6 A schematic diagram of the masking information texture in a foam effect rendering method provided in another embodiment of the present invention;

[0031] Figure 7 A schematic diagram of the interface for the distance field information texture in a foam effect rendering method provided in another embodiment of the present invention;

[0032] Figure 8 This is a graphical user interface diagram illustrating the rendering of a second foam rendering area to obtain a foam effect in a foam effect rendering method provided in an embodiment of the present invention.

[0033] Figure 9 A graphical user interface diagram illustrating a method for rendering a foam effect according to an embodiment of the present invention, which uses a method of superimposing a foam image texture and a foam noise texture to obtain a foam effect;

[0034] Figure 10 A graphical user interface diagram illustrating a method for rendering a foam effect according to an embodiment of the present invention, which uses a different foam image texture and a foam noise texture superimposed to obtain the foam effect.

[0035] Figure 11A structural block diagram of a foam effect rendering apparatus provided in one embodiment of the present invention;

[0036] Figure 12 A structural block diagram of a foam effect rendering apparatus provided in another embodiment of the present invention;

[0037] Figure 13 This is a structural block diagram of an electronic device provided in one embodiment of the present invention. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0039] In virtual scenes, to simulate realistic dynamic water bodies, foam effects need to be rendered on the water surface. Related technologies typically use a Jacobian matrix to identify the wave crest regions of the water, determine the foam rendering area based on these regions, and then render the foam effect within that area. However, using a Jacobian matrix consumes significant hardware resources. For terminal devices with limited hardware resources, this rendering method can easily lead to system lag and overheating.

[0040] Based on this, the present invention provides a method, apparatus, electronic device and machine-readable storage medium for rendering foam effects, which can simulate marine foam effects on a target water body model with lower performance overhead.

[0041] The foam effect rendering method in one embodiment of the present invention can run on a local terminal device or a server. When the foam effect rendering method runs on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0042] In some alternative implementations, various cloud applications, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program and the game screen presentation are separated. The storage and execution of the bubble effect rendering method are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, the information processing is performed by the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game screen and other data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.

[0043] In some alternative implementations, taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the player through a graphical user interface (GUI), i.e., conventionally downloading, installing, and running the game program via an electronic device. The local terminal device can provide the GUI to the player in various ways, such as rendering it on the terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen for displaying the GUI, which includes game screens, and a processor for running the game, generating the GUI, and controlling the display of the GUI on the display screen.

[0044] In one possible implementation, the present invention provides a method for rendering a bubble effect, which provides a graphical user interface through a terminal device, wherein the terminal device may be the aforementioned local terminal device or a client device in the aforementioned cloud interactive system.

[0045] To facilitate understanding of this embodiment, a detailed description of a foam effect rendering method disclosed in this embodiment of the invention will be provided first. Figure 1 This is a flowchart illustrating a method for rendering a foam effect according to an embodiment of the present invention. In this embodiment, the method for rendering a foam effect includes steps S110 to S140.

[0046] In step S110, the vertex normal information of the target water body model is obtained; wherein, the normal information includes: the normal direction of the vertex on the target water body model.

[0047] In step S120, a first initial region is determined on the target water body model based on the normal information; wherein, in the first initial region, the normal direction of the vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset degree threshold.

[0048] In some embodiments, step S120 of determining a first initial region on a target water body model includes: determining the gradient results of the normal directions corresponding to at least two vertices that are at least a specified distance from each other on the target water body model; determining the vertices whose gradient results are greater than a preset gradient threshold as first vertices; and forming a first initial region through the first vertices.

[0049] The initial region is the area on the target water model where the change in the normal direction exceeds a preset threshold, i.e., the region where the normal changes drastically. Specifically, the rate of change of the normal can be calculated; the region with a large rate of change is the region where the normal changes drastically. Because the normal is three-dimensional data, the rate of change of the normal can be obtained by calculating the partial derivative. In the shader, the partial derivative can be calculated using the API's built-in functions `ddx` and `ddy`. Currently, graphics processing units (GPUs) typically render pixels in 2×2 pixel blocks, and `ddx` and `ddy` can calculate how much a certain attribute value has changed within a pixel's (vertex's) span in the current horizontal and vertical directions of the screen. Therefore, by passing the normal information to `ddx` and `ddy`, the gradient of the normal between two adjacent pixels (vertexes) can be easily obtained, i.e., the rate of change of the normal.

[0050] In step S130, a second initial region is determined on the target water body model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold.

[0051] In some embodiments, step S130 of determining a second initial region on a target water body model according to a preset height masking function includes: determining a reference height of the target water body model; determining a second vertex as a vertex on the target water body model whose position height is higher than the reference height and whose height difference between the position height and the reference height is greater than a preset height difference threshold; and forming a second initial region through the second vertices.

[0052] In the above embodiments, the position and height of each vertex of the target water body model are compared with the reference height. Since the values ​​of world space coordinates are large, in some cases, the subtraction may not yield the correct masking range. Therefore, a coefficient can be introduced to adjust the result, narrowing it down to a reasonable range for subsequent use.

[0053] In step S140, a first foam rendering area is determined based on a first initial area and a second initial area, and the first foam rendering area is rendered based on a preset first foam texture map to obtain the foam effect of the target water model.

[0054] In this embodiment, step S140 of determining the first foam rendering region based on the first initial region and the second initial region includes: determining the intersection region of the first initial region and the second initial region as the first foam rendering region.

[0055] Figure 2 This is a graphical user interface diagram illustrating the determination of a first foam rendering area in a foam effect rendering method provided in an embodiment of the present invention. Figure 2 In the image, the brighter white area is the first bubble rendering area, which is equivalent to the wave crest area on the target water body model.

[0056] After determining the first foam rendering area, the first foam rendering area is rendered based on the preset first foam texture map to obtain the foam effect of the target water model. Figure 3 This is a graphical user interface diagram illustrating the rendering of a first foam rendering area to obtain a foam effect in a foam effect rendering method provided in an embodiment of the present invention. Figure 3 The example demonstrates a first foam texture map, which is rendered on a first foam rendering area (wave crest area) to simulate the effect of sea wave crest foam on a target water body model. In other embodiments, different first foam texture maps can be used depending on the artistic style requirements.

[0057] According to the foam effect rendering method of the present invention, vertex normal information of a target water body model is obtained. On one hand, based on the normal information, a first initial region is determined on the target water body model, where the degree of change in the normal direction is higher than a preset degree threshold. On the other hand, according to a preset height masking function, a second initial region is determined on the target water body model, where the position height of the vertices in the second initial region is higher than a preset height threshold. Then, a first foam rendering region is determined based on the first and second initial regions, which is equivalent to obtaining a region in the target water body model where the normal changes drastically and the height is relatively high. This region is the wave crest region in the target water body model. The first foam rendering region can simulate the region where the wave movement is more intense on the real sea surface. The first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water body model, that is, to simulate the sea foam effect on the target water body model. In the process of simulating the sea foam effect, the above implementation method no longer uses the Jacobian matrix to obtain the first foam rendering region, which can greatly save the consumption of hardware performance, thereby simulating the sea foam effect on the target water body model with lower performance overhead, and is more convenient to apply to mobile platform terminal devices.

[0058] In virtual scenes, to simulate realistic dynamic water bodies, it's often necessary to render foam effects along the shoreline. Related techniques typically use a depth buffer to calculate the height difference between the sea surface and seabed topography to determine the range and location of the shoreline foam, and then use periodic functions to dynamically change the foam. Using a depth buffer requires generating a full-screen resolution depth texture in real-time with high data precision, resulting in a large texture size that consumes significant GPU bandwidth, making it unsuitable for mobile platforms. Furthermore, the periodic functions used in these techniques cannot interact with game parameters; they are empirical models rather than reality-based simulations. For example, wind speed and direction in a virtual scene won't affect the shoreline foam, resulting in a rather rigid rendering effect.

[0059] Figure 4 A flowchart of a method for rendering a foam effect according to another embodiment of the present invention. In this embodiment, the method for rendering a foam effect includes steps S210 to S290.

[0060] In step S210, the vertex normal information of the target water body model is obtained; wherein, the normal information includes: the normal direction of the vertex on the target water body model.

[0061] In step S220, a first initial region is determined on the target water body model based on normal information; wherein, in the first initial region, the normal direction of a vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset threshold. In some embodiments, step S220 of determining the first initial region on the target water body model includes: determining the gradient results of the normal directions corresponding to at least two vertices with a specified distance on the target water body model; determining the vertex whose gradient result is greater than a preset gradient threshold as the first vertex; and forming the first initial region through the first vertex.

[0062] In step S230, a second initial region is determined on the target water body model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold. In some embodiments, step S230 of determining the second initial region on the target water body model according to the preset height masking function includes: determining the reference height of the target water body model; determining the vertices on the target water body model whose position height is higher than the reference height and whose height difference with the reference height is greater than a preset height difference threshold as second vertices; and forming the second initial region by the second vertices.

[0063] In step S240, a first foam rendering region is determined based on a first initial region and a second initial region, and the first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water model. In this embodiment, step S240 of determining the first foam rendering region based on the first initial region and the second initial region includes: determining the intersection region of the first initial region and the second initial region as the first foam rendering region.

[0064] In step S250, a shoreline region is determined on the target water body model according to a preset height masking function; wherein the position height of the vertices in the shoreline region is within a preset height range.

[0065] In some embodiments, step S250 of determining the shore area on the target water body model according to a preset height masking function includes: determining the reference height of the target water body model; determining the third vertex as the vertex on the target water body model whose position height is lower than the reference height and whose height difference between the position height and the reference height is within a preset height difference range; and forming the shore area by the third vertex.

[0066] In step S260, a terrain model adjacent to the target water body model is obtained; wherein, in the height direction of world space, the target water body model occludes part of the terrain model.

[0067] In step S270, the onshore area is determined from the terrain model based on the height information of the terrain model.

[0068] In some embodiments, step S270 of determining the shore area from the terrain model based on the height information of the terrain model includes: determining the reference height of the target water body model; determining a fourth vertex from the terrain model whose position height is higher than the reference height, and forming the shore area through the fourth vertex.

[0069] In step S280, a second foam rendering region is determined from the shore region based on the region edge of the shore region; wherein the nearest distance between the vertex in the second foam rendering region and the region edge is less than a preset distance threshold.

[0070] In some embodiments, step S280 of determining a second foam rendering region from the shore region based on the region edge of the shore region includes: determining the nearest distance between a vertex in the shore region and the region edge for each vertex in the shore region; determining a fifth vertex in the shore region whose nearest distance is less than a preset distance threshold, and forming a second foam rendering region through the fifth vertex.

[0071] In the above embodiment, the nearest distance between a vertex and the edge of the second foam rendering region is less than a preset distance threshold. This is equivalent to determining the second foam rendering region based on the Signed Distance Field (SDF), which corresponds to the area in the shore region where the shore foam effect is to be rendered. In the above embodiment, a non-real-time distance field texture is generated instead of a depth buffer to confirm the location of the shore foam, i.e., to confirm the second foam rendering region. The specific process of generating the non-real-time distance field texture will be described below.

[0072] First, a height information texture is generated. Based on the target water body model and the adjacent terrain model, the reference height of the target water body model is determined. The height information texture is generated by calculating the height difference between the terrain model below the reference height and the reference height, and it is stored in the first channel of the texture, for example, the red (R) channel. Figure 5 This is a schematic diagram of the height information texture interface in a foam effect rendering method provided in another embodiment of the present invention. Using the above calculation method, the black area on the height information texture refers to the shore area, while the area with a gray gradient corresponds to the area of ​​the target water body model. Hereinafter, the area corresponding to the target water body model will be referred to as the water body area.

[0073] Then, a mask information texture is generated. The color of the texture pixels is changed by applying a certain threshold to the height information texture. Each pixel corresponds to a model vertex. Colors greater than the threshold have a value of 0, and colors less than the threshold have a value of 1. This results in a black-and-white mask information texture, which is stored in the second channel of the texture, for example, the green (G) channel. Figure 6 This is a schematic diagram of the interface for masking information texture in a foam effect rendering method provided in another embodiment of the present invention. Regarding pixel information, each pixel originally stores the terrain model below the reference height and the height difference data of the reference height. After converting this into masking information texture, each pixel is marked as being located in a water area or a shore area.

[0074] Next, a distance field information texture is generated. When determining the position of a pixel, only the distance to the shore area needs to be determined, so it is not necessary to calculate the pixel information of all water areas. This can be achieved by introducing a parameter to set the maximum distance to be calculated; pixel information exceeding this distance will not be recorded. The size of this parameter depends on the required texture resolution. Finally, the distance from the current pixel to the shore is calculated using the Pythagorean theorem. Due to the discretization of pixel values, the final distance is not a continuous distance, but rather a series of segments, similar to jagged edges. Therefore, to obtain a smoother result, the generated distance field information texture can be blurred. For example, a mean blurring method can be used, which involves sampling several pixels surrounding the current pixel, averaging all color values, and then returning the result to the current pixel. The distance field information texture generated after the blurring operation is stored in the third channel of the texture, such as the blue (B) channel. Figure 7 A schematic diagram of the interface for distance field information texture in a foam effect rendering method provided in another embodiment of the present invention.

[0075] After generating the distance field information texture, the aforementioned non-real-time distance field texture is obtained. The first channel of the non-real-time distance field texture is height information, the second channel is masking information, and the third channel is distance field information. After obtaining the non-real-time distance field texture, it can be sampled in the vertex shader along the X and Z axes of world space coordinates, which can further save performance overhead. Sampling in the vertex shader is then passed to the pixel shader. First, the distance field information needs to be processed. When generating the distance field information texture, the water area is white, while the shore area is black, which is inconsistent with the masking information. Therefore, the colors of the distance field information texture need to be inverted for adaptation. Next, a parameter can be introduced to control the range of the masking information. Finally, the adjusted distance field information and the masking information are multiplied to obtain the location where the bubbles appear on the shore, thus determining the second bubble rendering area.

[0076] like Figure 4 In step S290, based on preset foam movement parameters and a second foam texture map, a second foam rendering area is rendered to obtain the foam effect of the target water model.

[0077] In some embodiments, step S290, which renders a second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain a foam effect of the target water body model, includes: obtaining weather state parameters in the world space, determining foam movement parameters based on the weather state parameters, determining a foam movement trajectory based on the foam movement parameters, and rendering vertices on the foam movement trajectory based on the preset second foam texture map to obtain a foam effect of the target water body model.

[0078] Specifically, in some embodiments, the weather state parameters include wind direction parameters and wind speed parameters. In this case, the step of determining the foam movement parameters based on the weather state parameters may include: determining the foam movement direction based on the wind direction parameters; determining the foam movement phase based on the wind speed parameters; and determining the foam movement direction and foam movement phase as the foam movement parameters.

[0079] Optionally, after determining the bubble movement trajectory based on the bubble movement parameters, the bubble effect rendering method further includes: obtaining the height difference between the vertices in the second bubble rendering area and the vertices at specified locations in the terrain model; wherein, in the height direction of world space, the vertices in the second bubble rendering area overlap with the vertices at specified locations in the terrain model; and determining the bubble fluctuation amplitude corresponding to the vertices in the second bubble rendering area based on the height difference.

[0080] Optionally, after determining the bubble movement trajectory based on the bubble movement parameters, the bubble effect rendering method further includes: obtaining the minimum distance between the vertex and the edge of the region in the second bubble rendering region, and determining the bubble wave wavelength corresponding to the vertex in the second bubble rendering region based on the minimum distance.

[0081] Figure 8 This is a graphical user interface diagram illustrating the rendering of a second foam rendering area to obtain a foam effect in a foam effect rendering method provided in one embodiment of the present invention. By rendering the second foam rendering area, a shoreline foam effect is simulated on a target water body model. According to the foam effect rendering method of the above embodiment, the shoreline foam effect rendered in the second foam rendering area can interact with weather conditions. The direction of foam movement is determined based on wind direction parameters, and the phase of foam movement is determined based on wind speed parameters, so that the shoreline foam effect changes with weather conditions. Furthermore, the foam fluctuation amplitude corresponding to a vertex in the second foam rendering area is determined based on the height difference between a vertex in the second foam rendering area and a vertex at a specified location in the terrain model. The distance field information is used to control the foam fluctuation wavelength, making the shoreline foam effect more natural.

[0082] In some embodiments, step S290, which renders a second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model, includes: acquiring preset foam image texture and foam noise texture; wherein the foam noise texture is generated by a random noise function; superimposing the foam image texture and the foam noise texture to obtain a superimposed result; and rendering vertices on the foam movement trajectory based on the superimposed result to obtain the foam effect of the target water body model. By changing the foam image texture, or by sampling the foam image texture and the foam noise texture with different parameters, different foam effects can be obtained after superimposing. For example... Figure 9This is a graphical user interface diagram illustrating a method for rendering a foam effect according to an embodiment of the present invention, which uses a method of superimposing a foam image texture and a foam noise texture to obtain the foam effect. Figure 10 This is a graphical user interface diagram illustrating a method for rendering a foam effect according to an embodiment of the present invention, which uses a different foam image texture and a foam noise texture to overlay the foam effect. By transforming the foam image texture and overlaying it with the foam noise texture, a wide variety of variations in the foam effect can be achieved.

[0083] According to the foam effect rendering method of the above embodiment, vertex normal information of the target water body model is obtained. On the one hand, based on the normal information, a first initial region is determined on the target water body model. In the first initial region, the degree of change in the normal direction is higher than a preset degree threshold. On the other hand, according to a preset height masking function, a second initial region is determined on the target water body model. The position height of the vertices in the second initial region is higher than a preset height threshold. Then, a first foam rendering region is determined based on the first and second initial regions. This is equivalent to obtaining a region in the target water body model where the normal changes drastically and the height is relatively high. This region is the wave crest region in the target water body model. The first foam rendering region can simulate the region where the wave movement is more intense on the real sea surface. The first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water body model, that is, to simulate the sea foam effect on the target water body model. In the process of simulating the sea foam effect, the above implementation method no longer uses the Jacobian matrix to obtain the first foam rendering region, which can greatly save the consumption of hardware performance, thereby simulating the sea foam effect on the target water body model with lower performance overhead.

[0084] According to the foam effect rendering method of the above embodiment, a shore area is determined on the target water model based on a preset height masking function. Based on the height information of the terrain model, a shore area is determined from the terrain model. Based on the edge of the shore area, a second foam rendering area is determined from the shore area, wherein the nearest distance between the vertices and the edge of the second foam rendering area is less than a preset distance threshold. This second foam rendering area is equivalent to the area in the shore area where the shore foam effect is to be rendered. The fact that the nearest distance between the vertices and the edge of the second foam rendering area is less than the preset distance threshold is equivalent to determining the second foam rendering area based on a distance field. Compared with the scheme of obtaining the second foam rendering area using a depth buffer, this significantly reduces the consumption of hardware performance, thereby simulating the shore foam effect on the target water model with lower performance overhead, and is more easily applied to mobile platform terminal devices.

[0085] This invention also provides a rendering device for a foam effect. Figure 11This is a structural block diagram of a foam effect rendering apparatus according to an embodiment of the present invention. In this embodiment, the foam effect rendering apparatus includes a normal information acquisition module 110, a first initial region determination module 120, a second initial region determination module 130, and a first foam rendering module 140.

[0086] The normal information acquisition module 110 is used to acquire the vertex normal information of the target water body model; wherein, the normal information includes: the normal direction of the vertex on the target water body model.

[0087] The first initial region determination module 120 is used to determine a first initial region on the target water body model based on normal information; wherein, in the first initial region, the normal direction of the vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset degree threshold.

[0088] The second initial region determination module 130 is used to determine a second initial region on the target water body model according to a preset height masking function; wherein the position height of the vertices in the second initial region is higher than a preset height threshold.

[0089] The first foam rendering module 140 is used to determine the first foam rendering area based on the first initial area and the second initial area, and to render the first foam rendering area based on the preset first foam texture map to obtain the foam effect of the target water model.

[0090] In some embodiments, the first initial region determination module 120 is configured to: determine the gradient results of the normal directions of at least two vertices that are at least a specified distance from each other on the target water body model; determine the vertices whose gradient results are greater than a preset gradient threshold as first vertices; and form a first initial region through the first vertices.

[0091] In some embodiments, the second initial region determination module 130 is configured to: determine the reference height of the target water body model; determine the vertex on the target water body model whose position height is higher than the reference height and whose height difference between the position height and the reference height is greater than a preset height difference threshold as the second vertex; and form the second initial region through the second vertex.

[0092] In some embodiments, the first foam rendering module 140 is configured to: determine the intersection area of ​​the first initial region and the second initial region as the first foam rendering region.

[0093] According to an embodiment of the present invention, a foam effect rendering apparatus includes a normal information acquisition module 110 acquiring vertex normal information of a target water model, a first initial region determination module 120 determining a first initial region on the target water model based on the normal information, wherein the degree of change in the normal direction in the first initial region is higher than a preset degree threshold, and a second initial region determination module 130 determining a second initial region on the target water model according to a preset height masking function, wherein the position height of the vertices in the second initial region is higher than a preset height threshold. A first foam rendering module 140 determines a first foam rendering region based on the first and second initial regions, which is equivalent to obtaining a region in the target water model where the normal changes drastically and the height is relatively high, i.e., the wave crest region in the target water model. This first foam rendering region can simulate a region where the wave movement is relatively violent on the real sea surface. The first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water model, i.e., to simulate the sea foam effect on the target water model. The above implementation method no longer uses the Jacobian matrix to obtain the first foam rendering area in the process of simulating the marine foam effect, which can greatly save the consumption of hardware performance. Thus, it can simulate the marine foam effect on the target water body model with lower performance overhead, and is more convenient to be applied to mobile platform terminal devices.

[0094] Figure 12 This is a structural block diagram of a foam effect rendering apparatus provided in another embodiment of the present invention. In another embodiment, the foam effect rendering apparatus includes a normal information acquisition module 210, a first initial region determination module 220, a second initial region determination module 230, a first foam rendering module 240, a shore region determination module 250, a terrain model acquisition module 260, a shore region determination module 270, and a second foam rendering module 280.

[0095] The normal information acquisition module 210 is used to acquire the vertex normal information of the target water body model; wherein, the normal information includes: the normal direction of the vertex on the target water body model.

[0096] The first initial region determination module 220 is used to determine a first initial region on the target water body model based on normal information; wherein, in the first initial region, the normal direction of the vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset degree threshold.

[0097] The second initial region determination module 230 is used to determine a second initial region on the target water body model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold.

[0098] The first foam rendering module 240 is used to determine the first foam rendering area based on the first initial area and the second initial area, and to render the first foam rendering area based on the preset first foam texture map to obtain the foam effect of the target water model.

[0099] The normal information acquisition module 210 acquires the vertex normal information of the target water body model. The first initial region determination module 220 determines a first initial region on the target water body model based on the normal information. In the first initial region, the degree of change in the normal direction is higher than a preset degree threshold. The second initial region determination module 230 determines a second initial region on the target water body model according to a preset height masking function, wherein the position height of the vertices in the second initial region is higher than a preset height threshold. The first foam rendering module 240 determines a first foam rendering region based on the first and second initial regions. This is equivalent to obtaining a region in the target water body model where the normal changes drastically and the height is relatively high. This region is the wave crest region in the target water body model. This first foam rendering region can simulate a region with drastic wave movement on the real sea surface. The first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water body model, that is, to simulate the sea foam effect on the target water body model. The above implementation method eliminates the need to use the Jacobian matrix to obtain the first foam rendering area during the simulation of marine foam effects, which greatly saves on hardware performance consumption and thus simulates marine foam effects on the target water body model with lower performance overhead.

[0100] The shore area determination module 250 is used to determine the shore area on the target water body model according to a preset height masking function; wherein the position height of the vertices in the shore area is within a preset height range.

[0101] The terrain model acquisition module 260 is used to acquire terrain models adjacent to the target water body model; wherein, in the height direction of world space, the target water body model occludes part of the terrain model.

[0102] The shore area determination module 270 is used to determine the shore area from the terrain model based on the height information of the terrain model.

[0103] The second foam rendering module 280 is used to determine a second foam rendering area from the shore area based on the area edge of the shore area; wherein the nearest distance between the vertex in the second foam rendering area and the area edge is less than a preset distance threshold; and to render the second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model.

[0104] According to the foam effect rendering apparatus of this embodiment, the shore region determination module 250 determines the shore region on the target water body model based on a preset height masking function. The shore region determination module 270 determines the shore region from the terrain model based on the height information of the terrain model. The second foam rendering module 280 determines a second foam rendering region from the shore region based on the region edge of the shore region. The nearest distance between the vertices and the region edge in the second foam rendering region is less than a preset distance threshold. This second foam rendering region is equivalent to the area in the shore region where the shore foam effect is to be rendered. The fact that the nearest distance between the vertices and the region edge in the second foam rendering region is less than the preset distance threshold is equivalent to determining the second foam rendering region based on a distance field. Compared with the scheme of obtaining the second foam rendering region using a depth buffer, this significantly reduces the consumption of hardware performance, thereby simulating the shore foam effect on the target water body model with lower performance overhead, making it more suitable for application on mobile platform terminal devices.

[0105] In some embodiments, the first initial region determination module 220 is configured to: determine the gradient results of the normal directions of at least two vertices that are at least a specified distance from each other on the target water body model; determine the vertices whose gradient results are greater than a preset gradient threshold as first vertices; and form a first initial region through the first vertices.

[0106] In some embodiments, the second initial region determination module 230 is configured to: determine the reference height of the target water body model; determine the vertices on the target water body model whose position height is higher than the reference height and whose height difference between the position height and the reference height is greater than a preset height difference threshold as second vertices; and form a second initial region through the second vertices.

[0107] In some embodiments, the first foam rendering module 240 is configured to determine the intersection area of ​​the first initial region and the second initial region as the first foam rendering region.

[0108] In some embodiments, the shore area determination module 250 is configured to: determine the reference height of the target water body model; determine the third vertex as the vertex on the target water body model whose position height is lower than the reference height and whose height difference with the reference height is within a preset height difference range; and form the shore area by the third vertex.

[0109] In some embodiments, the shore area determination module 270 is configured to: determine the reference height of the target water body model; determine the fourth vertex in the terrain model whose position height is higher than the reference height, and form the shore area through the fourth vertex.

[0110] In some embodiments, the second foam rendering module 280 is configured to: determine the nearest distance between a vertex in the shore region and the edge of the region for each vertex in the shore region; determine a fifth vertex in the shore region whose nearest distance is less than a preset distance threshold, and form a second foam rendering region through the fifth vertex.

[0111] In some embodiments, the second foam rendering module 280 is configured to: acquire weather state parameters in world space, determine foam movement parameters based on the weather state parameters; determine foam movement trajectory based on the foam movement parameters; and render vertices on the foam movement trajectory based on a preset second foam texture map to obtain the foam effect of the target water model.

[0112] Weather state parameters may include wind direction and wind speed parameters. Therefore, the second bubble rendering module 280 can be configured to: determine the bubble movement direction based on the wind direction parameter; determine the bubble movement phase based on the wind speed parameter; and define the bubble movement direction and bubble movement phase as bubble movement parameters.

[0113] Optionally, the rendering apparatus for the foam effect may further include a foam fluctuation amplitude control module, which is configured to: obtain the height difference between a vertex in the second foam rendering area and a vertex at a specified location in the terrain model; wherein, in the height direction of world space, the vertex in the second foam rendering area overlaps with the vertex at the specified location in the terrain model; and determine the foam fluctuation amplitude corresponding to the vertex in the second foam rendering area based on the height difference.

[0114] Optionally, the rendering apparatus for the foam effect may further include a foam wave wavelength control module, which is configured to: obtain the minimum distance between a vertex and the edge of the region in the second foam rendering region, and determine the foam wave wavelength corresponding to the vertex in the second foam rendering region based on the minimum distance.

[0115] In some embodiments, the second foam rendering module 280 is further configured to: acquire a preset foam image texture and a foam noise texture; wherein the foam noise texture is generated by a random noise function; superimpose the foam image texture and the foam noise texture to obtain a superposition result; and render the vertices on the foam movement trajectory based on the superposition result to obtain the foam effect of the target water body model.

[0116] Figure 13 The present invention provides a structural block diagram of an electronic device, which includes a processor 901 and a memory 902. The memory 902 stores machine-executable instructions that can be executed by the processor 901. The processor 901 executes the machine-executable instructions to implement the above-mentioned rendering method for the bubble effect.

[0117] The method for rendering a foam effect includes: obtaining vertex normal information of the target water model; wherein the normal information includes the direction of the normals of the vertices on the target water model; determining a first initial region on the target water model based on the normal information; wherein, in the first initial region, the direction of the normals of the vertices changes with the position of the vertices, and the degree of change of the normal direction is higher than a preset degree threshold; determining a second initial region on the target water model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold; determining a first foam rendering region based on the first and second initial regions; rendering the first foam rendering region based on a preset first foam texture map to obtain the foam effect of the target water model.

[0118] Furthermore, the electronic device may also include a communication interface 903 and a bus 904, with the processor 901, communication interface 903 and memory 902 connected via the bus 904.

[0119] The memory 902 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 903 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 904 may be an ISA bus, PCI bus, or EISA bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, a bus is represented by only a single bidirectional arrow in the accompanying drawings, but this does not imply that there is only one bus or one type of bus.

[0120] The processor 901 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 901 or by instructions in software form. The processor 901 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 902. Processor 901 reads information from memory 902 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0121] In some embodiments, the step of determining a first initial region on a target water body model based on normal information includes: determining the gradient results of the normal directions corresponding to at least two vertices that are at least a specified distance from each other on the target water body model; determining the vertices whose gradient results are greater than a preset gradient threshold as first vertices; and forming the first initial region through the first vertices.

[0122] In some embodiments, the step of determining a second initial region on a target water body model according to a preset height masking function includes: determining a reference height of the target water body model; determining a second vertex as a vertex on the target water body model whose position height is higher than the reference height and whose height difference between the position height and the reference height is greater than a preset height difference threshold; and forming a second initial region by using the second vertices.

[0123] In some embodiments, the step of determining the first foam rendering region based on the first initial region and the second initial region includes: determining the intersection region of the first initial region and the second initial region as the first foam rendering region.

[0124] In some embodiments, the method for rendering the foam effect further includes: determining a shore region on the target water model according to a preset height masking function; wherein the position height of the vertices in the shore region is within a preset height range; obtaining a terrain model adjacent to the target water model; wherein, in the height direction of world space, the target water model occludes part of the terrain model; determining a shore region from the terrain model based on the height information of the terrain model; determining a second foam rendering region from the shore region based on the region edge of the shore region; wherein the nearest distance between the vertices in the second foam rendering region and the region edge is less than a preset distance threshold; rendering the second foam rendering region based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water model.

[0125] In some embodiments, the step of determining the shore area on the target water body model according to a preset height masking function includes: determining the reference height of the target water body model; determining the vertex on the target water body model whose position height is lower than the reference height and whose height difference with the reference height is within a preset height difference range as the third vertex; and forming the shore area by the third vertex.

[0126] In some embodiments, the step of determining the shore area from the terrain model based on the height information of the terrain model includes: determining the reference height of the target water body model; determining the fourth vertex from the terrain model whose position height is higher than the reference height, and forming the shore area by the fourth vertex.

[0127] In some embodiments, the step of determining a second foam rendering region from the shore region based on the region edge of the shore region includes: determining the nearest distance between a vertex in the shore region and the region edge for each vertex in the shore region; determining a fifth vertex in the shore region whose nearest distance is less than a preset distance threshold, and forming the second foam rendering region by the fifth vertex.

[0128] In some embodiments, the step of rendering a second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain a foam effect of the target water body model includes: obtaining weather state parameters in the world space, determining foam movement parameters based on the weather state parameters; determining a foam movement trajectory based on the foam movement parameters; and rendering vertices on the foam movement trajectory based on the preset second foam texture map to obtain a foam effect of the target water body model.

[0129] In some embodiments, the steps of determining foam movement parameters based on weather state parameters, including wind direction parameters and wind speed parameters, include: determining the foam movement direction based on wind direction parameters; determining the foam movement phase based on wind speed parameters; and determining the foam movement direction and foam movement phase as foam movement parameters.

[0130] In some embodiments, after determining the bubble movement trajectory based on the bubble movement parameters, the bubble effect rendering method further includes: obtaining the height difference between a vertex in the second bubble rendering region and a vertex at a specified location in the terrain model; wherein, in the height direction of world space, the vertex in the second bubble rendering region overlaps with the vertex at the specified location in the terrain model; and determining the bubble fluctuation amplitude corresponding to the vertex in the second bubble rendering region based on the height difference.

[0131] In some embodiments, after determining the bubble movement trajectory based on the bubble movement parameters, the bubble effect rendering method further includes: obtaining the minimum distance between a vertex and the edge of the region in the second bubble rendering region, and determining the bubble wave wavelength corresponding to the vertex in the second bubble rendering region based on the minimum distance.

[0132] In some embodiments, the step of rendering a second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model includes: acquiring preset foam image texture and foam noise texture; wherein the foam noise texture is generated by a random noise function; superimposing the foam image texture and the foam noise texture to obtain a superimposed result; and rendering vertices on the foam movement trajectory based on the superimposed result to obtain the foam effect of the target water body model.

[0133] An electronic device according to an embodiment of the present invention includes a processor 901 and a memory 902. When the processor 901 executes machine-executable instructions to implement the above-described foam effect rendering method, it acquires vertex normal information of a target water body model. On one hand, based on the normal information, a first initial region is determined on the target water body model, wherein the degree of change of the normal direction in the first initial region is higher than a preset degree threshold. On the other hand, according to a preset height masking function, a second initial region is determined on the target water body model, wherein the position height of the vertices in the second initial region is higher than a preset height threshold. Then, a first foam rendering region is determined based on the first and second initial regions, which is equivalent to obtaining a region in the target water body model where the normal changes drastically and the height is relatively high. This region is the wave crest region in the target water body model. The first foam rendering region can simulate the region where the wave movement is more intense on the real sea surface. The first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water body model, that is, to simulate the sea foam effect on the target water body model. The above implementation method no longer uses the Jacobian matrix to obtain the first foam rendering area in the process of simulating the marine foam effect, which can greatly save the consumption of hardware performance. Thus, it can simulate the marine foam effect on the target water body model with lower performance overhead, and is more convenient to be applied to mobile platform terminal devices.

[0134] In the electronic devices described in the above embodiments, a shoreline region is determined on the target water body model according to a preset height masking function. Based on the height information of the terrain model, a shoreline region is determined from the terrain model. Based on the edge of the shoreline region, a second foam rendering region is determined from the shoreline region, wherein the nearest distance between a vertex in the second foam rendering region and the edge of the region is less than a preset distance threshold. This second foam rendering region is equivalent to the region in the shoreline region where the shoreline foam effect is to be rendered. The fact that the nearest distance between a vertex in the second foam rendering region and the edge of the region is less than the preset distance threshold is equivalent to determining the second foam rendering region based on a distance field. Compared with the scheme of obtaining the second foam rendering region using a depth buffer, this significantly reduces the consumption of hardware performance, thereby simulating the shoreline foam effect on the target water body model with lower performance overhead.

[0135] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by the processor, the machine-executable instructions cause the processor to implement the above-mentioned foam effect rendering method.

[0136] The machine-executable instructions stored in the aforementioned machine-readable storage medium can be executed to achieve the following operations in the above-mentioned foam effect rendering method: obtaining vertex normal information of the target water model; wherein, the normal information includes: the normal direction of the vertices on the target water model; determining a first initial region on the target water model based on the normal information; wherein, in the first initial region, the normal direction of the vertices changes with the position of the vertices, and the degree of change of the normal direction is higher than a preset degree threshold; determining a second initial region on the target water model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold; determining a first foam rendering region based on the first initial region and the second initial region, rendering the first foam rendering region based on a preset first foam texture map, and obtaining the foam effect of the target water model.

[0137] In some embodiments, the step of determining a first initial region on a target water body model based on normal information includes: determining the gradient results of the normal directions corresponding to at least two vertices that are at least a specified distance from each other on the target water body model; determining the vertices whose gradient results are greater than a preset gradient threshold as first vertices; and forming the first initial region through the first vertices.

[0138] In some embodiments, the step of determining a second initial region on a target water body model according to a preset height masking function includes: determining a reference height of the target water body model; determining a second vertex as a vertex on the target water body model whose position height is higher than the reference height and whose height difference between the position height and the reference height is greater than a preset height difference threshold; and forming a second initial region by using the second vertices.

[0139] In some embodiments, the step of determining the first foam rendering region based on the first initial region and the second initial region includes: determining the intersection region of the first initial region and the second initial region as the first foam rendering region.

[0140] In some embodiments, the method for rendering the foam effect further includes: determining a shore region on the target water model according to a preset height masking function; wherein the position height of the vertices in the shore region is within a preset height range; obtaining a terrain model adjacent to the target water model; wherein, in the height direction of world space, the target water model occludes part of the terrain model; determining a shore region from the terrain model based on the height information of the terrain model; determining a second foam rendering region from the shore region based on the region edge of the shore region; wherein the nearest distance between the vertices in the second foam rendering region and the region edge is less than a preset distance threshold; rendering the second foam rendering region based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water model.

[0141] In some embodiments, the step of determining the shore area on the target water body model according to a preset height masking function includes: determining the reference height of the target water body model; determining the vertex on the target water body model whose position height is lower than the reference height and whose height difference with the reference height is within a preset height difference range as the third vertex; and forming the shore area by the third vertex.

[0142] In some embodiments, the step of determining the shore area from the terrain model based on the height information of the terrain model includes: determining the reference height of the target water body model; determining the fourth vertex from the terrain model whose position height is higher than the reference height, and forming the shore area by the fourth vertex.

[0143] In some embodiments, the step of determining a second foam rendering region from the shore region based on the region edge of the shore region includes: determining the nearest distance between a vertex in the shore region and the region edge for each vertex in the shore region; determining a fifth vertex in the shore region whose nearest distance is less than a preset distance threshold, and forming the second foam rendering region by the fifth vertex.

[0144] In some embodiments, the step of rendering a second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain a foam effect of the target water body model includes: obtaining weather state parameters in the world space, determining foam movement parameters based on the weather state parameters; determining a foam movement trajectory based on the foam movement parameters; and rendering vertices on the foam movement trajectory based on the preset second foam texture map to obtain a foam effect of the target water body model.

[0145] In some embodiments, the steps of determining foam movement parameters based on weather state parameters, including wind direction parameters and wind speed parameters, include: determining the foam movement direction based on wind direction parameters; determining the foam movement phase based on wind speed parameters; and determining the foam movement direction and foam movement phase as foam movement parameters.

[0146] In some embodiments, after determining the bubble movement trajectory based on the bubble movement parameters, the bubble effect rendering method further includes: obtaining the height difference between a vertex in the second bubble rendering region and a vertex at a specified location in the terrain model; wherein, in the height direction of world space, the vertex in the second bubble rendering region overlaps with the vertex at the specified location in the terrain model; and determining the bubble fluctuation amplitude corresponding to the vertex in the second bubble rendering region based on the height difference.

[0147] In some embodiments, after determining the bubble movement trajectory based on the bubble movement parameters, the bubble effect rendering method further includes: obtaining the minimum distance between a vertex and the edge of the region in the second bubble rendering region, and determining the bubble wave wavelength corresponding to the vertex in the second bubble rendering region based on the minimum distance.

[0148] In some embodiments, the step of rendering a second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model includes: acquiring preset foam image texture and foam noise texture; wherein the foam noise texture is generated by a random noise function; superimposing the foam image texture and the foam noise texture to obtain a superimposed result; and rendering vertices on the foam movement trajectory based on the superimposed result to obtain the foam effect of the target water body model.

[0149] According to an embodiment of the present invention, a machine-readable storage medium stores machine-executable instructions. When these machine-executable instructions are invoked and executed by a processor, they cause the processor to implement the aforementioned foam effect rendering method. Specifically, vertex normal information of a target water body model is obtained. On one hand, based on the normal information, a first initial region is determined on the target water body model, where the degree of change in the normal direction is higher than a preset degree threshold. On the other hand, according to a preset height masking function, a second initial region is determined on the target water body model, where the position height of the vertices in the second initial region is higher than a preset height threshold. Then, a first foam rendering region is determined based on the first and second initial regions. This is equivalent to obtaining a region in the target water body model where the normal changes drastically and the height is also relatively high. This region is the wave crest region in the target water body model. This first foam rendering region can simulate a region where the movement of waves on a real sea surface is relatively violent. The first foam rendering region is rendered based on a preset first foam texture map to obtain the foam effect of the target water body model, that is, to simulate the sea foam effect on the target water body model. The above implementation method no longer uses the Jacobian matrix to obtain the first foam rendering area in the process of simulating the marine foam effect, which can greatly save the consumption of hardware performance. Thus, it can simulate the marine foam effect on the target water body model with lower performance overhead, and is more convenient to be applied to mobile platform terminal devices.

[0150] In some embodiments of the machine-readable storage medium, when machine-executable instructions are invoked and executed by a processor, a shore region is determined on the target water body model according to a preset height masking function. Based on the height information of the terrain model, a shore region is determined from the terrain model. Based on the edge of the shore region, a second foam rendering region is determined from the shore region, wherein the nearest distance between a vertex in the second foam rendering region and the edge of the region is less than a preset distance threshold. This second foam rendering region is equivalent to the area in the shore region where the shore foam effect is to be rendered. The fact that the nearest distance between a vertex in the second foam rendering region and the edge of the region is less than the preset distance threshold is equivalent to determining the second foam rendering region based on a distance field. Compared with the scheme of obtaining the second foam rendering region using a depth buffer, this significantly reduces the consumption of hardware performance, thereby simulating the shore foam effect on the target water body model with lower performance overhead.

[0151] The computer program product of the bubble effect rendering method, apparatus, electronic device and machine-readable storage medium provided in the embodiments of the present invention includes a machine-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.

[0152] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0153] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0154] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a machine-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0155] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0156] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for rendering a bubble effect, characterized in that, The method includes: Obtain vertex normal information of the target water body model; wherein, the normal information includes: the normal direction of the vertices on the target water body model; Based on the normal information, a first initial region is determined on the target water body model; wherein, in the first initial region, the normal direction of the vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset degree threshold. A second initial region is determined on the target water body model according to a preset height masking function; wherein, the position height of the vertices in the second initial region is higher than a preset height threshold. A first foam rendering area is determined based on the first initial area and the second initial area, and the first foam rendering area is rendered based on a preset first foam texture map to obtain the foam effect of the target water model. According to the preset height masking function, a shoreline region is determined on the target water body model; wherein, the position height of the vertices in the shoreline region is within the preset height range; Obtain a terrain model adjacent to the target water body model; wherein, in the height direction of world space, the target water body model occludes a portion of the terrain model. Based on the height information of the terrain model, the onshore area is determined from the terrain model; Based on the region edge of the shore area, a second foam rendering region is determined from the shore area; wherein the nearest distance between a vertex in the second foam rendering region and the region edge is less than a preset distance threshold; Based on preset foam movement parameters and a second foam texture map, the second foam rendering area is rendered to obtain the foam effect of the target water body model.

2. The method according to claim 1, characterized in that, The step of determining a first initial region on the target water body model based on the normal information includes: For at least two vertices on the target water body model that are at a specified distance, determine the gradient results of the normal directions corresponding to the at least two vertices; Vertices whose gradient results are greater than a preset gradient threshold are identified as first vertices; a first initial region is formed by the first vertices.

3. The method according to claim 1, characterized in that, The step of determining a second initial region on the target water body model according to a preset height masking function includes: Determine the reference height of the target water body model; On the target water body model, the vertex whose position height is higher than the reference height and whose height difference with the reference height is greater than a preset height difference threshold is determined as the second vertex; the second initial region is formed by the second vertex.

4. The method according to claim 1, characterized in that, The step of determining the first foam rendering region based on the first initial region and the second initial region includes: The intersection of the first initial region and the second initial region is defined as the first foam rendering region.

5. The method according to claim 1, characterized in that, The step of determining the shoreline region on the target water body model according to the preset height masking function includes: Determine the reference height of the target water body model; The vertex on the target water body model whose position height is lower than the reference height and whose height difference with the reference height is within a preset height difference range is determined as the third vertex; the shore area is formed by the third vertex.

6. The method according to claim 1, characterized in that, The step of determining the onshore area from the terrain model based on the height information of the terrain model includes: Determine the reference height of the target water body model; From the terrain model, a fourth vertex with a position height higher than the reference height is determined, and the onshore area is formed by the fourth vertex.

7. The method according to claim 1, characterized in that, The step of determining a second foam rendering region from the shore region based on the region edge of the shore region includes: For each vertex in the shoreline region, determine the nearest distance between the vertex in the shoreline region and the edge of the region; The fifth vertex, whose nearest distance is less than a preset distance threshold, is determined from the shore area, and the second foam rendering area is formed by the fifth vertex.

8. The method according to claim 1, characterized in that, The steps of rendering the second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water model include: Obtain weather state parameters in the world space, and determine bubble movement parameters based on the weather state parameters; The foam movement trajectory is determined based on the foam movement parameters; The vertices on the movement trajectory of the foam are rendered based on a preset second foam texture map to obtain the foam effect of the target water body model.

9. The method according to claim 8, characterized in that, The weather state parameters include: wind direction parameters and wind speed parameters; the step of determining the foam movement parameters based on the weather state parameters includes: The direction of foam movement is determined based on the wind direction parameter; the phase of foam movement is determined based on the wind speed parameter; and the direction of foam movement and the phase of foam movement are defined as foam movement parameters.

10. The method according to claim 8, characterized in that, After determining the foam movement trajectory based on the foam movement parameters, the method further includes: Obtain the height difference between a vertex in the second bubble rendering region and a vertex at a specified location in the terrain model; wherein, in the height direction of world space, the vertex in the second bubble rendering region overlaps with the vertex at the specified location in the terrain model; Based on the height difference, the bubble fluctuation amplitude corresponding to the vertex in the second bubble rendering area is determined.

11. The method according to claim 8, characterized in that, After determining the foam movement trajectory based on the foam movement parameters, the method further includes: Obtain the minimum distance between a vertex in the second foam rendering region and the edge of the region, and determine the foam wave wavelength corresponding to the vertex in the second foam rendering region based on the minimum distance.

12. The method according to claim 8, characterized in that, The steps of rendering the second foam rendering area based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water model include: Obtain a preset foam image texture and a foam noise texture; wherein the foam noise texture is generated by a random noise function; The foam image texture and the foam noise texture are superimposed to obtain a superimposed result; based on the superimposed result, the vertices on the foam movement trajectory are rendered to obtain the foam effect of the target water body model.

13. A rendering device for a foam effect, characterized in that, The device includes: The normal information acquisition module is used to acquire the vertex normal information of the target water body model; wherein, the normal information includes: the normal direction of the vertex on the target water body model; The first initial region determination module is used to determine a first initial region on the target water body model based on the normal information; wherein, in the first initial region, the normal direction of the vertex changes with the vertex position, and the degree of change of the normal direction is higher than a preset degree threshold. The second initial region determination module is used to determine a second initial region on the target water body model according to a preset height masking function; wherein the position height of the vertices in the second initial region is higher than a preset height threshold. The first foam rendering module is used to determine a first foam rendering area based on the first initial area and the second initial area, and to render the first foam rendering area based on a preset first foam texture map to obtain the foam effect of the target water model. The shore area determination module is used to determine the shore area on the target water body model according to the preset height masking function; wherein the position height of the vertices in the shore area is within the preset height range; The terrain model acquisition module is used to acquire terrain models adjacent to the target water body model; wherein, in the height direction of world space, the target water body model occludes part of the terrain model. The onshore area determination module is used to determine the onshore area from the terrain model based on the height information of the terrain model; The second foam rendering module is used to determine a second foam rendering region from the shore region based on the region edge of the shore region; wherein the nearest distance between the vertex in the second foam rendering region and the region edge is less than a preset distance threshold; and to render the second foam rendering region based on preset foam movement parameters and a second foam texture map to obtain the foam effect of the target water body model.

14. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the rendering method of the bubble effect according to any one of claims 1 to 12.

15. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the rendering method for the bubble effect as described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Simulation and rendering method of real-time sea system

    CN105279782A

  • Virtual sea wave generation method and device, storage medium and electronic device

    CN115100340A