Water ripple simulation method and device, electronic device, and storage medium

By obtaining the target area of ​​water ripples in 3D simulation and fitting it to the slot, the problem of wasted memory and video memory resources in the existing technology is solved, and efficient water ripple simulation is achieved.

CN116194961BActive Publication Date: 2026-06-09BOE TECHNOLOGY GROUP CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BOE TECHNOLOGY GROUP CO LTD
Filing Date
2021-09-27
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing technologies for creating water ripples in 3D simulations require additional memory and video memory, leading to resource waste and inefficiency.

Method used

By obtaining the target area corresponding to the water ripples and fitting the slot to the initial model, the water ripple effect is achieved by utilizing the slot's memory and video memory resources.

Benefits of technology

It improves simulation efficiency, reduces additional requirements for memory and video memory, and optimizes resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116194961B_ABST
    Figure CN116194961B_ABST
Patent Text Reader

Abstract

A water ripple simulation method and device, electronic equipment and storage medium. The method comprises: when it is detected that an initial model has a demand for obtaining water ripples in a simulation process, a target area corresponding to the water ripples is obtained, and a slot (11) corresponding to the target area is obtained; the slot is attached to the initial model to obtain a target model, and a target area of the target model presents a water ripple effect (12). In the method, the slot with the water ripples is attached to the initial model to enable the target model to carry the water ripples, and only memory and display memory need to be opened for the slot without additional increase of memory and display memory, which is beneficial to improving simulation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing technology, and in particular to a water ripple simulation method and apparatus, electronic equipment, and storage medium. Background Technology

[0002] Currently, during modeling, it is necessary to generate water ripples in certain areas of the model (such as rivers, lakes, etc.). In related technologies, the water ripples generated during 3D simulation are usually three-dimensional, thus requiring dedicated space to process the water ripples, which in turn requires additional memory and video memory to handle the display of the simulated water ripples. Summary of the Invention

[0003] This disclosure provides a water ripple simulation method and apparatus, electronic device, and storage medium to address the shortcomings of related technologies.

[0004] According to a first aspect of the present disclosure, a water ripple simulation method is provided, comprising:

[0005] When it is detected that the initial model needs to obtain water ripples during the simulation process, the target area corresponding to the water ripples is obtained, and the slot corresponding to the target area is obtained;

[0006] The slot is attached to the initial model to obtain the target model, and the target area of ​​the target model presents a water ripple effect.

[0007] Optionally, obtaining the slot corresponding to the target area includes:

[0008] A bitmap image is acquired and processed to obtain a first image;

[0009] The first image is processed to obtain a second image, which serves as the slot corresponding to the target region.

[0010] Optionally, processing the first image based on the noise data to obtain the second image includes:

[0011] Obtain the target point in the bitmap image and the normal line corresponding to the target point; the normal line is a straight line passing through the target point and parallel to the z-axis in the coordinate system of the bitmap image;

[0012] Using the normal corresponding to the target point as a reference and combining it with a preset angle in the noise data, the transformation data of the pixels around the target point is obtained, and the pixels to be processed are determined based on the target point.

[0013] The transformation matrix corresponding to the bitmap image is determined based on the transformation data and the pixels to be processed.

[0014] The bitmap image is adjusted according to the transformation matrix to obtain the first image.

[0015] Optionally, obtaining the target point in the bitmap image includes:

[0016] Obtain the mapping point and the center point of the bitmap image; the mapping point is the origin of the bitmap image coordinate system mapped to the corresponding starting point in the world coordinate system;

[0017] Obtain the midpoint of the line connecting the mapping point and the center point to obtain the first midpoint;

[0018] When the first midpoint is located within the bitmap image, the first midpoint is determined as the target point;

[0019] When the first midpoint is located outside the bitmap image, the midpoint of the line connecting the preset point of the bitmap image and the center point of the bitmap image is obtained to obtain the second midpoint;

[0020] The second midpoint is determined as the target point.

[0021] Optionally, determining the pixel to be processed based on the target point includes:

[0022] Obtain candidate pixels in the bitmap image that satisfy a first filtering condition; the first filtering condition includes at least one of the following: among the pixel values ​​of the candidate pixels, the red pixel value is less than or equal to a red pixel threshold, the green pixel value exceeds a green pixel threshold and the blue pixel value exceeds a first blue pixel threshold, and the blue pixel value exceeds a second blue pixel threshold; the second blue pixel threshold is greater than the first blue pixel threshold;

[0023] The spacing between two adjacent pixels in the bitmap image is determined based on the size of the bitmap image and the size of the display area of ​​the screen;

[0024] When it is determined that the second filtering condition is not met, the step of moving the interval distance sequentially in different directions from the specified point until the pixel at the corresponding position is a non-candidate pixel or exceeds the boundary of the bitmap image is repeated to determine the candidate pixel at the corresponding position as the pixel to be processed; wherein the second filtering condition includes that the pixel at the corresponding position after moving the interval distance is located outside the bitmap image or there is no pixel, and the specified point includes the target point or the first candidate pixel after the non-candidate pixel.

[0025] According to a second aspect of the present disclosure, a water ripple simulation device is provided, comprising:

[0026] The target region acquisition module is configured to acquire the target region corresponding to the water ripple when it is detected that the initial model needs to acquire water ripples during the simulation process, and insert the bitmap image corresponding to the target region into the target region.

[0027] The target model acquisition module is configured to perform the action of fitting the slot to the initial model to obtain a target model, wherein the target area of ​​the target model presents a water ripple effect.

[0028] Optionally, the target model acquisition module includes:

[0029] The first image acquisition module is configured to acquire a bitmap image and process the bitmap image to obtain a first image;

[0030] The second image acquisition module is configured to process the first image to obtain a second image.

[0031] Optionally, the second image acquisition module includes:

[0032] The target point acquisition submodule is configured to acquire the target point in the bitmap image and the normal corresponding to the target point; the normal is a straight line passing through the target point and parallel to the z-axis in the coordinate system of the bitmap image.

[0033] The transformation data acquisition submodule is configured to perform transformation data of pixels around the target point by combining the normal corresponding to the target point with a preset angle in the noise data, and to determine the pixel to be processed based on the target point.

[0034] The transformation matrix acquisition submodule is configured to determine the transformation matrix corresponding to the bitmap image based on the transformation data and the pixels to be processed.

[0035] The second image acquisition submodule is configured to adjust the bitmap image according to the transformation matrix to obtain the first image.

[0036] Optionally, the target point acquisition submodule includes:

[0037] The center point acquisition unit is configured to acquire the mapping point and the center point of the bitmap image; the mapping point is the origin of the bitmap image coordinate system mapped to the corresponding starting point in the world coordinate system;

[0038] The first midpoint acquisition unit is configured to acquire the midpoint of the line connecting the mapping point and the center point to obtain the first midpoint.

[0039] The target point acquisition unit is configured to determine the first midpoint as the target point when the first midpoint is located within the bitmap image;

[0040] The second midpoint acquisition unit is configured to acquire the midpoint of the line connecting a preset point of the bitmap image and the center point of the bitmap image when the first midpoint is located outside the bitmap image, thereby obtaining the second midpoint;

[0041] The target point acquisition unit is configured to determine the second midpoint as the target point.

[0042] Optionally, the transformation data acquisition submodule includes:

[0043] The candidate pixel acquisition unit is configured to acquire candidate pixels in the bitmap image that satisfy a first filtering condition; the first filtering condition includes at least one of the following: the red pixel value of the candidate pixel is less than or equal to a red pixel threshold, the green pixel value exceeds a green pixel threshold and the blue pixel value exceeds a first blue pixel threshold, and the blue pixel value exceeds a second blue pixel threshold; the second blue pixel threshold is greater than the first blue pixel threshold.

[0044] The interval distance acquisition unit is configured to determine the interval distance between two adjacent pixels in the bitmap image based on the size of the bitmap image and the size of the display area of ​​the screen.

[0045] The pixel acquisition unit is configured to perform the following steps when it is determined that the second filtering condition is not met: starting from a specified point, moving the interval distance sequentially in different directions until the pixel at the corresponding position is a non-candidate pixel or exceeds the boundary of the bitmap image, thereby determining the candidate pixel at the corresponding position as the pixel to be processed; wherein the second filtering condition includes that the pixel at the corresponding position after moving the interval distance is located outside the bitmap image or there is no pixel, and the specified point includes the target point or the first candidate pixel after the non-candidate pixel.

[0046] According to a third aspect of the present disclosure, an electronic device is provided, comprising:

[0047] processor;

[0048] Memory for storing computer programs executable by the processor;

[0049] The processor is configured to execute a computer program in the memory to implement the method described above.

[0050] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when an executable computer program in the storage medium is executed by a processor, enables the implementation of the above-described method.

[0051] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:

[0052] As can be seen from the above embodiments, the technical solution provided in this disclosure can obtain the target area corresponding to the water ripple when it is detected that the initial model needs to obtain water ripples during the simulation process, and obtain the slot corresponding to the target area; then, the slot is attached to the initial model to obtain the target model, and the target area of ​​the target model presents a water ripple effect. Thus, in this embodiment, attaching the slot with water ripples to the initial model can make the target model carry water ripples, and only memory and video memory need to be allocated for the slot without the need to add additional memory and video memory, which is beneficial to improving simulation efficiency.

[0053] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0054] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0055] Figure 1 This is a flowchart illustrating a water ripple simulation method according to an exemplary embodiment.

[0056] Figure 2 This is a flowchart illustrating another water ripple simulation method according to an exemplary embodiment.

[0057] Figure 3 This is a flowchart illustrating an example of obtaining a slot, according to an exemplary embodiment.

[0058] Figure 4 This is a flowchart illustrating an example of acquiring a first image according to an exemplary embodiment.

[0059] Figure 5 This is a flowchart illustrating an example of obtaining a target point according to an exemplary embodiment.

[0060] Figure 6 This is a schematic diagram illustrating the effect of a first midpoint being located outside a bitmap image, according to an exemplary embodiment.

[0061] Figure 7 This is a schematic diagram illustrating the effect of a second midpoint being located within a bitmap image, according to an exemplary embodiment.

[0062] Figure 8 This is a schematic diagram illustrating a data logic principle according to an exemplary embodiment.

[0063] Figure 9 This is a flowchart illustrating an example of acquiring pixels to be processed, according to an exemplary embodiment.

[0064] Figure 10This is a schematic diagram illustrating the effect of obtaining the interval distance according to an exemplary embodiment.

[0065] Figure 11 This is a schematic diagram illustrating the effect of acquiring pixels to be processed according to an exemplary embodiment.

[0066] Figure 12 This is a schematic diagram illustrating the effect of a second image, i.e., a slot, according to an exemplary embodiment.

[0067] Figure 13 This is a schematic diagram illustrating a data logic principle according to an exemplary embodiment.

[0068] Figure 14 This is a block diagram illustrating a water ripple simulation device according to an exemplary embodiment. Detailed Implementation

[0069] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described below by way of example do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatus consistent with some aspects of this disclosure as detailed in the appended claims.

[0070] To address the aforementioned technical problems, this disclosure provides a water ripple simulation method that can be applied to electronic devices such as smartphones, tablets, personal computers, or servers. Figure 1 This is a flowchart illustrating a water ripple simulation method according to an exemplary embodiment. Figure 2 This is a detailed flowchart illustrating a water ripple simulation method according to an exemplary embodiment. See also... Figure 1 and Figure 2 A water ripple simulation method includes steps 11 to 12.

[0071] Step 11: When it is detected that the initial model needs to obtain water ripples during the simulation process, obtain the target area corresponding to the water ripples and obtain the slot corresponding to the target area.

[0072] In this embodiment, the electronic device can acquire an initial model, such as a 3D model. In practical applications, the electronic device can be equipped with an interactive graphics program, such as OpenSceneGraph (OSG engine); during the running of the OSG engine, the electronic device can create 3D models such as aircraft, games, virtual reality, and architectural models based on user operations. Furthermore, some areas in the 3D model may contain water features, such as rivers, lakes, oceans, ports, and fountains.

[0073] In this embodiment, the electronic device can respond to the user's simulation request and simulate the initial model. Through experiments, the entire process of changes in various parameters of the model can be observed to study the impact of different parameters on the initial model. During the user's simulation of the initial model, the electronic device can read the initial model from local memory, specifically loading the node data of each node sequentially according to the order of the nodes in the initial model.

[0074] In this embodiment, during the simulation, the electronic device can display an interactive interface, which may include a menu bar containing slots in various water ripple formats. The user can select one of the slots from the menu bar as the slot corresponding to the target area, based on the actual needs of the initial model and / or user requirements. It should be noted that the initial model may include multiple target areas, and each target area corresponds to one slot. Considering that the processing method for each slot is the same, subsequent embodiments will describe each scheme using the example of fitting a slot to a target area, thus facilitating description and understanding.

[0075] In this embodiment, the electronic device can detect a need to acquire water ripples and acquire the target area corresponding to the water ripples. In practical applications, the initial model may have "hollowed-out" areas, which need to be filled with bitmap images to achieve the desired effect. In this embodiment, the aforementioned "hollowed-out" areas can be used as the target areas corresponding to the water ripples.

[0076] In this embodiment, the electronic device can have a local database that stores bitmap images, including but not limited to bitmaps in formats such as JPG, PNG, and bitmap, which can be pixel matrices derived from image parsing. Alternatively, it can store related data of the bitmap images, such as dynamic link library (DLL) files or static link library (BLI) files. When the electronic device detects a node in the initial model that contains water features, it can read the bitmap image from the local database. At this point, the electronic device can determine that the initial model requires water ripple data during simulation. The electronic device can then read the bitmap image from the local database and insert the bitmap image corresponding to the target area into it.

[0077] It should be noted that, in this embodiment, before inserting the position image, the electronic device can determine whether the specified parameter changes of the initial model are valid, such as whether the normal angle is between 0 and 180 degrees, whether the sine value range is between 0 and 1 or the range extends to the bitmap image boundary, etc. The above specified parameters are selected according to the specific scenario and are not limited here.

[0078] In this embodiment, the electronic device may have a local database that stores bitmap images, including but not limited to bitmaps in formats such as JPG, PNG, and bitmap, which can be pixel matrices derived from image parsing. Alternatively, it may store related data of the bitmap images, such as dynamic link library (DLL) files or static link library (BLI) files. When the electronic device reads a node containing water features in the initial model or when the user selects a slot for a target area, it can read the bitmap image from the local database. At this point, the electronic device can determine that the initial model requires water ripple data during simulation. The electronic device can then obtain the slot corresponding to the target area, see [link to relevant documentation]. Figure 3 This includes steps 31 and 32.

[0079] In step 31, the electronic device can acquire a bitmap image and process the bitmap image to obtain a first image, see [link to relevant documentation]. Figure 4 This includes steps 41 to 44.

[0080] In step 41, the electronic device can acquire the target point in the bitmap image and the normal to the target point. The target point can be understood as the reference point for processing the bitmap image; see [link to relevant documentation]. Figure 5 The acquisition method includes steps 51 to 54: In step 51, the electronic device can acquire the mapping point and the center point of the bitmap image; the mapping point is the origin of the bitmap image coordinate system mapped to the corresponding starting point in the world coordinate system. In step 52, the electronic device can acquire the midpoint of the line connecting the mapping point and the center point to obtain the first midpoint. In step 53, when the first midpoint is located within the bitmap image, the electronic device can determine the first midpoint as the target point. In step 54, when the first midpoint is located outside the bitmap image, such as... Figure 6 As shown, the midpoint c of the line connecting the mapped point a and the center point b of the bitmap image, i.e., the first midpoint c, is located outside the bitmap image. At this time, the electronic device can obtain the midpoint of the line connecting a preset point of the bitmap image (such as a corner point when the bitmap image is rectangular) and the center point of the bitmap image, thus obtaining the second midpoint; this second midpoint falls within the bitmap image, as shown... Figure 7 As shown, the midpoint e of the line connecting the preset point d and the center point b of the bitmap image, i.e., the second midpoint e, is located inside the bitmap image. At this point, the electronic device can determine the second midpoint as the target point. This step, by obtaining the target point, provides a reference point for processing the bitmap image, ensuring that the water ripples remain within the bitmap image and improving processing efficiency.

[0081] In this embodiment, the normal to the target point is a straight line passing through the target point and parallel to the z-axis in the coordinate system of the bitmap image. See also Figure 8The bottom straight line represents the background plane, and the curve containing two sine waves above the background plane represents the water surface. The sine waves represent water ripples, and the vertical line above the water surface, perpendicular to the background plane, represents the user's line of sight when viewing the water surface. Taking the target point at x0 as an example, the water surface here is flat, and the normal to the water surface is perpendicular to the background plane. The line of sight L0 is parallel to the normal at x0, allowing the line of sight to pass through the water surface perpendicularly to the background plane. Taking the target point at x1 as an example, the water surface here has water ripples. The normal becomes L2, which is no longer perpendicular to the background plane, maintaining an angle. In this case, the line of sight can reach x1 through the refraction of the water ripples. Based on this principle, when the water surface includes multiple water ripples, by adjusting the direction of the line of sight, the user's line of sight can be unevenly distributed across the background plane, achieving the effect of viewing the water ripples. Figure 8 As the example shows, regardless of whether the target point is on a plane on the surface of the water or on the water ripples, its normal is parallel to the z-axis in the coordinate system of the bitmap image.

[0082] In step 42, the electronic device can use the normal corresponding to the target point as a reference and combine it with a preset angle in the noise data to obtain the transformation data of the pixels surrounding the target point, and determine the pixel to be processed based on the target point. It is understood that the transformation data refers to the data required to adjust the pixel values ​​of the surrounding pixels to form a water ripple. This transformation data is associated with a preset angle and a direction vector. The direction vector represents the direction between the pixel to be processed and the target point, i.e., the unit vector formed when looking from the target towards the pixel to be processed, such as (0, 1), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1), (0, 1), and (1, 1). The aforementioned preset angle refers to the angle formed between the two coordinate systems when the coordinate system of the slot (i.e., the bitmap image) is mapped to the coordinate system of the initial model (i.e., the world coordinate system). This angle changes with the change of the coordinate system of the initial model; that is, when the user rotates the model to adjust the viewing angle, the insertion angle of the slot, i.e., the aforementioned preset angle, will change synchronously. Understandably, the mapping between the slot's coordinate system and the world coordinate system can be extracted from or pre-set in the application that generates the model.

[0083] In this step, the electronic device can determine the pixel to be processed based on the target point. See [link / reference] Figure 9 This includes steps 91 to 93.

[0084] In step 91, the electronic device can acquire candidate pixels in the bitmap image that meet the first filtering condition, as shown in the following figure. Figure 10 As shown, Figure 10Black dots represent candidate pixels that meet the first screening condition, while circles represent candidate pixels that do not meet the first screening condition. The first screening condition includes at least one of the following: among the candidate pixel values, red pixel values ​​are less than or equal to a red pixel threshold, green pixel values ​​exceed a green pixel threshold, and blue pixel values ​​exceed a first blue pixel threshold; the blue pixel value exceeds a second blue pixel threshold; and the second blue pixel threshold is greater than the first blue pixel threshold. By setting the first screening condition in this step, the color of the water area is ensured to lean towards blue or green rather than red, which is beneficial for improving the simulation effect.

[0085] In step 92, the electronic device can determine the spacing between two adjacent pixels in the bitmap image based on the size of the bitmap image and the size of the display area, as shown in the image. Figure 10 The mid-range distance f. Both the initial model and the subsequent target model need to be displayed within the screen's display area; therefore, the size of the display area also affects the spacing between adjacent pixels in the position image. After determining the size of the display area, the size of the target area can be determined simultaneously. Since the resolution of the bitmap image is known, the spacing between two adjacent pixels in the bitmap image can be determined. By setting the spacing distance, the two water ripples can maintain a gap, achieving the same effect as real-life water ripples and improving the viewing experience.

[0086] It should be noted that step 92 describes a scheme for determining the interval distance using the bitmap size and the size of the display area. In practical applications, the above interval distance can also be set based on empirical values. For example, the interval distance can be set to 3-5 pixels in a light breeze and 10-15 pixels in a strong wind, which can also achieve the scheme disclosed herein.

[0087] In step 93, when it is determined that the second filtering condition is not met, the electronic device may repeatedly execute the step of moving the interval distance sequentially in different directions from the specified point until the pixel at the corresponding position is a non-candidate pixel or exceeds the boundary of the bitmap image, thereby determining the candidate pixel at the corresponding position as the pixel to be processed; wherein the second filtering condition includes that the pixel at the corresponding position is outside the bitmap image or there is no pixel after moving the interval distance, and the specified point includes the target point or the first candidate pixel after the non-candidate pixel.

[0088] Step 93 can be an iterative step, namely: the first time, using the target point as a reference, which can be understood as the position where the stone falls, as can be seen from... Figure 8The target point is set at x0. Then, the candidate pixels adjacent to the target point are the pixels to be processed. For example, the pixel at x on the right is the pixel to be processed. After processing, the first ripple or the first ring of water (i.e., the crest of a wave) can be obtained. After moving the above interval distance, the corresponding candidate pixel is then used as the pixel to be processed again. After processing, the second ripple or the second ring of water can be obtained; and so on, following the order of "ripple—normal—ripple—normal…" until the boundary of the bitmap image.

[0089] In practical applications, considering the initial expansion of water ripples in eight directions towards the target point, see [reference needed]. Figure 11 , Figure 11 Figure (a) shows the target point g, and Figure (b) shows the water ripples expanding in five directions that meet the requirements. For each direction, the pixel to be processed is adjusted in the manner of step 93 to obtain the water ripples. Subsequent expansion also continues in the same direction. When a candidate pixel is encountered, the pixel brightness is adjusted to form water ripples. Figure 11 Figure (c) illustrates the effect of creating ripples 1 and ripple 2 after moving three times to the left. The expansion process based on the target point g stops when the pixel corresponding to the movement interval is not a candidate pixel (e.g., pixel A). Then, it continues to extend in each direction to find candidate pixels, and uses these candidate pixels as designated points to continue expanding in eight directions, as shown below. Figure 11 Figure (c) illustrates the effect of finding the specified point g1 to the left. At this point, the specified point g1 is transformed into a reference point with the same status as the target point. The subsequent expansion process is the same as the expansion process from the target point outward, and will not be repeated here. Based on Figure 11 Following the principle illustrated, the search continues for specified points and the water ripples are expanded until they reach the boundary or are no longer candidate pixels. In this way, the water area can be filled with water ripples using the above expansion method.

[0090] It should be noted that expanding water ripples in eight directions from a designated point is suitable for scenarios where pebbles or raindrops fall into water, forming concentric circles of ripples centered on the designated point. Considering larger bodies of water, such as lakes and oceans, where ripples move towards the shore, the ripples can be expanded in four directions towards the shore from the designated point. Subsequent designated points are expanded similarly, creating a continuous ripple movement towards the shore, thus matching the simulation scene. Technicians can select appropriate direction vectors based on the specific scene to ensure the flow and orientation of the water ripples. Flow direction refers to the direction the water ripples move; for example, in the ocean, ripples flow from the depths towards the shore. Orientation refers to the orientation of the water ripples as seen by the user, i.e., the angle at which the user views the ripples from different perspectives. For example, a ripple seen from the front, and when the model is rotated 90 degrees (which can be understood as a preset angle change of 90 degrees), a wave-like shape with a high center and low sides is seen from the side.

[0091] It should be noted that, considering that the proportion of pixels in the bitmap image that meet the requirements is close to or less than half, i.e., less than or equal to 50%, for example, 30%, the average distance between two adjacent specified points in the entire bitmap image is about 2-3 pixels. Therefore, for each specified point, after forming the first ripple or the first ring of water, it cannot continue to extend. From the overall perspective, the entire bitmap image can form multiple ripples or rings, achieving the effect of forming water ripples on the bitmap image. In other words, in this example, combining the interval distance and the interval corresponding to the pixels that do not meet the requirements can ensure the final interval between two adjacent water ripples, achieving the final effect of visually seeing two water ripples or two water ripples with a large interval. In step 43, the electronic device can determine the transformation matrix corresponding to the bitmap image based on the transformation data and the pixels to be processed.

[0092] In this step, considering that the difference between different water ripples in a bitmap image lies only in the change of the direction vector, or in other words, the different orientations of the pixels to be processed at the target point, the preset angle associated with the transformation data of the pixels to be processed remains unchanged for different water ripples; only the direction vector changes.

[0093] Therefore, the electronic device can determine the direction vector of the pixel to be processed. Referring to the example in step 32, the aforementioned direction vector is related to the scene of the water area and a preset angle (e.g., which direction it points to). The scene of the water area determines that the water ripples extend in 1, 4, or 8 directions, thus giving the specified point 1, 4, or 8 direction vectors, and determining which direction vector to use for the pixels to be processed in each direction associated with that specified point. The preset angle determines the direction of water ripple propagation, thus determining which direction vector to use for the pixel to be processed. For example, when the preset angle is 0 degrees, the water ripples are visible on the front, i.e., a single ripple; in this case, a direction vector pointing left or right can be selected for the pixel to be processed. When the model rotates 90 degrees, i.e., the preset angle changes by 90 degrees, mountain-shaped waves can be seen from the side of the water ripples; in this case, a direction vector pointing towards or away from the display screen can be selected for the pixel to be processed. It should be noted that, for illustrative purposes, the process of selecting the direction vector is explained from the user's perspective of the display screen; in practical applications, the conversion can be performed based on the mapping relationship between the world coordinate system and the bitmap image coordinate system.

[0094] Then, the electronic device can write the direction vector and preset angle of each pixel to be processed into the transformation matrix, and write a constant 1 (indicating that no change is needed) at the position of the pixels other than the pixels to be processed, and finally determine the transformation matrix corresponding to the first image.

[0095] In step 44, the electronic device can adjust the bitmap image according to the transformation matrix to obtain the first image. It is understood that the electronic device obtains the product of the pixels in the first image and the transformation data in the transformation matrix, i.e., updates the pixel values ​​of the data to be processed in the first image, thereby obtaining the second image.

[0096] In this embodiment, the transformation matrix described above can be used to indicate which pixel position to adjust to form water ripples. Adjusting pixel values ​​in this step essentially adjusts the brightness value of the pixels; pixels at the water ripple position are given higher brightness, while pixels at other positions are given normal brightness. For pixel values ​​that need adjustment in a bitmap image, brightness and contrast adjustment belong to the grayscale linear transformation of the image, as shown in the following formula:

[0097] y=[x-127.5*(1-B)]*k+127.5*(1+B);

[0098] In the formula, x is the pixel value before adjustment, and y is the pixel value after adjustment. B takes a value of [-1, 1] to adjust the brightness; k adjusts the contrast, and arctan(k) takes a value of [1, 89], k = tan((45 + 44 * c) / 180 * pi); where c is the preset angle, and c is usually used to set the contrast.

[0099] In one example, an electronic device can adjust the brightness and contrast of pixels in the following way:

[0100] When B = 0, y = (x - 127.5) * k + 127.5; at this time, only the contrast is adjusted.

[0101] When c = 0, k = 1, y = x + 255 * B, at this time only the brightness is adjusted.

[0102] It should be noted that technicians can adjust the brightness and contrast of pixels based on the above adjustment principles, which will not be elaborated upon here.

[0103] In step 32, the first image is processed to obtain the second image.

[0104] In one embodiment, the electronic device can process the first image to obtain a second image. For example, the electronic device can perform Fresnel transform processing on the first image. This Fresnel transform can be understood as a Fourier transform, the purpose of which is to form any continuous measurement time series or signal, using an infinite superposition of sinusoidal wave signals of different frequencies. Thus, in this embodiment, the Fresnel transform can find the water ripples (or echoes) that appear in the opposite direction when the subsequent reference point expands in eight directions as in step 93. These echoes are noise signals relative to the water ripples generated by the previous reference point. Then, by removing the sinusoidal wave signal of the corresponding frequency of the echo signal, the second image can be obtained. The solution in this embodiment is suitable for scenarios with large water areas and water ripples flowing in the same direction, such as ocean waves flowing towards the shore. Anti-interference processing can ensure the accuracy of the water ripples.

[0105] In one embodiment, the electronic device includes a noise source, which may include generating Monte Carlo random numbers and generating noise source parameter data. Specifically, the noise source first generates Monte Carlo random numbers, and then inputs these random numbers into the noise source parameters to generate noise source parameter data. This noise source parameter data may include different positions and incident angles of the noise source. Figure 6 The illustrated embodiment is similar, where the noise source can be equivalent to the target point and the incident angle is equivalent to a preset angle. This approach is applicable to scenarios such as rain in water, where the water ripples generated by these noise sources will also interfere with the water ripples generated by the target point. In this embodiment, a second image is obtained by performing a sine transform on the first image, thereby superimposing the water ripples corresponding to the target point and the noise source. This second image is then used as the slot corresponding to the target region. By superimposing noise data, this embodiment can simulate the effect of different water ripples being superimposed, ensuring the accuracy of the water ripples.

[0106] Step 12: Fit the slot to the initial model to obtain the target model, and the target area of ​​the target model presents a water ripple effect.

[0107] In this embodiment, the electronic device can use the second image as a slot to fit the initial model, thereby obtaining the target model, with a water ripple effect as shown. Figure 12 As shown.

[0108] It should be noted that steps 11 to 12 are processed in the memory of the electronic device. This allows memory areas to be pre-allocated for the bitmap image during the acquisition of the slot. When updating pixel values ​​in the bitmap image, updates only need to be made on the bitmap image. As a result, the water ripples do not occupy space in the z-axis direction of space. Different water ripples can be formed simply by adjusting the loading angle. Furthermore, no additional memory space needs to be allocated, thereby improving memory utilization.

[0109] In this embodiment, after acquiring the target model, the electronic device can swap the target model from memory to video memory, where the video memory will handle the rendering and display of the target model. This will not be elaborated further. It is understood that for the video memory, the second image and the bitmap image do not add rendering parameters. Therefore, using the above method on the parts of the target model that require water features is beneficial for improving the simulation effect.

[0110] Thus, the technical solution provided in this disclosure can acquire the target area corresponding to the water ripple when the initial model needs to acquire water ripples during simulation, and acquire the slot corresponding to the target area; then, the slot is attached to the initial model to obtain the target model, and the target area of ​​the target model presents a water ripple effect. In this embodiment, attaching the slot with water ripples to the initial model is sufficient to make the target model carry water ripples, requiring only the allocation of memory and video memory for the slot without the need for additional memory and video memory, which is beneficial for improving simulation efficiency.

[0111] The following is combined Figure 13 This embodiment describes the implementation process of a water ripple simulation method.

[0112] The electronic device stores a water ripple simulation SDK, which can be called and run during simulation. The electronic device can retrieve the basic texture database and interference parameter database from the local database via dynamic link library or static link library interface. The basic texture database contains the bitmap images mentioned above, and the interference parameter database contains the noise data mentioned above. In practical applications, it can... Figure 1 The steps shown are integrated into a single module, providing only the interface and static resource packages (such as pre-made basic texture images, or parameters such as wave height and depth, which can be set).

[0113] Users can select the desired slot for the target area of ​​the initial model within the interactive interface. After detecting the selected slot, the electronic device acquires the corresponding basic texture data and interference parameter data. Then, the electronic device can process the aforementioned basic texture data and interference parameter data by calling the breadth calculation model, refraction calculation model, and normal offset calculation model through the data logic layer. The data principle diagram is shown below. Figure 6The illustrated embodiment describes the following: For example, the breadth calculation model can obtain the starting and ending points of the hollowed-out area (or target area) in the initial model, and then determine the range of the target area within the display area. The refraction calculation model can obtain the angle at which the pre-made basic texture image (i.e., bitmap image) is placed into the 3D world, i.e., obtain the preset angle; and obtain the angle of light or wind ingress at the water scene, etc., to determine the flow direction and orientation of the water ripples. The normal offset calculation model can obtain the coordinates of candidate pixels in the basic texture image that meet the pixel / RGB value requirements (i.e., the first screening condition), and obtain the coordinates of the specified point and its normal. It is understood that when the preset angle does not change but the angle of light or wind ingress changes (i.e., noise data changes), it can also cause changes in the normal at the target point or specified point in the bitmap image, thereby introducing changes in the water ripples. Afterwards, the electronic device can obtain a slot after processing the above basic texture image. After the slot is attached to the initial model, the target model can be obtained. Finally, the target model can be displayed on the external preview interface.

[0114] It should be noted that the above description outlines a scheme for inserting the slot into the OSG engine from one angle. In practical applications, electronic devices can directly load the slot into any position within the OSG engine. The loading angle can then be adjusted (i.e., adjusting the direction of the normal to change the preset angle while keeping the line of sight constant) to create corresponding water ripples within the target area. Furthermore, as the target model changes in spatial angle, the loading angle also changes, thus altering the flow direction and orientation of the displayed water ripples, achieving the effect of viewing water ripples with different flow directions and orientations from different perspectives.

[0115] Based on the water ripple simulation method provided in this disclosure, this embodiment also provides a water ripple simulation device, see [link to relevant documentation]. Figure 14 ,include:

[0116] The target area acquisition module 141 is configured to acquire the target area corresponding to the water ripple when it is detected that the initial model needs to acquire water ripples during the simulation process, and acquire the slot corresponding to the target area.

[0117] The target model acquisition module 142 is configured to perform the action of fitting the slot to the initial model to obtain a target model, wherein the target area of ​​the target model presents a water ripple effect.

[0118] In one embodiment, the target model acquisition module includes:

[0119] The first image acquisition module is configured to acquire a bitmap image and process the bitmap image to obtain a first image;

[0120] The second image acquisition module is configured to process the first image to obtain a second image, which serves as a slot corresponding to the target region.

[0121] In one embodiment, the second image acquisition module includes:

[0122] The target point acquisition submodule is configured to acquire the target point in the bitmap image and the normal corresponding to the target point; the normal is a straight line passing through the target point and parallel to the z-axis in the coordinate system of the bitmap image.

[0123] The transformation data acquisition submodule is configured to perform transformation data of pixels around the target point by combining the normal corresponding to the target point with a preset angle in the noise data, and to determine the pixel to be processed based on the target point.

[0124] The transformation matrix acquisition submodule is configured to determine the transformation matrix corresponding to the bitmap image based on the transformation data and the pixels to be processed.

[0125] The second image acquisition submodule is configured to adjust the bitmap image according to the transformation matrix to obtain the first image.

[0126] In one embodiment, the target point acquisition submodule includes:

[0127] The center point acquisition unit is configured to acquire the mapping point and the center point of the bitmap image; the mapping point is the origin of the bitmap image coordinate system mapped to the corresponding starting point in the world coordinate system;

[0128] The first midpoint acquisition unit is configured to acquire the midpoint of the line connecting the mapping point and the center point to obtain the first midpoint.

[0129] The target point acquisition unit is configured to determine the first midpoint as the target point when the first midpoint is located within the bitmap image;

[0130] The second midpoint acquisition unit is configured to acquire the midpoint of the line connecting a preset point of the bitmap image and the center point of the bitmap image when the first midpoint is located outside the bitmap image, thereby obtaining the second midpoint;

[0131] The target point acquisition unit is configured to determine the second midpoint as the target point.

[0132] In one embodiment, the transformation data acquisition submodule includes:

[0133] The candidate pixel acquisition unit is configured to acquire candidate pixels in the bitmap image that satisfy a first filtering condition; the first filtering condition includes at least one of the following: the red pixel value of the candidate pixel is less than or equal to a red pixel threshold, the green pixel value exceeds a green pixel threshold and the blue pixel value exceeds a first blue pixel threshold, and the blue pixel value exceeds a second blue pixel threshold; the second blue pixel threshold is greater than the first blue pixel threshold.

[0134] The interval distance acquisition unit is configured to determine the interval distance between two adjacent pixels in the bitmap image based on the size of the bitmap image and the size of the display area of ​​the screen.

[0135] The pixel acquisition unit is configured to perform the following steps when it is determined that the second filtering condition is not met: starting from a specified point, moving the interval distance sequentially in different directions until the pixel at the corresponding position is a non-candidate pixel or exceeds the boundary of the bitmap image, thereby determining the candidate pixel at the corresponding position as the pixel to be processed; wherein the second filtering condition includes that the pixel at the corresponding position after moving the interval distance is located outside the bitmap image or there is no pixel, and the specified point includes the target point or the first candidate pixel after the non-candidate pixel.

[0136] It should be noted that the apparatus shown in this embodiment matches the content of the method embodiment, and the content of the above method embodiment can be referred to, which will not be repeated here.

[0137] In an exemplary embodiment, an electronic device is also provided, comprising:

[0138] processor;

[0139] Memory for storing computer programs executable by the processor;

[0140] The processor is configured to execute a computer program in the memory to achieve, for example, Figure 1 The steps of the method are described.

[0141] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including instructions, wherein the executable computer program described above can be executed by a processor. The readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device, etc.

[0142] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This disclosure is intended to cover any variations, uses, or adaptations that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

Claims

1. A method for simulating water ripples, characterized in that, include: When it is detected that the initial model needs to obtain water ripples during the simulation process, the target area corresponding to the water ripples is obtained, and the slot corresponding to the target area is obtained; The slot is attached to the initial model to obtain the target model, and the target area of ​​the target model presents a water ripple effect. Obtaining the slot corresponding to the target region includes obtaining a bitmap image and processing the bitmap image to obtain a first image; processing the first image to obtain a second image, the second image serving as the slot corresponding to the target region; Processing the bitmap image to obtain a first image includes acquiring a target point in the bitmap image and the normal corresponding to the target point; the normal is a straight line passing through the target point and parallel to the z-axis in the coordinate system of the bitmap image; using the normal corresponding to the target point as a reference and combining a preset angle in the noise data, acquiring transformation data of pixels around the target point, and determining the pixel to be processed based on the target point; and determining the transformation matrix corresponding to the bitmap image based on the transformation data and the pixel to be processed. The bitmap image is adjusted according to the transformation matrix to obtain the first image; Determining the pixel to be processed based on the target point includes: Obtain candidate pixels in the bitmap image that satisfy a first filtering condition; the first filtering condition includes at least one of the following: among the pixel values ​​of the candidate pixels, the red pixel value is less than or equal to a red pixel threshold, the green pixel value exceeds a green pixel threshold and the blue pixel value exceeds a first blue pixel threshold, and the blue pixel value exceeds a second blue pixel threshold; the second blue pixel threshold is greater than the first blue pixel threshold; The spacing between two adjacent pixels in the bitmap image is determined based on the size of the bitmap image and the size of the display area of ​​the screen; When it is determined that the second filtering condition is not met, the step of moving the interval distance sequentially in different directions from the specified point until the pixel at the corresponding position is a non-candidate pixel or exceeds the boundary of the bitmap image is repeated to determine the candidate pixel at the corresponding position as the pixel to be processed; wherein the second filtering condition includes that the pixel at the corresponding position after moving the interval distance is located outside the bitmap image or there is no pixel, and the specified point includes the target point or the first candidate pixel after the non-candidate pixel.

2. The method according to claim 1, characterized in that, Obtaining the target point in the bitmap image includes: Obtain the mapping point and the center point of the bitmap image; the mapping point is the origin of the bitmap image coordinate system mapped to the corresponding starting point in the world coordinate system; Obtain the midpoint of the line connecting the mapping point and the center point to obtain the first midpoint; When the first midpoint is located within the bitmap image, the first midpoint is determined as the target point; When the first midpoint is located outside the bitmap image, the midpoint of the line connecting the preset point of the bitmap image and the center point of the bitmap image is obtained to obtain the second midpoint; The second midpoint is determined as the target point.

3. A water ripple simulation device, characterized in that, include: The target area acquisition module is configured to acquire the target area corresponding to the water ripple when it is detected that the initial model needs to acquire water ripples during the simulation process, and acquire the slot corresponding to the target area; The target model acquisition module is configured to perform the action of fitting the slot to the initial model to obtain a target model, wherein the target area of ​​the target model presents a water ripple effect; The target model acquisition module includes: a first image acquisition module configured to acquire a bitmap image and process the bitmap image to obtain a first image; and a second image acquisition module configured to process the first image to obtain a second image, wherein the second image serves as a slot corresponding to the target region. The first image acquisition module includes a target point acquisition submodule and a transformation data acquisition submodule. The target point acquisition submodule is configured to acquire a target point in the bitmap image and the normal corresponding to the target point. The normal is a straight line passing through the target point and parallel to the z-axis in the coordinate system of the bitmap image. The transformation data acquisition submodule is configured to acquire transformation data of pixels surrounding the target point, using the normal corresponding to the target point as a reference and combining a preset angle in the noise data, and to determine the pixel to be processed based on the target point. The transformation matrix acquisition submodule is configured to determine the transformation matrix corresponding to the bitmap image based on the transformation data and the pixel to be processed. The second image acquisition submodule is configured to adjust the bitmap image according to the transformation matrix to obtain the first image. The transformation data acquisition submodule includes: The candidate pixel acquisition unit is configured to acquire candidate pixels in the bitmap image that satisfy a first filtering condition; the first filtering condition includes at least one of the following: the red pixel value of the candidate pixel is less than or equal to a red pixel threshold, the green pixel value exceeds a green pixel threshold and the blue pixel value exceeds a first blue pixel threshold, and the blue pixel value exceeds a second blue pixel threshold; the second blue pixel threshold is greater than the first blue pixel threshold. The interval distance acquisition unit is configured to determine the interval distance between two adjacent pixels in the bitmap image based on the size of the bitmap image and the size of the display area of ​​the screen. The pixel acquisition unit is configured to perform the following steps when it is determined that the second filtering condition is not met: starting from a specified point, moving the interval distance sequentially in different directions until the pixel at the corresponding position is a non-candidate pixel or exceeds the boundary of the bitmap image, thereby determining the candidate pixel at the corresponding position as the pixel to be processed; wherein the second filtering condition includes that the pixel at the corresponding position after moving the interval distance is located outside the bitmap image or there is no pixel, and the specified point includes the target point or the first candidate pixel after the non-candidate pixel.

4. The apparatus according to claim 3, characterized in that, The target point acquisition submodule includes: The center point acquisition unit is configured to acquire the mapping point and the center point of the bitmap image; the mapping point is the origin of the bitmap image coordinate system mapped to the corresponding starting point in the world coordinate system; The first midpoint acquisition unit is configured to acquire the midpoint of the line connecting the mapping point and the center point to obtain the first midpoint. The target point acquisition unit is configured to determine the first midpoint as the target point when the first midpoint is located within the bitmap image; The second midpoint acquisition unit is configured to acquire the midpoint of the line connecting a preset point of the bitmap image and the center point of the bitmap image when the first midpoint is located outside the bitmap image, thereby obtaining the second midpoint; The target point acquisition unit is configured to determine the second midpoint as the target point.

5. An electronic device, characterized in that, include: processor; Memory for storing computer programs executable by the processor; The processor is configured to execute a computer program in the memory to implement the method as described in claim 1 or 2.

6. A computer-readable storage medium, characterized in that, When the executable computer program in the storage medium is executed by a processor, it can implement the method as described in claim 1 or 2.