Ripple simulation method, device, electronic device and computer-readable storage medium
By obtaining control parameters in the game scene, assigning grids and random points, and generating ripple waveform diffusion information, the problem of fixed ripples effect in the existing technology is solved, and a more realistic ripples effect is achieved.
Patent Information
- Application Number
- CN202111622817.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2041-12-28
AI Technical Summary
In the prior art, the raindrop ripples animation effect is fixed, lacks authenticity, and the raindrop falls unchanged, resulting in the scene not being realistic enough.
By obtaining control parameters, including grid parameters and ripple diffusion period, the target plane is evenly divided into multiple grids, and random points are assigned to each grid, and ripples waveform diffusion information is generated based on grid information and periodic information, and finally a ripple effect is generated in the target plane.
The randomness of the ripples effect is achieved, and the ripples effect is close to the real raindrops falling on the water surface, enhancing the realism of the game scene.
Smart Images

Figure CN114404950B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a ripple simulation method, device, electronic device, and computer-readable storage medium. Background Art
[0002] The rapid development of computer technology has driven the rapid advancement of the gaming industry, and online games have become an indispensable form of entertainment in people's lives. Many scenario-based online games are based on a combination of reality and imagination. To provide players with a better gaming experience, continuous optimization of the realism and vividness of the scenes is necessary.
[0003] Many game scenes involve raindrop ripple effects. The raindrop ripple animations implemented by existing technologies mostly periodically generate raindrop ripple effects at fixed points. Although this shows the effect of ripples when raindrops fall on the water surface, the landing point of the raindrops does not change, making the scene less realistic. Summary of the Invention
[0004] The object of the present invention is to provide a ripple simulation method, device, electronic device and computer-readable storage medium to improve the problems existing in the prior art.
[0005] The embodiments of the present invention can be implemented as follows:
[0006] In a first aspect, the present invention provides a ripple simulation method, comprising:
[0007] Acquiring control parameters, wherein the control parameters include grid parameters and ripple diffusion period;
[0008] Dividing the target plane into a plurality of grids according to the grid parameters;
[0009] According to the ripple diffusion period, a random point is assigned to each of the grids, wherein the random point represents the center of the ripple;
[0010] Obtaining waveform diffusion information of the ripple corresponding to each grid according to row and column information and current cycle information of each grid, wherein the waveform diffusion information represents waveform changes of the ripple affected by other ripples when the ripple diffuses, and the current cycle information represents that the current ripple is the i-th diffusion cycle;
[0011] According to all the waveform diffusion information, a ripple effect is generated in the target plane based on the control parameters.
[0012] In an optional embodiment, the control parameters further include a ripple diffusion speed and a ripple diffusion wavelength, and the method further includes:
[0013] The control parameters are used as formal parameters to encapsulate and obtain a ripple cycle function; the formal parameters include at least one of the grid parameters, the ripple diffusion period, the ripple diffusion speed, and the ripple diffusion wavelength;
[0014] Get the input value of the formal parameter;
[0015] Based on the input value, the ripple loop function is called to generate a new ripple effect.
[0016] In an optional embodiment, the control parameters further include a ripple diffusion speed and a ripple diffusion wavelength, and the method further includes:
[0017] Acquiring updated control parameters, where the updated control parameters include at least one of a grid parameter, a ripple diffusion period, a ripple diffusion speed, and a ripple diffusion wavelength;
[0018] Based on the updated control parameters, a new ripple effect is generated in the target plane.
[0019] In an optional embodiment, the step of assigning a periodically changing random point to each grid includes:
[0020] Allocating one random point to each grid;
[0021] For each ripple corresponding to the random point, the appearance time of the ripple is set to any time within the ripple diffusion period; wherein, for multiple ripple diffusion periods, the appearance time of the ripples in the same grid is the same, and the appearance time of the ripples in different grids is different.
[0022] In an optional embodiment, the step of obtaining corresponding waveform diffusion information according to the row and column information and current cycle information of each grid includes:
[0023] Obtaining a random number for each ripple based on row and column information and current cycle information of the ripple corresponding to each grid;
[0024] Obtaining an attenuation coefficient of each ripple according to each random number, wherein the attenuation coefficient represents the degree of attenuation of the ripple when it spreads;
[0025] Based on a predefined ripple waveform function and a ripple width function, and each of the attenuation coefficients, calculating first waveform diffusion information of each of the ripples; the first waveform diffusion information represents waveform changes when the ripples diffuse independently;
[0026] For each ripple, the first waveform diffusion information of a plurality of other ripples surrounding the ripple is superimposed to obtain the waveform diffusion information corresponding to the ripple.
[0027] In a second aspect, the present invention provides a ripple simulation device, comprising:
[0028] An acquisition module, configured to acquire control parameters, wherein the control parameters include grid parameters and a ripple diffusion period;
[0029] a processing module, configured to divide the target plane into a plurality of grids according to the grid parameters; and to assign a random point to each of the grids according to the ripple diffusion period, wherein the random point represents the center of the ripple;
[0030] The acquisition module is further configured to obtain waveform diffusion information of the ripple corresponding to each grid according to row and column information and current cycle information of each grid, wherein the waveform diffusion information represents waveform changes of the ripple affected by other ripples when the ripple diffuses, and the current cycle information represents that the current period is the i-th ripple diffusion cycle;
[0031] The processing module is further configured to generate a ripple effect in the target plane based on the control parameters according to all the waveform diffusion information.
[0032] In an optional embodiment, the control parameters further include a ripple diffusion speed and a ripple diffusion wavelength, and the processing module is further configured to:
[0033] The control parameters are used as formal parameters to encapsulate and obtain a ripple cycle function; the formal parameters include at least one of the grid parameters, the ripple diffusion period, the ripple diffusion speed, and the ripple diffusion wavelength;
[0034] Get the input value of the formal parameter;
[0035] Based on all the input values, call the ripple loop function to generate a new ripple effect.
[0036] In an optional embodiment, the control parameters further include ripple diffusion speed and ripple diffusion wavelength;
[0037] The acquisition module is further configured to acquire updated control parameters, wherein the updated control parameters include at least one of a grid parameter, a ripple diffusion period, a ripple diffusion speed, and a ripple diffusion wavelength;
[0038] The processing module is further configured to generate a new ripple effect in the target plane based on the updated multiple control parameters.
[0039] In a third aspect, the present invention provides an electronic device comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory through the bus, and the processor executes the machine-readable instructions to perform the steps of the simulation method as described in any of the aforementioned embodiments.
[0040] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method described in any one of the aforementioned embodiments.
[0041] Embodiments of the present invention provide a ripple simulation method, apparatus, electronic device, and computer-readable storage medium. Control parameters, including grid parameters and a ripple diffusion period, are obtained. Based on the grid parameters, a target plane is divided into multiple grids. Then, based on the ripple diffusion period, a random point is assigned to each grid, representing the center of the ripple. Furthermore, based on the row and column information and current period information of each grid, waveform diffusion information for the ripple corresponding to each grid is obtained. This waveform diffusion information represents the waveform changes affected by other ripples as the ripple diffuses, and the current period information indicates that the current period is the i-th ripple diffusion period. Finally, based on all the waveform diffusion information, a ripple effect is generated on the target plane based on the control parameters.
[0042] The beneficial effect of the embodiment of the present invention is that: according to the ripple diffusion period, random points are assigned to each of the grids, so that the position of the ripples in each grid in the target plane is random. Different from the prior art in which ripples repeatedly appear at fixed landing points, the present invention can simulate the appearance of ripples at random positions, making the generated ripple effect more realistic, close to the ripple effect caused by raindrops falling on the water surface. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 This is a ripple effect diagram achieved using existing technology.
[0045] Figure 2 One of the flowcharts of a ripple simulation method provided by an embodiment of the present invention.
[0046] Figure 3 A schematic diagram of gridding a target plane according to an embodiment of the present invention.
[0047] Figure 4 The second flowchart of a ripple simulation method provided by an embodiment of the present invention.
[0048] Figure 5 The third flowchart of a ripple simulation method provided by an embodiment of the present invention.
[0049] Figure 6 A schematic diagram of generating a ripple effect according to an embodiment of the present invention.
[0050] Figure 7 A fourth flow chart of a ripple simulation method provided in an embodiment of the present invention.
[0051] Figure 8 Schematic diagram of the relationship between the ripple diffusion period and the time when the ripple appears.
[0052] Figure 9 FIG5 is a fifth flow chart of a ripple simulation method provided in an embodiment of the present invention.
[0053] Figure 10 A schematic diagram of the functional modules of a ripple simulation device provided by an embodiment of the present invention.
[0054] Figure 11 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0055] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0056] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0057] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0058] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear, the orientation or position relationship indicated is based on the orientation or position relationship shown in the accompanying drawings, or is the orientation or position relationship in which the product of the invention is usually placed when in use. It is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be understood as a limitation on the present invention.
[0059] In addition, the terms "first", "second", etc., if used, are merely used to distinguish and describe, and should not be understood as indicating or implying relative importance.
[0060] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0061] Currently, many game scenes involve raindrop ripple effects. The raindrop ripple animations simulated by existing technologies mostly generate raindrop ripple effects periodically at fixed points. Figure 1 , Figure 1 A schematic diagram of the ripple effect simulated by existing technology. Figure 1 (a) and (b) in the figure are the ripple effects produced by intercepting different periods, and the black dot in the figure is the center of the ripple.
[0062] In existing technologies, the position, size, and appearance time of each ripple are determined by the input texture, which has poor randomness. Figure 1 As can be seen, each ripple reappears repeatedly at the same location within each cycle, with the center of the ripple remaining constant. This creates the illusion of ripples created by raindrops hitting water, but the point of impact remains constant, with ripples only periodically recurring at a fixed point. However, in reality, raindrops don't land consistently on water, but rather in a chaotic pattern. Clearly, the ripple effect achieved with existing technology lacks realism.
[0063] Furthermore, once the ripples' position, size, and time offset are determined using a texture, adjusting the ripple effect in the output image is difficult. Adjusting parameters like ripple density, wavelength, and speed requires redrawing the texture or making significant changes, a tedious process.
[0064] In view of this, embodiments of the present invention provide a ripple simulation method, device, electronic device, and computer-readable storage medium to improve the problems existing in the prior art. Specific embodiments will be described below with reference to the accompanying drawings.
[0065] See Figure 2 , Figure 2This is a flow chart of a ripple simulation method provided by an embodiment of the present invention, which includes steps S110 to S140:
[0066] Step S110: Acquire control parameters.
[0067] In this embodiment, the control parameters include grid parameters and ripple diffusion period. The grid parameters and ripple diffusion period can be set by the user according to actual application conditions and are not limited here.
[0068] Step S120: Divide the target plane into multiple grids according to the grid parameters. Step S130: Assign random points to each grid according to the ripple diffusion period.
[0069] The value of the grid parameter determines the number of grids. Each grid is assigned a random point, which represents the center of the ripple. For example, when the user sets the grid parameter to 5, the target plane can be divided into 25 grids of 5×5. Figure 3 , Figure 3 This is a schematic diagram of the target plane meshing. The white dots in the figure can be considered random points. It should be noted that this figure is only an example. In actual applications, the traces of the target plane meshing and the random points may not be displayed.
[0070] Step S140: Obtain the waveform diffusion information of the ripples corresponding to each grid according to the row and column information and the current cycle information of each grid.
[0071] As you can understand, ripples can overlap as they spread, and when they overlap, their waveforms can influence each other. Waveform diffusion information represents the waveform changes affected by other ripples as the ripple spreads, and current cycle information represents the i-th ripple diffusion cycle.
[0072] Step S150: Generate a ripple effect in the target plane based on the control parameters according to all waveform diffusion information.
[0073] The embodiments of the present invention provide a ripple simulation method, device, electronic device and computer-readable storage medium. First, by obtaining control parameters such as grid parameters and ripple diffusion period, the target plane is divided into multiple grids according to the grid parameters. Then, according to the ripple diffusion period, random points are assigned to each grid, and the random points represent the center of the ripples. Then, according to the row and column information and current period information of each grid, the waveform diffusion information of the ripples corresponding to each grid is obtained. Finally, based on all the waveform diffusion information, a ripple effect is generated in the target plane based on the control parameters. In this way, according to the ripple diffusion period, random points are assigned to each of the grids, so that the position of the ripples in each grid in the target plane is random. Different from the prior art in which ripples repeatedly appear at fixed landing points, the present invention can simulate the appearance of ripples at random positions, so that the generated ripple effect is more realistic, close to the ripple effect caused by raindrops falling on the water surface.
[0074] In an optional implementation, the control parameters may also include the ripple diffusion speed and the ripple diffusion wavelength, which can be encapsulated into a ripple loop function for easy repeated calls. Figure 4 , Figure 4 The second flow chart of a ripple simulation method provided by an embodiment of the present invention further includes the following steps:
[0075] Step S160: encapsulate the control parameters as formal parameters to obtain a ripple loop function.
[0076] In this embodiment, the formal parameters may include at least one of a grid parameter, a ripple diffusion period, a ripple diffusion speed, and a ripple diffusion wavelength. That is, during function encapsulation, the formal parameters can be set based on actual application requirements. For example, to simulate the varying ripple densities generated by raindrops falling at different precipitation intensities, grid parameters and ripple diffusion speed can be used as formal parameters. It should be noted that this example is merely illustrative and not limiting.
[0077] Step S170: Get the input value of the formal parameter.
[0078] Step S180: Call the ripple loop function to generate a new ripple effect according to the input value.
[0079] When the user calls the encapsulated ripple loop function, they need to assign values to the formal parameters according to the actual application requirements to obtain the input values of the formal parameters. Based on the input values, the ripple loop function is run to obtain a new ripple effect.
[0080] In another optional embodiment, when the control parameters also include ripple diffusion speed and ripple diffusion wavelength, a new ripple effect can be obtained by changing the control parameters. Figure 5 , Figure 5The third flow chart of a ripple simulation method provided by an embodiment of the present invention further includes the following steps:
[0081] Step S160a: Obtain updated control parameters.
[0082] Step S170b: Generate a new ripple effect in the target plane based on the updated control parameters.
[0083] It is understood that the user can adjust the ripple effect by changing at least one of the grid parameters, ripple diffusion period, ripple diffusion speed, and ripple diffusion wavelength. In other words, the number of control parameters changed by the user corresponds to the number of updated control parameters. The updated control parameters may include at least one of the grid parameters, ripple diffusion period, ripple diffusion speed, and ripple diffusion wavelength.
[0084] See Figure 6 , Figure 6 (a) is a schematic diagram of the ripple effect obtained by interception. Figure 6 (b) shows the effect of doubling the ripple diffusion wavelength based on (a), where (a) and (b) are captured at the same moment in the same ripple diffusion cycle. Figure 6 The ripples shown in (c) and (b) have the same control parameters. (b) and (c) were captured at different times during the ripple's propagation cycle. As can be seen from the figure, some ripple waveforms propagate independently and remain intact, while others overlap, creating intersecting, overlapping areas.
[0085] Optional, see Figure 7 , Figure 7 The fourth flowchart of a ripple simulation method provided by an embodiment of the present invention, the sub-steps of step S130 include:
[0086] Step S130-1: assign a random point to each grid.
[0087] Step S130 - 2 : For each ripple corresponding to a random point, set the ripple occurrence time to any time within the ripple diffusion period.
[0088] It is understood that a random time offset can be set for each random point to determine the appearance time of the corresponding ripple in the ripple diffusion cycle. In particular, for multiple ripple diffusion cycles, the appearance time of ripples in the same grid can be the same, and the appearance time of ripples in different grids can be different.
[0089] See Figure 8 , Figure 8Schematic diagram of the relationship between the ripple diffusion cycle and the moment of ripple appearance. In the figure, the time axis is divided into four time periods by the four moments t1, t2, t3, and t5. The four time periods correspond to T1, T2, T3, and T4, which are equal, and T1 to T4 can represent the first to fourth ripple diffusion cycles, respectively. S1 to S4 and S1′ to S4′ on the time axis are the moments of ripple appearance, and the time interval between the two moments of appearance corresponding to two adjacent ripple diffusion cycles is equal to the ripple diffusion cycle, that is, T′=T1 and T″=T1 in the figure.
[0090] In (a), S1 to S4 represent the same appearance time of the ripples in the first grid during different ripple diffusion cycles, and S1′ to S4′ represent the same appearance time of the ripples in the second grid during different ripple diffusion cycles. Within the same ripple diffusion cycle, the appearance time S1 of the ripples in the first grid can be different from the appearance time S1′ of the ripples in the second grid.
[0091] Optionally, each ripple can correspond to the first waveform diffusion information during independent diffusion, and the waveform diffusion information corresponding to each ripple can be the sum of multiple first waveform diffusion information. Figure 9 , Figure 9 The fifth flow chart of a ripple simulation method provided by an embodiment of the present invention, the sub-steps of step S140 include:
[0092] Step S140 - 1 : Based on the row and column information and current cycle information of the ripple corresponding to each grid, obtain a random number for each ripple.
[0093] In this embodiment, the target plane is divided into multiple grids based on the grid parameters, and the row and column information of the ripple can indicate that the ripple is located in the grid corresponding to the mth row and the nth column of the target plane.
[0094] Step S140 - 2 : Obtain the attenuation coefficient of each ripple according to each random number.
[0095] It can be understood that when the ripples spread, the ripples will decay and disappear with the diffusion distance, and the attenuation coefficient can represent the degree of attenuation when the ripples spread.
[0096] Step S140 - 3 : Calculate first waveform diffusion information of each ripple based on the predefined ripple waveform function and ripple width function, and each attenuation coefficient.
[0097] In this embodiment, each ripple may correspond to a first waveform diffusion information, which represents the waveform change when the ripple diffuses independently. The ripple waveform function and the ripple width function may be predefined according to the control parameters, and the ripple waveform function may be a sine function.
[0098] Combine Figure 6 As can be seen from the ripple waveforms shown, some ripples spread independently and their waveforms are not affected by the rest of the ripples. However, other ripples intersect with other ripples and their waveforms are affected by the rest of the ripples.
[0099] Step S140 - 4 : For each ripple, superimpose the first waveform diffusion information of multiple other ripples surrounding the ripple to obtain the waveform diffusion information corresponding to the ripple.
[0100] It can be understood that in order to simulate the waveform changes caused by the intersection of ripples, for one of the ripples, it is necessary to superimpose the first waveform diffusion information of the surrounding ripples to obtain the corresponding waveform diffusion information. Based on the above-mentioned ripple simulation device, the embodiment of the present invention also provides a ripple simulation device 200, see Figure 10 , Figure 10 This is a functional module diagram of a ripple simulation device provided by an embodiment of the present invention. The ripple simulation device 200 includes:
[0101] The acquisition module 210 is used to acquire control parameters, which include grid parameters and ripple diffusion period.
[0102] The processing module 220 is configured to divide the target plane into a plurality of grids according to the grid parameters and to assign a random point to each grid according to the ripple diffusion period, wherein the random point represents the center of the ripple.
[0103] The acquisition module 210 is further configured to obtain waveform diffusion information of the ripples corresponding to each grid according to the row and column information and current cycle information of each grid.
[0104] The waveform diffusion information represents the waveform change affected by other ripples when the ripple diffuses, and the current cycle information represents that the current ripple diffusion cycle is the i-th cycle.
[0105] The processing module 220 is further configured to generate a ripple effect in the target plane based on the control parameters according to all waveform diffusion information.
[0106] In this embodiment, the acquisition module 210 can be used to execute Figure 2 In the steps S110 and S140 shown, the processing module 220 can be used to perform Figure 2 Regarding the steps S120, S130 and S150 shown, the relevant contents of the acquisition module 210 and the processing module 220 can refer to the corresponding detailed description above.
[0107] Furthermore, the control parameters may also include a ripple diffusion speed and a ripple diffusion wavelength. The processing module 220 is further configured to:
[0108] The control parameters are used as formal parameters and encapsulated to obtain a ripple circulation function, wherein the formal parameters include at least one of a grid parameter, a ripple diffusion period, a ripple diffusion speed, and a ripple diffusion wavelength.
[0109] Gets the input value of a formal parameter.
[0110] Call the ripple loop function to generate a new ripple effect based on all input values.
[0111] Furthermore, when the control parameters also include the ripple diffusion speed and the ripple diffusion wavelength:
[0112] The acquisition module 210 is further configured to acquire updated control parameters, where the updated control parameters include at least one of a grid parameter, a ripple diffusion period, a ripple diffusion speed, and a ripple diffusion wavelength.
[0113] The processing module 220 is further configured to generate a new ripple effect in the target plane based on the updated multiple control parameters.
[0114] The above-mentioned ripple simulation device 200 is used to execute the method provided by the aforementioned embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0115] The above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more microprocessors (DSPs), or one or more field programmable gate arrays (FPGAs). For example, when a module is implemented by scheduling program code through a processing element, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SoC).
[0116] Further, based on the above ripple simulation method, please refer to Figure 11 , Figure 11This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 300 includes a processor 310, a memory 320, and a bus 330. The memory 320 stores machine-readable instructions executable by the processor 310. When the electronic device is in operation, the processor 310 communicates with the memory 320 via the bus 330, and the processor 310 executes the machine-readable instructions, thereby implementing the above-described method embodiment.
[0117] Furthermore, based on the above-mentioned ripple simulation method, an embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned method embodiment when executed by a processor.
[0118] In summary, embodiments of the present invention provide a ripple simulation method, apparatus, electronic device, and computer-readable storage medium. Control parameters, including grid parameters and a ripple diffusion period, are obtained. Based on the grid parameters, a target plane is divided into multiple grids. Then, based on the ripple diffusion period, a random point is assigned to each grid, representing the center of the ripple. Furthermore, based on the row and column information and current period information of each grid, waveform diffusion information for the ripple corresponding to each grid is obtained. This waveform diffusion information represents the waveform changes as the ripple spreads due to the influence of other ripples, and the current period information indicates the i-th ripple diffusion period. Finally, based on all waveform diffusion information, a ripple effect is generated in the target plane based on the control parameters. Thus, random points are assigned to each grid based on the ripple diffusion period, resulting in random ripple locations within each grid in the target plane. Unlike the prior art method of repeatedly generating ripples at fixed locations, the present invention simulates ripples at random locations, resulting in a more realistic ripple effect, similar to the ripple effect caused by raindrops falling on a surface.
[0119] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A ripple simulation method, characterized in that: include: Acquiring control parameters, wherein the control parameters include grid parameters and ripple diffusion period; Dividing the target plane into a plurality of grids according to the grid parameters; Assigning a random point to each of the grids, wherein the random point represents the center of the ripple; For each ripple corresponding to the random point, the appearance time of the ripple is set to any time within the ripple diffusion period; wherein, for multiple ripple diffusion periods, the appearance time of the ripples in the same grid is the same, and the appearance time of the ripples in different grids is different; Obtaining waveform diffusion information of the ripple corresponding to each grid according to row and column information and current cycle information of each grid, wherein the waveform diffusion information represents waveform changes of the ripple affected by other ripples when the ripple diffuses, and the current cycle information represents that the current ripple is the i-th diffusion cycle; According to all the waveform diffusion information, a ripple effect is generated in the target plane based on the control parameters.
2. The ripple simulation method according to claim 1, characterized in that: The control parameters further include a ripple diffusion speed and a ripple diffusion wavelength, and the method further includes: The control parameters are used as formal parameters to encapsulate and obtain a ripple cycle function; the formal parameters include at least one of the grid parameters, the ripple diffusion period, the ripple diffusion speed, and the ripple diffusion wavelength; Get the input value of the formal parameter; Based on the input value, the ripple loop function is called to generate a new ripple effect.
3. The ripple simulation method according to claim 1, wherein: The control parameters further include a ripple diffusion speed and a ripple diffusion wavelength, and the method further includes: Acquiring updated control parameters, where the updated control parameters include at least one of a grid parameter, a ripple diffusion period, a ripple diffusion speed, and a ripple diffusion wavelength; Based on the updated control parameters, a new ripple effect is generated in the target plane.
4. The ripple simulation method according to claim 1, wherein: The step of obtaining the waveform diffusion information of the ripple corresponding to each grid according to the row and column information and the current cycle information of each grid comprises: Obtaining a random number for each ripple based on row and column information and current cycle information of the ripple corresponding to each grid; Obtaining an attenuation coefficient of each ripple according to each random number, wherein the attenuation coefficient represents the degree of attenuation of the ripple when it spreads; Based on a predefined ripple waveform function and a ripple width function, and each of the attenuation coefficients, calculating first waveform diffusion information of each of the ripples; the first waveform diffusion information represents waveform changes when the ripples diffuse independently; For each ripple, the first waveform diffusion information of a plurality of other ripples surrounding the ripple is superimposed to obtain the waveform diffusion information corresponding to the ripple.
5. A ripple simulation device, characterized in that: include: An acquisition module, configured to acquire control parameters, wherein the control parameters include grid parameters and a ripple diffusion period; a processing module, configured to divide the target plane into a plurality of grids according to the grid parameters; The processing module is further configured to assign a random point to each of the grids, where the random point represents the center of the ripple; The processing module is further configured to set, for each ripple corresponding to the random point, an appearance time of the ripple to any time within the ripple diffusion period; wherein, for multiple ripple diffusion periods, the appearance time of the ripples in the same grid is the same, and the appearance time of the ripples in different grids is different; The acquisition module is further configured to obtain waveform diffusion information of the ripple corresponding to each grid according to row and column information and current cycle information of each grid, wherein the waveform diffusion information represents waveform changes of the ripple affected by other ripples when the ripple diffuses, and the current cycle information represents that the current period is the i-th ripple diffusion cycle; The processing module is further configured to generate a ripple effect in the target plane based on the control parameters according to all the waveform diffusion information.
6. The ripple simulation device according to claim 5, characterized in that The control parameters also include ripple diffusion speed and ripple diffusion wavelength, and the processing module is further configured to: The control parameters are used as formal parameters to encapsulate and obtain a ripple cycle function; the formal parameters include at least one of the grid parameters, the ripple diffusion period, the ripple diffusion speed, and the ripple diffusion wavelength; Get the input value of the formal parameter; Based on all the input values, call the ripple loop function to generate a new ripple effect.
7. The ripple simulation device according to claim 5, characterized in that The control parameters also include ripple diffusion speed and ripple diffusion wavelength; The acquisition module is further configured to acquire updated control parameters, wherein the updated control parameters include at least one of a grid parameter, a ripple diffusion period, a ripple diffusion speed, and a ripple diffusion wavelength; The processing module is further configured to generate a new ripple effect in the target plane based on the updated multiple control parameters.
8. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the processor executes the machine-readable instructions to perform the steps of the simulation method as described in any one of claims 1 to 4.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Method and system for realizing special effects of dripping and rippling of image raindrops
CN111008928A