Virtual water surface wave ripple generation method and device, storage medium and electronic equipment
Patent Information
- Application Number
- CN202310343995.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2043-03-28
AI Technical Summary
Existing methods for generating virtual water ripples produce effects with low realism and poor aesthetics, resulting in a poor user experience.
By acquiring virtual scene information, a target ripple texture is generated, and the movement direction and speed of the target ripple particles are set based on preset wind direction parameters to generate ripple effects on the virtual water surface.
It improves the realism and aesthetics of virtual water ripples, enhances the user's immersion, and achieves water ripple effects with different degrees of fluctuation by modifying preset wind direction parameters, thereby improving generation efficiency and diversity.
Smart Images

Figure CN116778059B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method for generating virtual water surface ripples, a device for generating virtual water surface ripples, a computer-readable storage medium, and an electronic device. Background Technology
[0002] In virtual scenes, it is often necessary to create water ripple effects for floating objects or virtual objects that protrude from the water surface to make the virtual scene more vivid.
[0003] In related technologies, quadrilateral meshes are usually bent into flat circles, and then ripple maps are used to render the mesh to generate the ripple effect of virtual water surface. Obviously, the ripple effect of virtual water surface generated by this method has low realism and poor aesthetics, resulting in a poor user experience. Summary of the Invention
[0004] This disclosure provides a method for generating virtual water surface ripples, a device for generating virtual water surface ripples, a computer-readable storage medium, and an electronic device, thereby improving the problem of low realism of virtual water surface ripples to at least a certain extent.
[0005] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.
[0006] According to a first aspect of this disclosure, a method for generating virtual water surface ripples is provided, comprising: acquiring first scene information in a virtual scene, and acquiring a target ripple texture based on the first scene information, wherein the virtual scene includes a virtual water surface, and the first scene information is acquired based on the virtual scene; determining a target ripple particle from candidate ripple particles based on the target ripple texture, and acquiring the initial motion direction and size of the target ripple particle based on second scene information obtained from the target ripple texture, to initialize the target ripple particle; acquiring the actual motion direction and actual motion speed of the target ripple particle based on a preset wind direction parameter, the initial motion direction and initial motion speed of the target ripple particle, and setting the motion direction and motion speed of the target ripple particle based on the actual motion direction and actual motion speed, to generate a ripple effect on the virtual water surface.
[0007] According to a second aspect of this disclosure, a virtual water ripple generation device is provided, comprising: a target ripple texture acquisition module configured to acquire first scene information in a virtual scene and acquire a target ripple texture based on the scene information, wherein the virtual scene includes a virtual water surface, and the first scene information is acquired based on the virtual scene; a target ripple particle initialization module configured to determine a target ripple particle from candidate ripple particles based on the target ripple texture, and acquire the initial motion direction and size of the target ripple particle according to the second scene information obtained from the target ripple texture, so as to initialize the target ripple particle; and a motion direction and motion speed setting module configured to acquire the actual motion direction and actual motion speed of the target ripple particle according to a preset wind direction parameter, the initial motion direction and initial motion speed of the target ripple particle, and set the motion direction and motion speed of the target ripple particle based on the actual motion direction and actual motion speed, so as to generate a ripple effect on the virtual water surface.
[0008] According to a third aspect of this disclosure, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the virtual water surface ripple generation method of the first aspect described above and its possible implementations.
[0009] According to a fourth aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor. The processor is configured to execute the virtual water ripple generation method of the first aspect and its possible implementations thereof via executing the executable instructions.
[0010] The technical solution disclosed herein has the following beneficial effects:
[0011] On the one hand, the solution obtains target ripple textures based on scene information in the virtual scene, generates target ripple particles based on the target ripple textures, and sets the actual movement direction and speed of the target ripple particles according to preset wind direction parameters. This allows the solution to present detailed information about water ripples, improve the realism and aesthetics of the water ripple effect, and further enhance the user's immersion. On the other hand, by setting the actual movement direction and speed of the target ripple particles based on preset wind direction parameters and the initial movement direction and speed of the target ripple particles, different degrees of ripple effects can be achieved by modifying the preset wind direction parameters, enhancing the diversity and flexibility of the water ripple effect. Furthermore, the solution implements an automated method for generating virtual water ripples, greatly improving the generation efficiency of virtual water ripple effects.
[0012] 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
[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0014] Figure 1A A schematic diagram of a circular grid is shown;
[0015] Figure 1B This diagram illustrates a rendered circular mesh.
[0016] Figure 1C A schematic diagram of a virtual water surface ripple is shown;
[0017] Figure 2 This illustrates the system operating architecture of this exemplary embodiment;
[0018] Figure 3 This diagram illustrates a flowchart of a virtual water surface ripple generation method in this exemplary embodiment;
[0019] Figure 4A This example illustrates a grayscale mask texture when the first scene information includes scene depth information in this exemplary embodiment.
[0020] Figure 4B This illustration shows a schematic diagram of virtual water surface ripples when the first scene information includes scene depth information in this exemplary embodiment.
[0021] Figure 5A This example illustrates a grayscale mask texture when the first scene information includes SDF information in this exemplary embodiment.
[0022] Figure 5B This illustration shows a virtual water surface ripple diagram when the first scene information includes SDF information in this exemplary embodiment.
[0023] Figure 6 This illustrates a flowchart of obtaining a target ripple map in this exemplary embodiment;
[0024] Figure 7 This diagram illustrates a flowchart of obtaining intersection information, dimension information, and normal information in this exemplary embodiment.
[0025] Figure 8 This illustrates a flowchart of a method for acquiring target ripple particles in this exemplary embodiment;
[0026] Figure 9AA schematic diagram showing a spherical virtual obstacle in a virtual water surface;
[0027] Figure 9B This diagram illustrates the region where a target ripple particle is located in this exemplary embodiment.
[0028] Figure 10 A schematic diagram of a virtual water surface ripple is shown in this exemplary embodiment;
[0029] Figure 11 A flowchart illustrating another method for generating virtual water surface ripples in this exemplary embodiment is shown.
[0030] Figure 12 This diagram illustrates the structure of a virtual water surface ripple generation device according to this exemplary embodiment.
[0031] Figure 13 A schematic diagram of the structure of an electronic device in this exemplary embodiment is shown. Detailed Implementation
[0032] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0033] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0034] In non-photorealistic rendering (NPR), workers typically use quadrilateral meshes bent into... Figure 1A The circular grid shown is then processed using a wave map. Figure 1A Render the circular mesh to obtain Figure 1B The water surface ripples shown, and Figure 1B The water ripples shown are applied to a virtual scene to obtain Figure 1C The virtual water ripple effect shown is poor; however, the virtual water ripples generated by this method have low realism and weak aesthetics, which reduces the user experience.
[0035] In view of one or more of the above-mentioned problems, this disclosure first provides an exemplary embodiment of a method for generating virtual water surface ripples. The following describes the method in conjunction with... Figure 2 The system architecture of the operating environment for this exemplary embodiment will be described.
[0036] refer to Figure 2 As shown, the system architecture 200 may include a terminal device 210. The terminal device 210 may be an electronic device such as a laptop, desktop computer, or tablet computer, and the terminal device 210 may be used to obtain first scene information in a virtual scene.
[0037] The virtual water ripple generation method in this exemplary embodiment can be executed by the terminal device 210. For example, in a game scene, the terminal device 210 can be a computer used by staff to create the game, and the virtual scene can be a game scene that needs to generate virtual water ripples. The terminal device 210 can execute the virtual water ripple generation method to obtain first scene information in the virtual scene, obtain a target ripple texture based on the first scene information, obtain target ripple particles based on the target ripple texture, and then set the actual movement speed and actual movement direction of the target ripple particles to present a highly realistic virtual water ripple effect to the player in the virtual scene, further enhancing the player's immersion.
[0038] As can be seen from the above, the virtual water surface ripple generation method in this exemplary embodiment can be executed by the aforementioned terminal device 210.
[0039] The following is combined Figure 3 The method for generating virtual water surface ripples is explained. Figure 3 An exemplary flow of a method for generating virtual water surface ripples is shown, including the following steps S310 to S330:
[0040] Step S310: Obtain first scene information in the virtual scene, and obtain the target ripple texture based on the first scene information. The virtual scene includes a virtual water surface, and the first scene information is obtained based on the virtual scene.
[0041] Step S320: Based on the target ripple texture, determine the target ripple particle among the candidate ripple particles, and obtain the initial motion direction and size of the target ripple particle according to the second scene information obtained from the target ripple texture, so as to initialize the target ripple particle.
[0042] Step S330: Obtain the actual motion direction and actual motion speed of the target ripple particle according to the preset wind direction parameters, the initial motion direction and initial motion speed of the target ripple particle, and set the motion direction and motion speed of the target ripple particle based on the actual motion direction and actual motion speed to generate ripple effect on the virtual water surface.
[0043] Based on the above method, on the one hand, the target ripple texture is obtained based on the scene information in the virtual scene, and target ripple particles are generated based on the target ripple texture. Then, the actual movement direction and actual movement speed of the target ripple particles are set according to the preset wind direction parameters, so that this solution can present the detailed information of water surface ripples, improve the realism and aesthetics of water surface ripple effects, and further enhance the user's immersion. On the other hand, the actual movement direction and actual movement speed of the target ripple particles are set based on the preset wind direction parameters and the initial movement direction and initial movement speed of the target ripple particles. By modifying the preset wind direction parameters, water surface ripple effects with different degrees of fluctuation can be achieved, enhancing the diversity and flexibility of water surface ripple effects. Furthermore, an automated method for generating virtual water surface ripples is realized, which greatly improves the generation efficiency of virtual water surface ripple effects.
[0044] The following is about Figure 3 Each step in the process will be explained in detail.
[0045] refer to Figure 3 In step S310, first scene information in the virtual scene is obtained, and target ripple texture is obtained based on the first scene information. The virtual scene includes a virtual water surface, and the first scene information is obtained based on the virtual scene.
[0046] The aforementioned first scene information is information obtained from the virtual scene for generating virtual water surface ripples. For example, the first scene information may include the size information and normal information of virtual obstacles in the virtual water surface. The target ripple texture is a texture used to generate ripple particles. For example, the target ripple texture may be obtained by superimposing multiple render targets (RTs).
[0047] The following explains several methods for generating virtual water ripples using information from the first scene.
[0048] In one embodiment, the first scene information may include scene depth information of the virtual scene, and the above method may further include: obtaining the intersection information of the virtual obstacle and the virtual water surface according to the scene depth information, generating a grayscale mask texture based on the intersection information, and generating a ripple effect of the virtual water surface according to the grayscale mask texture.
[0049] Virtual obstacles include virtual floating objects existing in the virtual water surface, or other virtual models that affect the flow of the virtual water surface. This disclosure does not specifically limit the specific type of virtual obstacles. For example, virtual obstacles can be virtual rocks, virtual aquatic plants, etc. in the virtual water surface. Grayscale mask textures can be used to reflect the distance information of models in the virtual scene.
[0050] For example, one can first obtain information about the intersection points of virtual obstacles and virtual water surfaces based on scene depth information in the virtual scene. After obtaining the intersection point information, further information can be obtained such as... Figure 4A The scene grayscale mask texture shown is then blended with a preset ripple pattern texture to obtain the following result: Figure 4B The water ripple effect shown.
[0051] The method of obtaining virtual water surface ripple effects through scene depth can generate virtual ripple effects by adding ripple calculations to the virtual water surface. The calculation method is relatively simple and has low computational complexity.
[0052] Since scene depth reflects the distance information between virtual models and virtual cameras in a virtual scene, the ripple effect of virtual water surface can also be generated by the signed distance field (SDF) information that reflects the distance between virtual models: In one implementation, the SDF information in the virtual scene can be obtained, and the grayscale mask texture of the virtual scene can be obtained based on the SDF information, and the ripple effect of virtual water surface can be generated according to the grayscale mask texture.
[0053] SDF information stores spatial distance information between models within the scene. The difference between SDF information and scene depth information is that scene depth information stores the depth information of the virtual model as seen from the rendered camera's view plane; while SDF is independent of the virtual camera and stores the distance information between the virtual model in the scene and other surrounding virtual models.
[0054] For example, it is possible to generate something like this by obtaining the SDF information of a virtual scene. Figure 5A The grayscale mask texture shown is used to generate a model based on the grayscale mask texture. Figure 5B The ripple effect on the virtual water surface shown.
[0055] Since SDF information is generated based on three-dimensional space, the virtual water ripple effect generated based on SDF information has a stronger sense of three-dimensionality.
[0056] Furthermore, since obtaining the SDF information of the virtual scene requires a high amount of computation, the method of generating virtual water ripples based on scene depth information can be applied to the rendering of virtual water ripple effects on mobile devices, while the method of generating virtual water ripples based on SDF information can be applied to the rendering of virtual water ripple effects on high-configuration terminals.
[0057] pass Figure 4B and Figure 5B It can be seen that the two virtual water surface ripple generation methods described above produce ripple effects of the same thickness when facing virtual obstacles of different sizes. However, in reality, obstacles of different sizes exert different resistances on water flow, and the ripple effect thickness produced by different obstacles should be different. Therefore, in one embodiment, the first scene information includes the intersection information of the virtual water surface and the virtual obstacle, the size information of the scaled virtual obstacle, and the normal information of the virtual obstacle. Obtaining the first scene information in the virtual scene and obtaining the target ripple texture based on the first scene information may include the following steps:
[0058] When the virtual obstacle is a static model, intersection information, size information, and normal information are obtained from the image of the virtual obstacle captured by the virtual camera. These information are then added to the target material to obtain intersection texture, size texture, and normal texture. The obtained intersection texture, size texture, and normal texture are then superimposed to obtain the target ripple map. When the virtual obstacle is a dynamic model, virtual rays are emitted in the virtual scene. First scene information is obtained based on the intersection of the virtual ray and the virtual obstacle. This first scene information is then output to the target texture to obtain the target ripple map.
[0059] The intersection information texture, size information texture, and normal information texture can be a rendering texture (RT) with intersection information, a rendering texture with size information, and a rendering texture with normal information, respectively. A static model can be a model that, upon acquiring the first scene information, simultaneously transmits vertex and shadow information to the rendering pipeline and executes a single draw call command for rendering. This disclosure does not specifically limit the content of the static model; for example, a static model can include a static mesh. A dynamic model, on the other hand, is a model obtained by continuously updating rendering commands in the rendering thread after acquiring the first scene information. For example, a dynamic model can include other models such as a landscape model. An exemplary process of this exemplary embodiment can be as follows: Figure 6 As shown:
[0060] Step S601: Begin acquiring the first scene information;
[0061] Step S602: When the virtual obstacle is a static model, obtain the intersection information, size information and normal information based on the image with the virtual obstacle captured by the virtual camera.
[0062] Step S603: Add the intersection information, size information, and normal information to the target material to obtain the intersection information texture, size information texture, and normal information texture;
[0063] Step S604: Overlay the obtained intersection information texture, size information texture, and normal information texture to obtain the target ripple map.
[0064] Step S605: When the virtual obstacle is a dynamic model, virtual light rays are emitted in the virtual scene, and the first scene information is obtained based on the intersection of the virtual light rays and the virtual obstacle.
[0065] Step S606: Output the first scene information to the target texture to obtain the target ripple map.
[0066] For example, to obtain a target ripple map based on virtual first scene information in a virtual scene, for static models, intersection information, size information, and normal information can be obtained from images captured by a virtual camera containing virtual obstacles and virtual water surfaces. These intersection information, size information, and normal information are then rendered onto the target texture to obtain intersection information texture, size information texture, and normal information texture. These three textures are then superimposed and their formats are converted to obtain a target ripple map in static texture format. For dynamic models, linear ray tracing can be used to continuously traverse the virtual scene and process the row and column information of the virtual obstacle surfaces to obtain first scene information. This first scene information is then output to the target texture to obtain the target ripple map.
[0067] based on Figure 6 The method can acquire first scene information in different ways according to the model category to which the virtual obstacle belongs, thereby improving the efficiency and completeness of first scene information acquisition.
[0068] In one implementation, the intersection information, size information, and normal information are obtained from the image captured by the virtual camera containing virtual obstacles, such as... Figure 7 As shown, steps S710 to S730 may be included:
[0069] Step S710: Determine the intersection information based on the position information of the intersection point between the virtual obstacle and the virtual water surface in the virtual scene.
[0070] Step S720: Scale the virtual obstacle in the image according to a preset scaling ratio, and obtain size information based on the size of the scaled virtual obstacle;
[0071] Step S730: Convert the normal vector of the virtual obstacle surface in the image into color values, and obtain normal information based on the color values.
[0072] The preset scaling ratio is the basis for scaling the size of the virtual obstacle to the target data range. This disclosure does not impose any special limitation on the specific value of the preset scaling ratio.
[0073] For example, the intersection point information can be obtained based on the position coordinates of the intersection point between the virtual obstacle and the virtual water surface. Then, the size of the virtual obstacle can be scaled to between 0 and 1 according to a preset scaling ratio, and the scaled size of the virtual obstacle can be used as the size information. Alternatively, the normal vector of the virtual obstacle surface can be converted into the corresponding RGB color value using the packNormalToRGB() function in the Unity game engine, so as to obtain the normal information based on the RGB color value.
[0074] based on Figure 7 The method obtains intersection information, size information, and normal information respectively, and further obtains three types of texture information to generate a target ripple map for rendering the ripple effect of virtual water surface. This improves the data richness used to generate virtual water surface ripples, making the generated virtual water surface ripples more vivid and realistic.
[0075] Since particle rendering can be used to render fluid models such as liquids and gases, in step S320, the target ripple particle can be determined from the candidate ripple particles based on the target ripple texture, and the initial motion direction and size of the target ripple particle can be obtained according to the second scene information stored in the target ripple texture to initialize the target ripple particle.
[0076] Here, a particle is a vector, typically used to generate movement effects for simulated fluid models such as liquids and gases; candidate ripple particles are ripple particles generated in batches based on the target ripple texture; the target ripple particles can be particles used to generate virtual water surface ripples produced by virtual obstacles; the initialization of the target ripple particles can be setting default values for the relevant indicators of the target ripple particles, for example, initialization can include setting initial values for the movement direction, size, etc. of the target ripple particles.
[0077] In one implementation, before determining the target ripple particle from the candidate ripple particles based on the target ripple map, and obtaining the initial motion direction and size of the target ripple particle according to the second scene information obtained from the target ripple map, in order to initialize the target ripple particle, the above method may further include:
[0078] The target ripple map is parsed to obtain the second scene information stored in the target ripple map. The second scene information includes the intersection information of the virtual water surface and the virtual obstacle, the size information of the virtual obstacle, and the normal information of the virtual obstacle.
[0079] The second scene information is used to generate candidate ripple particles. The content of the second scene information is the same as that of the first scene information, but the acquisition methods of the second scene information and the first scene information are different. The first scene information is extracted from the virtual scene, while the second scene information is obtained by parsing the target ripple texture obtained from the first scene information.
[0080] For example, the target ripple map can be parsed using the DecodeLightmap function built into the Unity game engine, and then the first scene information stored in the target ripple map can be converted into second scene information that can be used to generate wave particles using the Niagara application framework.
[0081] By analyzing the target ripple map, we can obtain the second scene information used to generate ripple particles, which helps to improve the generation efficiency of ripple particles.
[0082] In one implementation, the above-described method for determining target ripple particles from candidate ripple particles based on the target ripple map is as follows: Figure 8 As shown, steps S810 to S820 may be included:
[0083] Step S810: Obtain the UV coordinates of the target ripple particles based on the intersection information of the target ripple map;
[0084] Step S820: Determine the target ripple particle from the candidate ripple particles based on the UV coordinates of the target ripple particle.
[0085] For example, if it is necessary to generate Figure 9A For water ripples on a spherical virtual obstacle, the texture of the target ripple map is first sampled using stereo rendering to generate candidate ripple particles at random positions within the virtual volume box. Then, the UV coordinates of the target ripple particles are determined based on the intersection point information between the virtual obstacle and the virtual water surface in the target ripple map. Finally, the target ripple particle is selected from the candidate ripple particles within the virtual volume box based on its UV coordinates. Figure 9BThe particles in the shaded area are the areas where the target ripple particles are located. After determining the target ripple particles, the remaining candidate ripple particles in the virtual volume box can be deleted to obtain the water surface ripples of the spherical virtual obstacle.
[0086] based on Figure 8 The method identifies the target ripple particle among candidate ripple particles, which can eliminate the interference of other candidate ripple particles on the generated virtual water surface ripples, thus improving the accuracy of the virtual water surface ripples.
[0087] In one embodiment, before obtaining the UV coordinates of the target ripple particles based on the intersection information in the target ripple map, the following steps may also be included:
[0088] The relative position coordinates of the candidate ripple particles are obtained by the difference between the world coordinates of the candidate ripple particles and the world coordinates of the virtual emitter of the ripple particles.
[0089] The relative position coordinates are scaled to a preset range, and the UV coordinates of the candidate ripple particles are calculated based on the scaled relative position coordinates.
[0090] The preset value range can be the scaled relative position coordinate data range. For example, since the UV coordinate range is 0 to 1, the preset value range can be set to -1 to 1 to facilitate calculation.
[0091] For example, after obtaining the relative position coordinates of the candidate ripple particles, the relative position coordinates can be scaled to a preset value range of -1 to 1 based on the ratio of the relative position coordinates to the total volume of the candidate ripple particles. Since the data range of UV coordinates is 0 to 1, the scaled relative position coordinates can be multiplied by 0.5 and then added by 0.5 to convert the relative position coordinates into UV coordinates with a data range of 0 to 1.
[0092] Obtaining the UV coordinates of candidate ripple particles using relative position coordinates simplifies the calculation logic, reduces computational complexity, and improves the overall efficiency of the method.
[0093] After determining the target ripple particle, the target ripple particle can be initialized. In one implementation, obtaining the initial motion direction and size of the target ripple particle based on the second scene information stored in the target ripple texture may include the following steps:
[0094] The initial motion direction of the target ripple particle is determined based on the normal information in the second scene information, and the size of the target ripple particle is calculated based on the size information in the second scene information.
[0095] For example, in the Niagara application framework, intersection information can be obtained from the target ripple map, and particle generation positions can be obtained based on the intersection information. Candidate wave particles can be generated in batches at the particle generation positions. The world coordinates of the candidate wave particles can be converted into UV coordinates, and the target ripple map can be sampled using the UV coordinates to obtain the target ripple particles. Then, the initial motion direction of the target ripple particles can be determined based on the normal information in the target ripple map, and the size of the target ripple particles can be calculated based on the size information in the target ripple map.
[0096] Since the generated target ripple particles are determined based on the size information of the virtual obstacles stored in the target ripple texture, virtual obstacles of different sizes can produce ripple effects of virtual water surfaces of different sizes, making the generated virtual water surface ripples more realistic and further enhancing the user's immersion.
[0097] To achieve the effect of virtual water ripples moving with the wind, continue to refer to... Figure 3 In step S330, the actual motion direction and actual motion speed of the target ripple particle are obtained according to the preset wind direction parameters, the initial motion direction and initial motion speed of the target ripple particle, and the motion direction and motion speed of the target ripple particle are set based on the actual motion direction and actual motion speed to generate ripple effect on the virtual water surface.
[0098] Among them, the preset wind direction parameter can be a vector representing the wind direction and wind intensity, and the actual motion direction and actual motion speed of the target ripple particle can be the ripple direction and motion speed of the target ripple particle after being affected by the preset wind direction parameter.
[0099] In one embodiment, obtaining the actual motion direction and actual motion velocity of the target ripple particle based on preset wind direction parameters, the initial motion direction and initial motion velocity of the target ripple particle may include the following steps:
[0100] The actual motion direction of the target ripple particles is determined based on the preset wind direction parameters and the initial motion direction.
[0101] The actual velocity of the target ripple particles is determined by the sum of the preset wind direction parameters and the initial velocity.
[0102] For example, the preset wind direction parameter can be a wind direction vector that includes wind direction and wind intensity. The wind direction vector can be passed into Niagara through Unreal Engine (UE) so that the actual motion direction of the target ripple particle can be determined in Niagara based on the wind direction vector and the initial motion direction of the target ripple particle, and the actual motion speed of the target ripple particle can be calculated based on the sum of the wind direction vector and the initial motion speed.
[0103] By presetting wind direction parameters and the initial motion direction and initial velocity of the target ripple particles, we can obtain, for example... Figure 10 The ripple effect shown dynamically changes with the wind direction and magnitude, making the ripple effect on the virtual water surface more realistic. Different ripple effects can also be obtained by adjusting the preset wind direction parameters, further improving the diversity and flexibility of the ripple effect.
[0104] Based on the above methods, not only is the realism of the virtual water ripple effect improved, but the diversity and flexibility of the virtual water ripple effect are also enhanced, thus improving the user experience.
[0105] In one implementation, an exemplary process of this disclosure can be as follows: Figure 11 As shown, it may include steps S1101 to S1110:
[0106] Step S1101: Obtain the intersection information of the virtual obstacle and the virtual water surface based on the water surface height information, convert the intersection information into RGB color values, and add the color values to the target material to obtain the intersection information texture;
[0107] Step S1102: Scale the size of the virtual obstacle to the range of 0 to 1, convert the scaled size information into RGB color values, and add the color values to the target material to obtain the size information texture;
[0108] Step S1103: Obtain the normal vector of the virtual obstacle surface, convert the normal vector into RGB color value, and add the color value to the target material to obtain the normal information texture;
[0109] Step S1104: Overlay the intersection information texture, the size information texture, and the normal information texture, and convert the overlaid texture into a static texture to obtain the target ripple map.
[0110] Step S1105: Decode the target ripple map to obtain the intersection information of the virtual obstacle and the virtual water surface, the size information of the virtual obstacle, and the normal information of the virtual obstacle.
[0111] Step S1106: Input the intersection information of the virtual obstacle and the virtual water surface, the size information of the virtual obstacle, the normal information of the virtual obstacle, the preset wind direction parameters, and the initial motion velocity of the ripple particles into the Niagara application framework.
[0112] Step S1107: Obtain the UV coordinates of the target ripple particles based on the intersection information of the target ripple map;
[0113] Step S1108: Determine the target ripple particle from the candidate ripple particles based on the UV coordinates of the target ripple particle.
[0114] Step S1109: Determine the size of the target ripple particle based on the above size information, and determine the initial motion direction of the target ripple particle based on the above normal information;
[0115] Step S1110: Set the actual motion direction of the target ripple particle by using preset wind direction parameters and initial motion direction, and set the actual motion speed of the target ripple particle based on the sum of preset wind direction parameters and initial motion speed.
[0116] based on Figure 11 The method described above can achieve a highly realistic dynamic effect of virtual water ripples changing with the wind.
[0117] To improve the convenience of the virtual water surface ripple generation method, in one embodiment, the above-mentioned... Figure 11 The process is integrated into the Unreal Engine's UI button "Generate Water Foam Particles" to enable one-click generation of virtual water surface ripple effects, thereby greatly improving work efficiency.
[0118] Exemplary embodiments of this disclosure also provide a virtual water surface ripple generation apparatus. For example... Figure 12 As shown, the virtual water surface ripple generation device 1200 may include:
[0119] The target ripple texture acquisition module 1210 is configured to acquire first scene information in a virtual scene and acquire a target ripple texture based on the first scene information, wherein the virtual scene includes a virtual water surface and the first scene information is acquired based on the virtual scene;
[0120] The target ripple particle initialization module 1220 is configured to determine the target ripple particle from the candidate ripple particles based on the target ripple texture, and obtain the initial motion direction and size of the target ripple particle according to the second scene information obtained from the target ripple texture, so as to initialize the target ripple particle.
[0121] The motion direction and motion speed setting module 1230 is configured to obtain the actual motion direction and actual motion speed of the target ripple particle based on the preset wind direction parameters, the initial motion direction and initial motion speed of the target ripple particle, and set the motion direction and motion speed of the target ripple particle based on the actual motion direction and actual motion speed to generate ripple effects on the virtual water surface.
[0122] In one implementation, the first scene information includes the intersection information of the virtual water surface and the virtual obstacle, the size information of the scaled virtual obstacle, and the normal information of the virtual obstacle. Obtaining the first scene information in the virtual scene and obtaining the target ripple map based on the first scene information may include:
[0123] When the virtual obstacle is a static model, intersection information, size information, and normal information are obtained from the image of the virtual obstacle captured by the virtual camera. These information are then added to the target material to obtain intersection texture, size texture, and normal texture. The obtained intersection texture, size texture, and normal texture are then superimposed to obtain the target ripple map. When the virtual obstacle is a dynamic model, virtual rays are emitted in the virtual scene. First scene information is obtained based on the intersection of the virtual ray and the virtual obstacle. This first scene information is then output to the target texture to obtain the target ripple map.
[0124] In one embodiment, obtaining intersection information, size information, and normal information from images captured by a virtual camera containing virtual obstacles may include:
[0125] The intersection information is determined based on the positional information of the intersection points between virtual obstacles and virtual water surfaces in the virtual scene.
[0126] The virtual obstacles in the image are scaled according to a preset scaling ratio, and the size information is obtained based on the size of the scaled virtual obstacles.
[0127] The normal vectors of the virtual obstacle surfaces in the image are converted into color values, and the normal information is obtained based on the color values.
[0128] In one embodiment, before initializing the target ripple particle by determining the target ripple particle from the candidate ripple particles based on the target ripple map and obtaining the initial motion direction and size of the target ripple particle according to the second scene information stored in the target ripple map, the above-mentioned device may further include:
[0129] The target ripple map is parsed to obtain the second scene information stored in the target ripple map. The second scene information includes the intersection information of the virtual water surface and the virtual obstacle, the size information of the virtual obstacle, and the normal information of the virtual obstacle.
[0130] In one implementation, the above-mentioned determination of target ripple particles among candidate ripple particles based on the target ripple map may include:
[0131] The UV coordinates of the target ripple particles are obtained based on the intersection information of the target ripple map;
[0132] The target ripple particle is determined from the candidate ripple particles based on its UV coordinates.
[0133] In one embodiment, before obtaining the UV coordinates of the target ripple particles based on the intersection information of the target ripple map, the method may further include:
[0134] The relative position coordinates of the candidate ripple particles are obtained by the difference between the world coordinates of the candidate ripple particles and the world coordinates of the ripple particle virtual emitter.
[0135] The relative position coordinates are scaled to a preset range, and the UV coordinates of the candidate ripple particles are calculated based on the scaled relative position coordinates.
[0136] In one implementation, obtaining the initial motion direction and size of the target ripple particles based on the second scene information stored in the target ripple texture may include:
[0137] The initial motion direction of the target ripple particle is determined based on the normal information in the second scene information, and the size of the target ripple particle is calculated based on the size information in the second scene information.
[0138] In one embodiment, obtaining the actual motion direction and actual motion velocity of the target ripple particles based on preset wind direction parameters, the initial motion direction of the target ripple particles, and the initial motion velocity of the target ripple particles may include:
[0139] The actual motion direction of the target ripple particles is determined based on the preset wind direction parameters and the initial motion direction.
[0140] The actual velocity of the target ripple particles is determined by the sum of the preset wind direction parameters and the initial velocity.
[0141] The specific details of each part of the above-mentioned device have been described in detail in the method section of the implementation, and therefore will not be repeated here.
[0142] Exemplary embodiments of this disclosure also provide a computer-readable storage medium that can be implemented as a program product including program code, which, when run on an electronic device, causes the electronic device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. In an alternative embodiment, the program product can be implemented as a portable compact disc read-only memory (CD-ROM) including program code and can run on an electronic device, such as a personal computer. However, the program product of this disclosure is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0143] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0144] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0145] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0146] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing devices can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0147] Exemplary embodiments of this disclosure also provide an electronic device. The electronic device may include a processor and a memory. The memory stores executable instructions for the processor, such as program code. The processor executes the executable instructions to perform the methods of this exemplary embodiment.
[0148] The following is for reference. Figure 13The electronic device is illustrated by way of a general-purpose computing device. It should be understood that... Figure 13 The electronic device 1300 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.
[0149] like Figure 13 As shown, the electronic device 1300 may include: a processor 1310, a memory 1320, a bus 1330, an I / O (input / output) interface 1340, and a network adapter 1350.
[0150] The processor 1310 may include one or more processing units, such as a central processing unit (CPU), an application processor (AP), a modem processor, a display processing unit (DPU), a graphics processing unit (GPU), an image signal processor (ISP), a controller, an encoder, a decoder, a digital signal processor (DSP), a baseband processor, an artificial intelligence processor, etc. In one implementation, an artificial intelligence processor can acquire first scene information in a virtual scene and obtain a target ripple texture based on the first scene information; then, based on the target ripple texture, a target ripple particle is determined from candidate ripple particles, and based on the second scene information obtained from the target ripple texture, the initial motion direction and size of the target ripple particle are obtained to initialize the target ripple particle; finally, based on preset wind direction parameters, the initial motion direction and initial motion speed of the target ripple particle, the actual motion direction and actual motion speed of the target ripple particle are obtained, and the motion direction and motion speed of the target ripple particle are set based on the actual motion direction and actual motion speed to generate a ripple effect on the virtual water surface.
[0151] Memory 1320 may include volatile memory, such as RAM 1321 and cache unit 1322, and may also include non-volatile memory, such as ROM 1323. Memory 1320 may also include one or more program modules 1324, such program modules 1324 including, but not limited to: operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. For example, program module 1324 may include the modules in the above-described device 1200.
[0152] Bus 1330 is used to connect different components of electronic device 1300 and may include a data bus, an address bus and a control bus.
[0153] Electronic device 1300 can communicate with one or more external devices 1400 (such as keyboard, mouse, external controller, etc.) through I / O interface 1340.
[0154] Electronic device 1300 can communicate with one or more networks via network adapter 1350. For example, network adapter 1350 can provide mobile communication solutions such as 3G / 4G / 5G, or wireless communication solutions such as wireless LAN, Bluetooth, and near-field communication. Network adapter 1350 can communicate with other modules of electronic device 1300 via bus 1330.
[0155] although Figure 13 As not shown in the diagram, other hardware and / or software modules may also be configured in the electronic device 1300, including but not limited to: a display, microcode, device driver, redundant processor, external disk drive array, RAID system, tape drive, and data backup storage system.
[0156] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0157] Those skilled in the art will understand that various aspects of this disclosure can be implemented as systems, methods, or program products. Therefore, various aspects of this disclosure can be embodied in entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuit,” “module,” or “system.” Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0158] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is defined only by the appended claims.
Claims
1. A method for generating virtual water surface ripples, characterized in that, include: First scene information in a virtual scene is obtained, and a target ripple texture is obtained based on the first scene information. The virtual scene includes a virtual water surface, and the first scene information is virtual obstacle information obtained based on the virtual scene for generating virtual water surface ripples. The target ripple map is parsed to obtain the second scene information stored in the target ripple map, wherein the second scene information includes the intersection information of the virtual water surface and the virtual obstacle, the size information of the virtual obstacle, and the normal information of the virtual obstacle; The texture of the target ripple map is sampled by stereo rendering to generate candidate ripple particles at random positions in the virtual volume box. The UV coordinates of the target ripple particles are obtained based on the intersection information of the target ripple map. The target ripple particles are determined from the candidate ripple particles according to the UV coordinates of the target ripple particles. The initial motion direction of the target ripple particle is determined based on the normal information in the second scene information, and the size of the target ripple particle is calculated based on the size information in the second scene information to initialize the target ripple particle; the candidate ripple particles are ripple particles generated in batches based on the target ripple texture. The actual motion direction and speed of the target ripple particle are obtained based on the preset wind direction parameters, the initial motion direction and the initial motion speed of the target ripple particle, and the motion direction and speed of the target ripple particle are set based on the actual motion direction and speed to generate a ripple effect on the virtual water surface.
2. The method according to claim 1, characterized in that, The first scene information includes the intersection point information of the virtual water surface and the virtual obstacle, the scaled size information of the virtual obstacle, and the normal information of the virtual obstacle. The step of obtaining the first scene information in the virtual scene and obtaining the target ripple map based on the first scene information includes: When the virtual obstacle is a static model, the intersection information, size information and normal information are obtained from the image with the virtual obstacle captured by the virtual camera. The intersection information, size information and normal information are added to the target material to obtain the intersection information texture, size information texture and normal information texture. The obtained intersection information texture, size information texture and normal information texture are superimposed to obtain the target ripple map. When the virtual obstacle is a dynamic model, the first scene information is obtained by emitting virtual rays in the virtual scene and obtaining the intersection of the virtual rays and the virtual obstacle, and the first scene information is output to the target texture to obtain the target ripple map.
3. The method according to claim 2, characterized in that, The step of obtaining the intersection information, size information, and normal information based on the image captured by the virtual camera containing the virtual obstacle includes: The intersection information is determined based on the position information of the intersection point between the virtual obstacle and the virtual water surface in the virtual scene. The virtual obstacles in the image are scaled according to a preset scaling ratio, and the size information is obtained based on the size of the scaled virtual obstacles. The normal vectors of the virtual obstacle surfaces in the image are converted into color values, and the normal information is obtained based on the color values.
4. The method according to claim 1, characterized in that, Before obtaining the UV coordinates of the target ripple particles based on the intersection information in the target ripple map, the method further includes: The relative position coordinates of the candidate ripple particle are obtained based on the difference between the world coordinates of the candidate ripple particle and the world coordinates of the ripple particle virtual emitter. The relative position coordinates are scaled to a preset range, and the UV coordinates of the candidate ripple particles are calculated based on the scaled relative position coordinates.
5. The method according to claim 1, characterized in that, The step of obtaining the actual motion direction and actual motion velocity of the target ripple particle based on preset wind direction parameters, the initial motion direction and initial motion velocity of the target ripple particle includes: The actual motion direction of the target ripple particle is determined based on the preset wind direction parameter and the initial motion direction. The actual velocity of the target ripple particle is determined based on the sum of the preset wind direction parameter and the initial velocity.
6. A virtual water surface ripple generation device, characterized in that, include: The target ripple texture acquisition module is configured to acquire first scene information in a virtual scene and acquire a target ripple texture based on the first scene information, wherein the virtual scene includes a virtual water surface, and the first scene information is virtual obstacle information for generating virtual water surface ripples acquired based on the virtual scene; The second scene information acquisition module is used to parse the target ripple map to obtain the second scene information stored in the target ripple map. The second scene information includes the intersection information of the virtual water surface and the virtual obstacle, the size information of the virtual obstacle, and the normal information of the virtual obstacle. The target ripple particle initialization module is configured to sample the texture of the target ripple map through stereo rendering to generate candidate ripple particles at random positions in a virtual volume box; obtain the UV coordinates of the target ripple particles based on the intersection information of the target ripple map; determine the target ripple particle from the candidate ripple particles based on the UV coordinates of the target ripple particle; determine the initial motion direction of the target ripple particle based on the normal information in the second scene information; and calculate the size of the target ripple particle based on the size information in the second scene information to initialize the target ripple particle; the candidate ripple particles are ripple particles generated in batches based on the target ripple map; The motion direction and motion speed setting module is configured to obtain the actual motion direction and actual motion speed of the target ripple particle based on the preset wind direction parameters, the initial motion direction and initial motion speed of the target ripple particle, and set the motion direction and motion speed of the target ripple particle based on the actual motion direction and actual motion speed to generate a ripple effect on the virtual water surface.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 5.
8. An electronic device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to execute the method of any one of claims 1 to 5 by executing the executable instructions.
Citation Information
Patent Citations
Rotor wing underwashing visual simulation method and system based on offshore flight
CN103985148A
Simulating display method and device based on particle movement model
CN106293565A
Fluid rendering method and device, storage medium and terminal equipment
CN111986303A
