Water ripple processing method and device, storage medium and electronic equipment
Patent Information
- Application Number
- CN202111658246.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2041-12-30
AI Technical Summary
[0008]借由上述技术方案,本申请提供的一种的方法、装置、存储介质及电子设备,本申请通过对虚拟对象预先标记发力骨骼,并根据发力骨骼与水面各个点的距离,确定出水面各个点的水波纹作用力,这种方式可以较为真实的反应虚拟对象(人物)在水中运动时对水面产生的波纹影响,因为,水波纹是由于发力骨骼(例如肢体)的动作而产生的,而水面任一点所受水波纹作用力的大小又与该点与肢体的距离相关,因此,通过发力骨骼与水面个点的距离确定水波纹作用力大小的方式,可更为准确、逼真的模拟水波纹效果。
Smart Images

Figure CN116416353B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus, storage medium and electronic device for processing water ripples. Background Technology
[0002] In online games, players often pay attention to the interactive effects between game characters and game scenes displayed on the game interface. For example, if a water ripple effect is displayed when a game character moves through water, it can enhance the visual experience. Summary of the Invention
[0003] In view of this, this application provides a water ripple processing method, apparatus, storage medium and electronic device, the main purpose of which is to optimize the water ripple presentation effect.
[0004] According to one aspect of this application, a water ripple processing method is provided, comprising: acquiring virtual object information in a current virtual scene, the virtual object information including a skeletal model, the skeletal model being pre-marked with force-generating bones, the force-generating bones being bones in the skeletal model capable of generating forces on the water surface; determining the water ripple force exerted by the force-generating bones on various points on the water surface based on the distances between the force-generating bones and various points on the water surface; determining a water ripple height map based on the water ripple force; and performing water ripple propagation calculations on a pre-acquired water ripple texture based on the water ripple height map to obtain a water ripple image.
[0005] According to one aspect of this application, a water ripple processing apparatus is provided, comprising: an acquisition unit, configured to acquire virtual object information in a current virtual scene, the virtual object information including a skeletal model, the skeletal model being pre-marked with force-generating bones, the force-generating bones being bones in the skeletal model capable of generating a force on the water surface; a force determination unit, configured to determine the water ripple force exerted by the force-generating bones on various points on the water surface based on the distance between the force-generating bones and various points on the water surface; a height map determination unit, configured to determine a water ripple height map based on the water ripple force; and a water ripple image determination unit, configured to perform water ripple propagation calculations on a pre-acquired water ripple texture based on the water ripple height map to obtain a water ripple image.
[0006] According to one aspect of this application, a storage medium is provided that stores a computer program, wherein the computer program is configured to execute the above-described water ripple processing method at runtime.
[0007] According to one aspect of this application, an electronic device is provided, including a memory and a processor, characterized in that the memory stores a computer program, and the processor is configured to run the computer program to perform the above-described water ripple processing method.
[0008] Using the above technical solutions, this application provides a method, apparatus, storage medium, and electronic device. This application pre-marks the force-generating skeleton of a virtual object and determines the water ripple force at each point on the water surface based on the distance between the force-generating skeleton and each point on the water surface. This method can more realistically reflect the ripple effect on the water surface when the virtual object (character) moves in the water. This is because water ripples are generated by the movement of the force-generating skeleton (e.g., limbs), and the magnitude of the water ripple force at any point on the water surface is related to the distance between that point and the limb. Therefore, determining the magnitude of the water ripple force by the distance between the force-generating skeleton and each point on the water surface can more accurately and realistically simulate the water ripple effect.
[0009] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0010] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0011] Figure 1 A schematic diagram illustrating an implementation scenario of a water ripple processing method provided in an embodiment of this application is shown.
[0012] Figure 2 A flowchart illustrating an example of a water ripple processing method provided in this application is shown.
[0013] Figure 3 This illustration shows a schematic diagram of water ripple distance provided in an embodiment of this application;
[0014] Figure 4 A flowchart illustrating a second example of a water ripple processing method provided in this application is shown.
[0015] Figure 5 A schematic diagram of the water ripple treatment device provided in an embodiment of this application is shown. Detailed Implementation
[0016] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present application can be combined with each other.
[0017] See Figure 1 This is a schematic diagram of a scenario for a water ripple processing method, which includes a terminal device 102 and a server 104. The water ripple processing method provided in this application embodiment can run on a terminal device or a server. The terminal device can be a local terminal device, such as a mobile phone or computer.
[0018] For convenience, the water ripple processing method provided in this application embodiment is illustrated below using a game scene as an example. However, it is understood that the water ripple processing method provided in this application embodiment can be applied not only to games, but also to other scenarios such as video processing and animation processing.
[0019] See Figure 2 This is a flowchart illustrating an example of a water ripple processing method provided in this application. The water ripple processing method includes the following steps S201-S204.
[0020] S201: Obtain information about virtual objects in the current virtual scene. The information about virtual objects includes a skeletal model. The skeletal model is pre-marked with force-generating bones, which are the bones in the skeletal model that can generate force on the water surface.
[0021] In game scenarios, the water ripple effect presented to the user is generally centered on the game character. For example, as the character moves through the water, ripples are created on the surface. In this embodiment, the moving game character is referred to as a virtual object, that is, the virtual object is a moving game character. Game characters include virtual characters controlled by different players and NPCs (Non-Player Characters), as long as the character can move.
[0022] A force-generating skeleton refers to the components of a virtual object that can exert force to disturb the surface of water. For example, for a virtual character, the force-generating skeleton could refer to the limbs that exert force. A force-generating skeleton can be further labeled with at least two nodes: a starting node for the force exertion and an ending node. For instance, the starting node for a character's force-generating skeleton could be the spinal column, and the ending nodes could be the hands and feet.
[0023] S202: Determine the force exerted by the force-generating skeleton on the water surface at each point based on the distance between the force-generating skeleton and each point on the water surface.
[0024] In this embodiment of the application, in order to improve the user's gaming experience, based on the concept of skeletal perturbation of the water surface, for example, even if the character stands still in the water, as long as the skeletal force is exerted to make a movement, a water ripple effect can be generated. To achieve this multi-point perturbation of various points on the water surface by the exerting skeletal force, it is necessary to determine the water ripple force exerted by the exerting skeletal force on each point on the water surface.
[0025] By calculating the distance between any point on the water surface and the force-generating skeleton, the magnitude of the ripple force exerted by the force-generating skeleton on that point can be determined. It can be understood that the closer a point is to the force-generating skeleton, the greater the ripple force it experiences; conversely, the farther a point is from the force-generating skeleton, the smaller the ripple force it experiences.
[0026] In one implementation, taking a limb as the force-generating skeleton, the starting end node and the ending end node are marked on the limb in advance. Based on the starting end node and the ending end node, the projection distance between any point on the water surface and the force-generating skeleton is calculated. It is determined that the force of the force-generating skeleton on the water ripples at any point is inversely proportional to the projection distance.
[0027] Since the water disturbance is caused by the limbs, the point of force generation should be the limbs, not the intersection of the limbs and the water surface. In this embodiment, the perpendicular line from a point P on the water surface to the "skeletal segment" is used as the distance from P to the point of force generation, thereby determining the strength of the force at point P.
[0028] Let P be a point on the water surface;
[0029] B0 represents the distal end of a limb;
[0030] B1 is the starting point node of the limb;
[0031] The distance from point P to the limb is obtained using the following procedure:
[0032] D0=P-B0.................................Formula(1)
[0033] D1=B1-B0................................Formula (2)
[0034] Distance(P, limb) = P - Dot(D0, D1) * D1............Formula (3)
[0035] Where P represents the coordinates of any point on the water surface, B0 represents the coordinates of the end node, B1 represents the coordinates of the starting end node, D0 represents the distance from point P to B0, D1 represents the distance from the starting end node to the end node of the limb (i.e., the limb length), and Dot() is the dot product function.
[0036] As analyzed earlier, the closer a point is to the skeletal bone exerting force, the greater the force exerted by the water ripples; conversely, the farther a point is from the skeletal bone, the smaller the force exerted by the water ripples. Therefore, the force exerted by the water ripples on point P is inversely proportional to Distance (P, the limb).
[0037] See Figure 3 The diagram illustrates the distances between points on the water surface and the limbs. It shows a virtual character and two points P1 and P2 on the water surface, where P1 is closer to the character and P2 is farther away. The starting node of one of the character's limbs (an upper limb) is labeled B1, and the ending node is labeled B0. Using formulas (1), (2), and (3), the distances between P1 and the limb, Distance(P1, limb), and between P2 and the limb, Distance(P2, limb), can be obtained. It is clear that Distance(P1, limb) is less than Distance(P2, limb).
[0038] For any point P on the water surface, after determining the distance between that point and the limb (power-generating bone), it can be clearly seen that the force exerted by the water ripples on that point is inversely proportional to the distance. That is, the closer the point is to the limb, the greater the force it bears, and vice versa.
[0039] by Figure 3 In the example, since P1 is closer to the limb and P2 is farther away from the limb, the ripple force exerted by the limb on point P1 is greater than the ripple force exerted by the limb on point P2.
[0040] In practice, the attributes of virtual objects interacting with the water surface can be preset. For example, in a game, if the virtual object is a character, water surface interaction attributes can be set for that character. For instance, an actor can be set to have water surface interaction attributes, which include the size of the water surface area (the radius of water surface disturbance) and the force of interaction with the water surface. Initial values for each interaction attribute can also be set, such as the initial value for the water surface disturbance radius and the initial value for the water surface interaction force.
[0041] Therefore, for a given virtual object, the process of determining the force exerted by the force-generating skeleton on the water surface at various points can be as follows: First, obtain the pre-set water surface interaction attributes and initial values for the virtual object. The water surface interaction attributes include the water surface disturbance radius and the water surface interaction force. Then, determine the water surface disturbance range based on the initial value of the water surface disturbance radius. Finally, for each point on the water surface within the water surface disturbance range, calculate the distance between each point and the force-generating skeleton, and determine the force exerted by the force-generating skeleton on the water surface at each point based on the initial value of the water surface interaction force and the distance.
[0042] For example, for a virtual object, assuming it's an Actor in a game, we first examine the Actor's water surface interaction properties. For instance, by examining these properties, we determine that the water surface disturbance radius is R and the initial value of the water surface interaction force is F. original Then, the range of water ripples is determined based on the water surface disturbance radius. That is, the range of water ripples is the range of a circle centered on the position of the character and determined by the water surface disturbance radius (R). Next, for each point on the water surface within the range of water ripples, the distance between each point and the character's limb (powering bone) is calculated, and the initial force is adjusted according to the distance.
[0043] There are several ways to adjust the initial force based on the distance.
[0044] For example, a pre-defined reduction range can be set, indicating that the force exerted by the water ripples decreases by a certain amount as the distance increases by a certain amount. For instance, the reduction range can be set to ΔF, meaning that for every ΔL increase in distance (starting from the initial distance of 0, assuming a point coincides with the limb's projection), the force decreases by ΔF. Therefore, for any point P, when adjusting the initial force based on the distance, the distance between point P and the limb, Distance(P, limb), is calculated. This distance Distance(P, limb) is then determined to be a multiple of ΔL. Assuming it is greater than 2 times ΔL but less than 3 times ΔL, the force can be reduced by two ΔF, thus determining the water ripple force exerted on point P. Let's assume another point Q. The distance between point Q and the limb is calculated as Distance(Q, limb). Determine how many times ΔL this distance Distance(Q, limb) is equal to. Assuming it's greater than 3 times ΔL but less than 4 times ΔL, the force can be reduced by three ΔF. Therefore, the force exerted by the water ripples on point Q is determined to be...
[0045] For example, a force-decreasing function can be constructed, such as:
[0046]
[0047] This represents the force exerted by the water ripples on point P. At the initial value of the applied force F original Based on this, it decreases as Distance (P, limb) increases.
[0048] S203: Determine the water ripple height diagram based on the water ripple force.
[0049] For any point P on the water surface, the greater the force exerted by the ripples, the higher the splash will be. By determining the force exerted by the ripples at each point on the water surface (generally referring to points within the radius of the water surface disturbance), the ripple height at each point can be determined according to a pre-defined relationship (function) between the force and the height, thus creating a ripple height diagram.
[0050] S204: Based on the water ripple height map, perform water ripple propagation calculations on the pre-acquired water ripple texture to obtain a water ripple image.
[0051] A water ripple texture is a texture containing water ripples, which can be pre-saved or obtained from the internet. After determining the water ripple height map, a water ripple propagation algorithm can be used to determine the height of the water ripple at each point in the water ripple texture, based on the water ripple height map, thus obtaining the water ripple image.
[0052] As can be seen, the water ripple processing method provided in Example 1 above pre-marks the force-generating bones of the virtual object and determines the water ripple force at each point on the water surface based on the distance between the force-generating bones and each point on the water surface. This method can more realistically reflect the ripple effect on the water surface when the virtual object (character) moves in the water. This is because water ripples are generated by the movement of force-generating nodes (such as limbs), and the magnitude of the water ripple force at any point on the water surface is related to the distance between that point and the limb. Therefore, determining the magnitude of the water ripple force by the distance between the force-generating bones and each point on the water surface can more accurately and realistically simulate the water ripple effect.
[0053] See Figure 4 The diagram shows a flowchart of an example two of the water ripple processing methods provided in this application. Figure 3 Compared to Example 1, the water ripple processing method described in Example 2 adds a step of perturbing the intensity of the water ripple force (S403), a step of adjusting the intensity of the force according to the movement speed (S404), a step of controlling the attenuation of the water ripples (S406), and a step of rendering the water ripple image (S408). It can be understood that, for simplicity, these preferred steps are described all at once in Example 2. In fact, adding any one or more of the above steps to Example 1 is feasible and has corresponding technical effects.
[0054] The following section focuses on explaining the newly added steps; for other steps, please refer to the relevant description in Example 1.
[0055] S401: Obtain information about virtual objects in the current virtual scene. The information about virtual objects includes a skeletal model. The skeletal model is pre-marked with force-generating bones, which are the bones in the skeletal model that can generate force on the water surface.
[0056] S402: Determine the force exerted by the force-generating skeleton on the water surface at each point based on the distance between the force-generating skeleton and each point on the water surface.
[0057] S403: Determine whether the force-generating bone is in contact with the water surface. If so, take the contact point as the center point of the ring force; use the center point of the ring force to determine the intensity of the disturbance water ripple force.
[0058] To make the water ripples appear more realistic, closely resembling the subtle ripples created when a person enters the water, without increasing performance consumption, this embodiment uses an unrealistic "ring-shaped force" instead of the original circular force. This achieves a subtle ripple effect within an acceptable heightmap resolution. Adding this unrealistic "ring-shaped force" makes the effect more realistic while maintaining low performance consumption.
[0059] The specific calculation process for the intensity of the disturbance water ripple force at the center point of the aforementioned annular force is as follows:
[0060] The intensity F of the water ripple force is calculated as follows:
[0061] F = saturate(abs(Distance(P,C)-r) / W)...............Formula (5)
[0062] in,
[0063] P is the coordinate of any point on the water surface;
[0064] C is the coordinate of the contact point;
[0065] r is the pre-set radius of influence of the force-generating bone;
[0066] W is the width of the ring of the circumferential force;
[0067] Distance(P, C) is the distance function between point P and point C;
[0068] abs() is a function that calculates the absolute value;
[0069] saturate() is a normalization function. The function of saturate(x) is to return 0 if x is less than 0, 1 if x is greater than 1, and x is between 0 and 1.
[0070] S404: Adjust the intensity of the water ripple force according to the movement speed of the exerting bones.
[0071] It is understandable that the faster the movement speed of the exerting skeletal member, the greater the intensity of the water ripple force; conversely, the slower the movement speed of the exerting skeletal member, the smaller the intensity of the water ripple force. Therefore, the intensity of the water ripple force can be adjusted by controlling the movement speed of the exerting skeletal member.
[0072] The coordinates of the force-generating bones in each frame can be pre-recorded. The movement speed of the force-generating bones is determined by the positional difference between the pixels of the force-generating bones in the previous and current frames. Then, the intensity of the water ripple force is adjusted based on the movement speed of the force-generating bones. Specifically, the trend of the force-generating bone's movement speed can be judged; if the trend is an increasing speed, the intensity of the water ripple force is increased; if the trend is a decreasing speed, the intensity of the water ripple force is decreased. The specific method of adjusting the water ripple force is not limited; it can be done by constructing an adjustment function or by setting an adjustment range, etc.
[0073] S405: Determine the water ripple height diagram based on the force of the water ripples.
[0074] In determining the water ripple height map based on the force exerted by the water ripples, the water ripple height map can be calculated based on the influence of the annular force on the water ripples. Specifically, for example, for the current pixel, the difference in height between surrounding pixels is calculated; based on the difference in pixel height and the intensity of the water ripple force, for example, by multiplying the average of the pixel height differences by the intensity of the water ripple force, the current pixel value in the water ripple height map is calculated.
[0075] S406: Controls the attenuation of water ripples based on a pre-set distance influence factor.
[0076] In this embodiment, to achieve a more realistic water ripple effect, the attenuation of the water ripples can be controlled. Ripples that are too far from the dynamic object (character) will attenuate more rapidly. This is because if a large attenuation is used directly, the propagation distance of the ripples when stationary is too short, resulting in an unattractive appearance; if a small attenuation is used, the trails left when the character moves are too long and somewhat distorted. Therefore, a non-realistic attenuation method is needed to create a more realistic visual effect.
[0077] This application introduces a distance influence factor to accelerate the attenuation of ripples that are farther away. Specifically, the distance of each ripple on the water surface from the virtual object is determined; based on the distance influence factor, the attenuation of ripples closer to the virtual object is slowed down, while the attenuation of ripples farther away from the virtual object is accelerated. For example, accelerated attenuation can be achieved using the linear interpolation function Lerp(WaveIntensity,0,DistanceToCenter) in a common ripple transmission algorithm, which can achieve good results. For example, the value of k in the linear interpolation function Y=kx+b is this response factor.
[0078] S407: Based on the water ripple height map, perform water ripple propagation calculations on the pre-acquired water ripple texture to obtain a water ripple image.
[0079] S408: Calculate the water ripple normal map based on the water ripple height map, and render the water ripples based on the water ripple normal map.
[0080] Specifically, for example, let the current pixel be P, the pixel above it be P1, and starting from P1, take the four directly adjacent pixels clockwise as P1 (top), P2 (right), P3 (bottom), and P4 (left).
[0081] Pick:
[0082] XAxis = P2 - P4
[0083] YAxis = P3 - P1
[0084] If we take the positive direction of UV as the direction of XYAxis, and then calculate the cross product of XAxis and YAxis, we get the normal vector. The normal vector points upwards.
[0085] As can be seen, the water ripple processing method provided in Example 2 above has more technical effects than that in Example 1. For example, by adding a ring-shaped force perturbation to the intensity of the water ripple force, the water ripples can look more like the fine ripples produced when a person enters the water. Furthermore, by adjusting the force intensity according to the movement speed, the faster the movement of the exerting skeleton, the greater the intensity of the water ripple force, thus more realistically simulating real-world scenes. Also, by adding a distance-based influence factor to control the attenuation of the water ripples, the attenuation of water ripples farther from the virtual object can be accelerated, resulting in a more realistic appearance. Finally, by determining the texture based on the height map and then rendering the water ripple image, a realistic rendering effect is achieved because the height map better reflects the form of real water ripples.
[0086] See Figure 5This diagram illustrates the structure of a water ripple processing device provided in an embodiment of this application. The water ripple processing device includes: an acquisition unit 501, used to acquire virtual object information in the current virtual scene, the virtual object information including a skeletal model, the skeletal model having pre-marked force-generating bones, the force-generating bones being bones in the skeletal model capable of generating force on the water surface; a force determination unit 502, used to determine the water ripple force exerted by the force-generating bones on various points on the water surface based on the distance between the force-generating bones and each point on the water surface; a height map determination unit 503, used to determine a water ripple height map based on the water ripple force; and a water ripple image determination unit 504, used to perform water ripple propagation calculations on a pre-acquired water ripple texture based on the water ripple height map to obtain a water ripple image.
[0087] In one implementation, the force determination unit 502 is used to: calculate the projected distance between any point on the water surface and the force-generating skeleton based on the start end node and end end node of the force-generating skeleton; wherein the force-generating skeleton of the virtual object is a force-generating skeleton, and the start end node and end end node are marked on the force-generating skeleton; and determine that the water ripple force exerted by the force-generating skeleton on any point is inversely proportional to the projected distance.
[0088] In one implementation, the force determination unit 502 is used to: determine the projection distance as: P-Dot(D0, D1)*D1, where P is the coordinate of any point on the water surface, D0 is the distance from point P to the end node of the force-generating bone, D1 is the distance between the end node and the starting node of the force-generating bone, and Dot() is the dot product function.
[0089] In one implementation, the force determination unit 502 is used to: obtain pre-set water surface interaction attributes and initial values for the virtual object, the water surface interaction attributes including water surface disturbance radius and water surface interaction force; determine the water surface disturbance range based on the initial value of the water surface disturbance radius; calculate the distance between each point on the water surface within the water surface disturbance range and the force-generating skeleton; and determine the water ripple force exerted by the force-generating skeleton on each point on the water surface based on the initial value of the water surface interaction force and the distance.
[0090] In one implementation, it further includes: a ring-shaped force disturbance unit 505, used to determine whether the force-generating skeleton is in contact with the water surface; if so, the contact point is taken as the center point of the ring-shaped force; and, using the center point of the ring-shaped force, to disturb the intensity of the water ripple force.
[0091] In one implementation, the annular force disturbance unit 505 is used to calculate the intensity F of the water ripple force as: F = saturate(abs(Distance(P,C)-r) / W), where P is the coordinate of any point on the water surface, C is the coordinate of the contact point, r is the influence radius set in advance for the force-generating skeleton, W is the width of the annular force ring, Distance(P,C) is the distance function between point P and point C, abs() is the function for calculating the absolute value, and saturate() is the activation function.
[0092] In one implementation, it further includes a water ripple attenuation control unit 506, used to control the attenuation of water ripples according to a preset distance influence factor.
[0093] In one implementation, the water ripple attenuation control unit 506 is used to: determine the distance of each water ripple on the water surface from the virtual object; and, based on the distance influence factor, control the water ripples closer to the virtual object to slow down their attenuation, and control the water ripples farther from the virtual object to accelerate their attenuation.
[0094] In one implementation, the system further includes: a force intensity adjustment unit 507, configured to determine the movement speed of the force-generating bone based on the positional difference of the force-generating bone pixels between the recorded previous image frame and the current image frame; and to adjust the intensity of the water ripple force based on the movement speed of the force-generating bone.
[0095] In one implementation, the force intensity adjustment unit 507 is used to: determine the trend of the movement speed of the force-generating bone; if the trend is that the speed is increasing, then increase the intensity of the water ripple force; if the trend is that the speed is decreasing, then decrease the intensity of the water ripple force.
[0096] In one implementation, the system further includes a rendering unit 508, configured to calculate a water ripple normal map based on the water ripple height map, and to render the water ripples based on the water ripple normal map.
[0097] Embodiments of this application also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0098] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0099] (1) Obtain information about virtual objects in the current virtual scene. The information about virtual objects includes a skeleton model. The skeleton model is pre-marked with force-generating bones. The force-generating bones are the bones in the skeleton model that can generate force on the water surface.
[0100] (2) Determine the water ripple force exerted by the force-generating skeleton on each point on the water surface based on the distance between the force-generating skeleton and each point on the water surface;
[0101] (3) Determine the water ripple height diagram based on the water ripple force;
[0102] (4) Based on the water ripple height map, perform water ripple propagation calculation on the pre-acquired water ripple texture to obtain a water ripple image.
[0103] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0104] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0105] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0106] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0107] (1) Obtain information about virtual objects in the current virtual scene. The information about virtual objects includes a skeleton model. The skeleton model is pre-marked with force-generating bones. The force-generating bones are the bones in the skeleton model that can generate force on the water surface.
[0108] (2) Determine the water ripple force exerted by the force-generating skeleton on each point on the water surface based on the distance between the force-generating skeleton and each point on the water surface;
[0109] (3) Determine the water ripple height diagram based on the water ripple force;
[0110] (4) Based on the water ripple height map, perform water ripple propagation calculation on the pre-acquired water ripple texture to obtain a water ripple image.
[0111] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0112] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0113] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0114] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0115] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0116] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0117] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0118] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for processing water ripples, characterized in that, include: Obtain information about virtual objects in the current virtual scene. The information about virtual objects includes a skeletal model. The skeletal model is pre-marked with force-generating bones, which are the bones in the skeletal model that can generate force on the water surface. Based on the distances between the force-generating skeleton and various points on the water surface, the ripple force exerted by the force-generating skeleton on each point on the water surface is determined, including: calculating the projected distance between any point on the water surface and the force-generating skeleton based on the start and end nodes of the force-generating skeleton, wherein the start and end nodes are marked on the force-generating skeleton; determining that the ripple force exerted by the force-generating skeleton on any point is inversely proportional to the projected distance; the projected distance is: Where P is the coordinate of any point on the water surface. Let P be the distance from point P to the end node of the force-generating bone. This refers to the distance between the distal and distal nodes of the skeletal structure that generates force. It is the dot product function; Determine the water ripple height diagram based on the water ripple force described above; Based on the water ripple height map, water ripple propagation calculations are performed on the pre-acquired water ripple texture to obtain a water ripple image.
2. The method according to claim 1, characterized in that, The determination of the water ripple force exerted by the force-generating skeleton on various points on the water surface based on the distance between the force-generating skeleton and each point on the water surface includes: Obtain the pre-defined water surface interaction attributes and initial values for the virtual object, wherein the water surface interaction attributes include the water surface disturbance radius and the water surface interaction force; The water surface disturbance range is determined based on the initial value of the water surface disturbance radius; For each point on the water surface within the water surface disturbance range, the distance between each point and the force-generating skeleton is calculated. Based on the initial value of the water surface interaction force and the distance, the water ripple force exerted by the force-generating skeleton on each point on the water surface is determined.
3. The method according to claim 1, characterized in that, Also includes: Determine whether the force-generating bone is in contact with the water surface. If so, take the contact point as the center point of the ring force. The intensity of the water ripple force is disturbed at the center point of the annular force.
4. The method according to claim 3, characterized in that, The intensity of the disturbance of the water ripple force at the center point of the annular force includes: The intensity F of the water ripple force is calculated as follows: , Where P is the coordinate of any point on the water surface, C is the coordinate of the contact point, r is the radius of influence pre-set for the force-generating skeleton, and W is the width of the circumferential force ring. Let P be the distance function between point P and point C. It is a function for finding the absolute value. This is the normalization function.
5. The method according to claim 4, characterized in that, The step of determining the water ripple height map based on the water ripple force includes: For the current pixel, calculate the height difference between the surrounding pixels; The current pixel value in the water ripple height map is calculated based on the difference in pixel height and the intensity of the water ripple force.
6. The method according to claim 1, characterized in that, Also includes: Determine the trend of the movement speed of the exerting bone. If the trend is that the speed is increasing, increase the intensity of the water ripple force. If the trend is that the speed is decreasing, decrease the intensity of the water ripple force.
7. The method according to claim 1, characterized in that, Also includes: The attenuation of water ripples is controlled based on a pre-set distance influence factor.
8. The method according to claim 7, characterized in that, The method of controlling the attenuation of water ripples according to a pre-set distance influence factor includes: Determine the distance between each water ripple on the water surface and the virtual object; Based on the distance influence factor, the water ripples closer to the virtual object are controlled to attenuate more slowly, while the water ripples farther from the virtual object are controlled to attenuate more quickly.
9. The method according to any one of claims 1-8, characterized in that, Following the determination of the water ripple height map, the following is also included: Calculate the water ripple normal map based on the water ripple height map; The water ripples are rendered based on the water ripple normal map.
10. A water ripple treatment device, characterized in that, include: The acquisition unit is used to acquire information about virtual objects in the current virtual scene. The information about virtual objects includes a skeletal model. The skeletal model is pre-marked with force-generating bones, which are bones in the skeletal model that can generate force on the water surface. The force determination unit is used to determine the ripple force exerted by the force-generating skeleton on various points on the water surface based on the distances between the force-generating skeleton and these points. This includes: calculating the projected distance between any point on the water surface and the force-generating skeleton based on the start and end nodes of the force-generating skeleton, wherein the start and end nodes are marked on the force-generating skeleton; and determining that the ripple force exerted by the force-generating skeleton on any point is inversely proportional to the projected distance; the projected distance is: Where P is the coordinate of any point on the water surface. Let P be the distance from point P to the end node of the force-generating bone. This refers to the distance between the distal and distal nodes of the skeletal structure that generates force. It is the dot product function; The height map determination unit is used to determine the water ripple height map based on the water ripple force. The water ripple image determination unit is used to perform water ripple propagation calculation on the pre-acquired water ripple texture based on the water ripple height map to obtain a water ripple image.
11. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method described in any one of claims 1 to 9 when it is run.
12. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Real-time water wave texture processing method based on 2D (Two-dimensional) grid
CN102592297A
Self-adaptive adjustment method and device for virtual skeleton model, and electronic device
CN111161427A
