Water drop sliding effect generation method and device, electronic equipment and storage medium

By dividing the cells that divide the texture coordinate space in the game rendering and control the water drop sliding path, combined with the sampling and rendering of the material light information, the problem of complexity and low performance of the water droplets in the existing technology has achieved efficient, stylish, and stylized The drop effect of water drops.

CN119379883APending Publication Date: 2025-01-28NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411515867.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

When generating the water droplet slip effect, the physical simulation method is complex in computing and performance overhead, making it difficult to apply in real-time rendering, and the texture mapping method causes repetition and limitations in the effects.

Method used

By dividing the texture coordinate space of the water droplet attached object into several cells, control the sliding path of the water droplet according to the texture coordinates of each cell, and the preliminary effect of rendering through the lighting information of the sampling material to obtain the final water droplet drop effect.

Benefits of technology

In the case of low computing quantity and low performance expenses, the generation of water drops is achieved, and through the sampling and rendering of material light information, the effect has stylization and artistic expression.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119379883A_ABST
    Figure CN119379883A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a water drop sliding effect generation method and device, electronic equipment and a storage medium, and the method comprises the steps: dividing a texture coordinate space of a water drop attachment object, and obtaining a plurality of cells; according to the texture coordinate of each cell, controlling a water drop sliding path of water drops on the corresponding cell to obtain a preliminary water drop sliding effect; and sampling the material illumination information of the current pixel according to the texture coordinate of each water drop, and rendering the initial water drop sliding effect according to the material illumination information to obtain the final water drop sliding effect. According to the method, a water drop sliding path of a water drop on an attached object is flexibly controlled by utilizing a texture coordinate space, the water drop sliding effect is generated under the conditions of low calculation amount and low performance overhead, and through sampling and rendering of material illumination information, the efficient rendering performance is kept, and meanwhile the water drop sliding effect is achieved. The generated water drop sliding effect has a stylized effect, and then the water drop effect rich in artistic expressive force is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of game rendering technology, and in particular to a method for generating a water droplet sliding down effect, a device for generating a water droplet sliding down effect, a corresponding electronic device, and a corresponding computer-readable storage medium. Background Art

[0002] In rainy weather in stylized games, in order to enhance user experience and visual performance, natural phenomena such as the effect of falling water drops can usually be simulated on the screen of the game terminal. Especially in applications such as video games, animated films, and virtual reality, the realistic effect of falling water drops can significantly enhance the immersion and authenticity of the game screen.

[0003] However, in the related technologies for generating the effect of falling water drops, the focus is mainly on physical simulation. The aforementioned physical simulation method is computationally complex and has high performance overhead, and is difficult to apply in real-time rendering. Summary of the invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide a method for generating a water droplet sliding down effect, a device for generating a water droplet sliding down effect, a corresponding electronic device, and a corresponding computer-readable storage medium that overcome the above problems or at least partially solve the above problems.

[0005] The embodiment of the present invention discloses a method for generating a water drop sliding down effect, the method comprising:

[0006] Divide the texture coordinate space of the object to which the water droplet is attached to obtain a number of cells;

[0007] According to the texture coordinates of each cell, the water droplet sliding path of the water droplet on the corresponding cell is controlled to obtain a preliminary water droplet sliding effect;

[0008] The material illumination information of the current pixel is sampled according to the texture coordinates of each water drop, and the preliminary water drop sliding effect is rendered according to the material illumination information to obtain the final water drop sliding effect.

[0009] The embodiment of the present invention further discloses a device for generating a water drop sliding down effect, the device comprising:

[0010] A cell division module is used to divide the texture coordinate space of the object to which the water droplet is attached into a plurality of cells;

[0011] A sliding path control module, used to control the sliding path of the water drop on the corresponding cell according to the texture coordinates of each cell, so as to obtain a preliminary water drop sliding effect;

[0012] The water drop falling effect generation module is used to sample the material illumination information of the current pixel according to the texture coordinates of each water drop, render the preliminary water drop falling effect according to the material illumination information, and obtain the final water drop falling effect.

[0013] An embodiment of the present invention further discloses an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, any one of the methods for generating a water droplet sliding down effect is implemented.

[0014] The embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any one of the methods for generating a water droplet sliding down effect is implemented.

[0015] The embodiments of the present invention include the following advantages:

[0016] In an embodiment of the present invention, the texture coordinate space of the object to which the water drop is attached is divided to obtain a plurality of cells, and then the water droplet sliding path of the water droplet on the corresponding cell is controlled according to the texture coordinates of each cell to obtain a preliminary water droplet sliding effect, and then the material illumination information of the current pixel is sampled according to the texture coordinates of each water droplet, and the preliminary water droplet sliding effect generated above is rendered according to the sampled material illumination information to obtain the final water droplet sliding effect. By using the texture coordinate space to flexibly control the water droplet sliding path on the object to which the water droplet is attached, the generation of the water droplet sliding effect is achieved with low computational complexity and low performance overhead, and by sampling and rendering the material illumination information, the generated water droplet sliding effect has a stylized effect while maintaining efficient rendering performance, thereby achieving a water drop effect with artistic expression. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a flow chart of steps of an embodiment of a method for generating a water drop sliding down effect of the present invention;

[0018] Figure 2 is a flowchart of another embodiment of a method for generating a water drop sliding effect according to the present invention;

[0019] Figure 3 This is a schematic diagram of generating identification of random values ​​provided by an embodiment of the present invention;

[0020] FIG. 4A to FIG. 4E is a schematic diagram of a process for generating a water drop sliding effect provided by an embodiment of the present invention;

[0021] Figure 5 It is a structural block diagram of an embodiment of a device for generating a water drop sliding down effect of the present invention. DETAILED DESCRIPTION

[0022] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0023] To facilitate those skilled in the art to understand the present invention, the following explains the terms or nouns involved in the following embodiments of the present invention:

[0024] Shader: Shader, which can be mainly used to write material effects and achieve special effects.

[0025] UV Coordinates: UV Coordinates is a coordinate system used for texture mapping, which can associate a two-dimensional texture image with a three-dimensional model surface. UV coordinates are usually represented by (U, V), where U and V correspond to the horizontal and vertical axes of the texture image, respectively.

[0026] Matcap texture: Material Capture texture is a technology used for real-time rendering, usually used to simulate complex lighting effects without the need for complex lighting calculations. Matcap texture is essentially a spherical mapping texture that can contain pre-calculated lighting information and can be directly applied to the surface of an object, thereby quickly achieving realistic lighting effects.

[0027] In applications such as video games, animated films, and virtual reality, realistic water droplet sliding effects can significantly enhance the immersion and realism of the game screen.

[0028] Among the related technologies for generating the effect of water droplets sliding down, as an example, it can be realized through physical simulation technology. In the physical simulation method, it is manifested as generating a realistic water droplet sliding down effect by simulating the physical properties of water droplets, such as gravity, wind force, surface tension, etc. The simulation of physical properties usually relies on complex physical calculations and particle systems, and can be applied to scenes requiring high-precision visual effects, such as movie special effects and high-end games. However, the aforementioned physical simulation method has high computational complexity and high performance overhead, and is difficult to apply in real-time rendering; as another example, the water droplet sliding down effect can be realized through texture mapping technology, which can be manifested as using pre-generated water droplet animations or static textures, and is realized by texture mapping. The texture mapping method usually relies on UV mapping to apply the water droplet texture to the screen or 3D model surface, and can be applied to real-time rendering scenes with high performance requirements, such as mobile games and real-time applications. However, due to the use of static textures for texture mapping, the generated water droplet sliding down effect will have a high degree of repetition and great limitations, making it difficult to achieve a vivid effect of water droplet sliding. In summary, the related technologies for generating the water droplet sliding effect are difficult to ensure the vividness and stylization of the screen water droplet sliding effect used in the game with low performance overhead.

[0029] In the embodiment of the present invention, the falling path of water droplets on the corresponding cells is controlled according to the texture coordinates of each cell, that is, the falling path of water droplets on the objects to which they are attached is flexibly controlled by utilizing the texture coordinate space to generate a water drop falling effect. This generation method does not require complex physical calculations and can save performance overhead. Moreover, in the aforementioned water drop falling effect generation method utilizing the texture coordinate space, random water drop falling can be achieved by randomly controlling the falling trajectory of water droplets on the corresponding cells, thereby avoiding the repetitive feeling of water drop falling in a method based solely on texture mapping. Furthermore, based on the sampling and rendering of material lighting information, a stylized effect of water drop falling can be further achieved.

[0030] Reference Figure 1 , shows a flow chart of steps of an embodiment of a method for generating a water drop sliding effect of the present invention, which may specifically include the following steps:

[0031] Step S101, dividing the texture coordinate space of the object to which the water droplet is attached to obtain a plurality of cells;

[0032] In order to achieve random control of the water droplets sliding down when generating the water droplet sliding down effect and to achieve a more sophisticated water droplet sliding down effect, in an embodiment of the present invention, it can be achieved based on random control of each water droplet on each attachment area.

[0033] The water droplet attachment area refers to the various areas divided on the surface of the water droplet attachment object. For example, in a scene where a water droplet sliding down effect is produced on the screen, the water droplet attachment object may refer to the terminal screen, and the embodiment of the present invention does not limit this.

[0034] In one embodiment of the present invention, the area division of the surface of the water droplet attachment object can be reflected as the division of the texture coordinate space of the water droplet attachment object. Specifically, the texture coordinate space of the water droplet attachment object can be divided to obtain a plurality of cells, wherein each cell corresponds to each area divided on the surface of the water droplet attachment object.

[0035] Optionally, the above division can be achieved through gridding or simple texture coordinate mapping. When dividing the cells, the texture space of the object to which the water droplets are attached can be divided uniformly or randomly. Uniform division refers to dividing the aforementioned texture coordinate space uniformly into a number of cells of the same size, each cell has the same size and a fixed position; random division refers to dividing the aforementioned texture coordinate space into a number of cells with randomly distributed sizes and positions, each cell has a random size and position. This is not limited by the embodiments of the present invention.

[0036] Step S102, according to the texture coordinates of each cell, controlling the water droplet sliding path on the corresponding cell to obtain a preliminary water droplet sliding effect;

[0037] The random control of the water droplet sliding down is reflected in the random control of the water droplet sliding down path. The embodiment of the present invention can use the texture coordinate space to flexibly control the water droplet sliding down path on the object to which it is attached, so as to randomly control the water droplet sliding down trajectory on the corresponding cell, thereby realizing random water droplet sliding down and avoiding the repetitive feeling of water droplet sliding down in the method based solely on texture mapping.

[0038] Specifically, the water droplet sliding path of the water droplet on the corresponding cell can be randomly controlled according to the texture coordinates of each cell to obtain a preliminary water droplet sliding effect.

[0039] The water droplet sliding path, i.e., the path that the water droplet slides on the surface of the attached object, can be based on the center position of the water droplet. The water droplet usually slides down along the normal direction of the attached object surface, and the water droplet sliding path can be specifically calculated based on the normal direction and the center position of the water droplet.

[0040] In one embodiment of the present invention, the random adjustment of the water droplet sliding path can be achieved by modifying the water droplet center position of each cell. Exemplarily, the modification process of the water droplet center position can include an offset process and / or a sliding control process of the water droplet center position.

[0041] As an example, in order to avoid the phenomenon that water drops are arranged too neatly in the center of the cell, the center position of the water droplets on the corresponding cell can be offset according to the texture coordinates of each cell. The offset is a random offset, and the random offset amounts for water droplets on different cells can be the same or different, which is not limited by the embodiments of the present invention. As another example, in order to avoid the repetitive feeling of water droplets sliding down, the center position of the water droplets on the corresponding cell during the sliding process can be controlled according to the texture coordinates of each cell to obtain a preliminary water drop sliding effect, wherein the control of the center position of the water droplets during the sliding process may involve random control of the sliding speed, the frequency of change of the center position of the water droplets, etc., which is not limited by the embodiments of the present invention.

[0042] It should be noted that in order to ensure the randomness of water drop control on each cell, the above-mentioned offset processing of the center position of the water drop and the sliding control processing of the center position of the water drop can usually be combined in the process of generating the water drop sliding effect. This is not limited by the embodiments of the present invention.

[0043] Step S103, sampling the material illumination information of the current pixel according to the texture coordinates of each water drop, rendering a preliminary water drop sliding effect according to the material illumination information, and obtaining a final water drop sliding effect.

[0044] In a preferred embodiment of the present invention, the stylized effect of water drops falling can be further achieved based on the sampling and rendering of material illumination information. Specifically, by sampling and rendering material illumination information, the generated water drop falling effect can have a stylized effect while maintaining efficient rendering performance, thereby achieving a water drop effect with artistic expression.

[0045] Optionally, first, the material lighting information of the current pixel can be sampled according to the texture coordinates of each water drop, and then the preliminary water drop falling effect can be rendered according to the material lighting information obtained by the aforementioned sampling, so as to obtain the final water drop falling effect, and the final water drop falling effect is a stylized water drop falling effect.

[0046] In an embodiment of the present invention, the texture coordinate space of the object to which the water drop is attached is divided to obtain a plurality of cells, and then the water droplet sliding path of the water droplet on the corresponding cell is controlled according to the texture coordinates of each cell to obtain a preliminary water droplet sliding effect, and then the material illumination information of the current pixel is sampled according to the texture coordinates of each water droplet, and the preliminary water droplet sliding effect generated above is rendered according to the sampled material illumination information to obtain the final water droplet sliding effect. By using the texture coordinate space to flexibly control the water droplet sliding path on the object to which the water droplet is attached, the generation of the water droplet sliding effect is achieved with low computational complexity and low performance overhead, and by sampling and rendering the material illumination information, the generated water droplet sliding effect has a stylized effect while maintaining efficient rendering performance, thereby achieving a water drop effect with artistic expression.

[0047] Reference Figure 2 , shows a flow chart of another method for generating a water drop falling effect according to an embodiment of the present invention, which may specifically include the following steps:

[0048] Step S201, dividing the texture coordinate space of the object to which the water droplet is attached to obtain a plurality of cells;

[0049] In order to achieve random control of the water droplets sliding down when generating the water droplet sliding down effect and to achieve a more sophisticated water droplet sliding down effect, in an embodiment of the present invention, it can be achieved based on random control of each water droplet on each attachment area.

[0050] The water droplet attachment area refers to the various areas divided on the surface of the water droplet attachment object. The area division of the water droplet attachment object surface can be reflected as the division of the texture coordinate space of the water droplet attachment object. Specifically, the texture coordinate space of the water droplet attachment object can be divided to obtain a number of cells, wherein each cell corresponds to each area divided on the surface of the water droplet attachment object, so as to randomly control each water drop on each cell, thereby achieving the randomness of the subsequent water drop sliding effect.

[0051] In the embodiment of the present invention, taking the scenario of generating a water drop sliding down effect on the screen as an example, the object to which the water drop is attached may refer to the terminal screen.

[0052] Step S202, offsetting the center position of the water drop on the corresponding cell according to the texture coordinates of each cell;

[0053] The random control of the water droplet sliding down is reflected in the random control of the water droplet sliding down path. In the embodiment of the present invention, the water droplet sliding down path of the water droplet on the corresponding cell can be randomly controlled according to the texture coordinates of each cell to obtain a preliminary water droplet sliding down effect.

[0054] The water droplet sliding path, i.e., the path that the water droplet slides on the surface of the attached object, can be based on the center position of the water droplet. The water droplet usually slides down along the normal direction of the attached object surface, and the water droplet sliding path can be specifically calculated based on the normal direction and the center position of the water droplet.

[0055] Specifically, the random adjustment of the water droplet sliding path can be achieved by modifying the center position of the water droplet on each cell.

[0056] Optionally, the modification process of the center position of the water droplet may include an offset process of the center position of the water droplet.

[0057] In an embodiment of the present invention, in order to avoid the phenomenon that the water drops are arranged too neatly in the center of the cell, the center position of the water drops on the corresponding cell may be offset according to the texture coordinates of each cell.

[0058] Among them, the offset performed is a random offset, and the random offset can be achieved by calculating the random value of each cell based on the texture coordinates of each cell. The random value obtained by the above calculation can be used to add a random offset, which can be specifically manifested as using the above random value to offset the center position of the water droplets on each cell, thereby achieving a random offset of the water droplets on each cell, thereby avoiding the phenomenon that the water droplets are arranged too neatly in the center of the cell.

[0059] In practical applications, in the process of offsetting the center position of a water drop, specifically the initial center position of a water drop on each cell is offset, and the initial center position of a water drop on each cell can be defaulted to the exact center position of each cell.

[0060] In the embodiment of the present invention, the calculated random values ​​of each cell may be different, so as to ensure that the arrangement of the center position of the water droplets on each cell is random based on different random values. In order to ensure that the calculated random values ​​are different as much as possible, different fixed values ​​can be used as input values ​​of the preset random function.

[0061] Optionally, different fixed values ​​may refer to the cell identifier of each cell, that is, the cell identifier of each cell and a preset random function may be used, specifically, the cell representation of each cell, such as the ID value, is input as a parameter into a preset random function to obtain a random value of each cell.

[0062] In order to ensure that the cell identifications are different, the cell identifications of each cell can be calculated by using the texture coordinates of each unit grid. For example, the cell identifications of each cell, i.e., ID values, can be obtained by rounding down the texture coordinates of each unit grid using a floor function; then the ID values ​​calculated above can be used as parameter inputs of a preset random function, and then a random value can be output.

[0063] After the ID value is input into the preset random function, various calculations may be involved. The specific pseudo code implementation can be as follows:

[0064] float2 id = floor(uv); / / Round down the texture coordinate uv of each cell to get an integer value id as the cell identifier of each cell;

[0065] id = frac(id*float2(21.64,15.45)); / / Convert the integer id into a pseudo-random value through multiplication and fractional operation to provide more random input for subsequent randomization operations;

[0066] id+=dot(id,id+4.397); / / Through dot product and addition operations, further randomize the integer id to make it more random;

[0067] float random_value = frac(id.x*id.y); / / Generate a random value uniformly distributed in the range [0,1) through multiplication and fractional operation

[0068] Among them, the cell identifiers output by the above pseudo code are different. When calculating the random value of each cell, different cell identifiers, that is, integer ids, can be passed into the preset random function shown in the above pseudo code; the random value output by the above pseudo code is a random number between 0 and 1. Specifically, Figure 3 Each grid shown can represent each cell, and the color presented on each cell can be a visual presentation of the random number, wherein the darker the color, the smaller the random number, for example, when the color is pure black, it indicates that the random number is 0; the brighter the color, the larger the random number, for example, when the color is pure white, it indicates that the random number is 1, that is, the different shades of the color presented visually can represent different random numbers for each cell.

[0069] After obtaining the random value of each cell, the center position of the water drop on the corresponding cell can be randomly offset according to the random value of the corresponding cell, which can be specifically expressed as offsetting the position of the water drop on the corresponding cell in the horizontal axis direction to avoid the water drop being in the center of the cell. Optionally, the position of the water drop in the vertical axis direction can also be offset according to actual needs, and the embodiment of the present invention is not limited to this.

[0070] In a preferred embodiment of the present invention, after determining the center position of the water drop in each cell, the shape of the water drop can be formed at this time because the water drop is not a simple point.

[0071] Specifically, the distance from the current pixel to the center of the water drop can be calculated on the corresponding cell. If the distance is less than the preset water drop size, the current pixel can be determined to be a target pixel for forming a water drop shape, and finally at least one target pixel is used to form a water drop shape at the center of the water drop. The preset water drop size can be a water drop size randomly obtained by a random value.

[0072] In practical applications, the generation of a water drop shape can be achieved by clamping the texture coordinates of the current pixel using a smoothstep function. Optionally, the smoothstep function can be used to generate a smooth transition from 0 to 1. In this case, the distance from each point on the two-dimensional plane to the center of the water drop can be used as a parameter and passed into the smoothstep function, so that the part close to the center of the water drop on the two-dimensional plane is clamped to 1, and the part away from the center of the water drop is clamped to 0; then, in an embodiment of the present invention, the aforementioned part clamped to 1 can be regarded as the water drop range, the part clamped to 0 can be regarded as the non-water drop part, and the corresponding part clamped to a value between 0 and 1 can be understood as the range of transition from water drop to non-water drop. That is, the water drop shape can be generated according to the water drop range indicated by the part clamped to 1.

[0073] It should be noted that the formation / generation of the water drop shape can be formed at the center position of the water drop after the offset; or the water drop shape can be first formed at the initial center position of the water drop, that is, the center position of each cell, and then the center position of the water drop of the formed water drop shape is offset. This embodiment of the present invention is not limited to this.

[0074] Step S203, according to the texture coordinates of each cell, the center position of the water drop on the corresponding cell during the sliding process is controlled to obtain a preliminary water drop sliding effect;

[0075] Optionally, the modification process of the center position of the water droplet may also include a sliding control process performed on the center position of the water droplet.

[0076] In one embodiment of the present invention, in order to avoid the repetitive feeling of water drops sliding down, the center position of the water drops on the corresponding cells during the sliding process can be controlled according to the texture coordinates of each cell to obtain a preliminary water drop sliding down effect.

[0077] In practical applications, water droplet sliding control can be divided into two processes: the process of controlling the cell to move downward as the water droplet slides down, and the process of controlling the center position of the water droplet to move up and down periodically in the cell. It should be noted that there is no order of execution of the above two processes, that is, the above two processes are in a combined implementation relationship, wherein the former process is reflected as the effect of water droplets moving downward, and the latter process is reflected as the effect of water droplets moving up or down. Based on the combination of the above two processes, the initial water droplet sliding effect can be reflected as an effect similar to moving down quickly within a certain sliding time period, and staying in place within a certain sliding time period. This is not limited by the embodiments of the present invention.

[0078] Specifically, in order to achieve the effect of all water drops moving downward, the cells can be controlled to move downward as the water drops slide down.

[0079] Optionally, in the process of controlling the cells to move downward as the water droplets slide down, the random value of each cell calculated based on the texture coordinates of each cell can be obtained, and the water droplet sliding time of each cell can be calculated using the random value of each cell. Then, according to the preset moving speed, each cell is moved downward as the water droplet sliding time of each cell, and the center position of the water droplets on the corresponding cells during the sliding process is controlled to achieve the effect of all water droplets moving downward and obtain a preliminary water droplet sliding effect.

[0080] Among them, the random value of each cell is different, and the time of each cell calculated based on the random value is also different.

[0081] In order to achieve the effect of all water droplets moving downward while making the rhythm of each water droplet moving downward different, the center position of the water droplet can be controlled to move up and down periodically in the cell.

[0082] Optionally, in the process of controlling the center position of a water droplet to periodically move up and down in a cell, a random value of each cell calculated based on the texture coordinates of each cell can be obtained, and the water droplet sliding time of each cell can be calculated using the random value of each cell. Then, the water droplet sliding time and a preset mathematical function can be used to calculate the center position of the water droplet when the water droplet moves periodically on the corresponding cell within the water droplet sliding time, so as to periodically control the periodic movement of the water droplet according to the center position of the water droplet to obtain a preliminary water droplet sliding effect.

[0083] Among them, it is possible to fit by using a preset mathematical function with periodicity to achieve the effect of the water droplets sliding down faster and slower. Exemplarily, the preset mathematical function can be formed by nesting functions such as sin, and the sin function is characterized by slow entry and slow exit. The nested sin function can be used to achieve the effect of the water droplets sliding down faster and slower.

[0084] Exemplarily, the initial water droplet sliding effect generated based on the above process can be as follows: Figure 4A As shown, the pseudo code implementation of the entire preliminary water drop sliding effect can be as follows:

[0085] float n = random_value; / / random value;

[0086] t+=n*6.2831; / / The random value of each cell is different, and the calculation based on t+n makes the sliding time of each cell different;

[0087] / /

[0088] float w = input_uv.y*10; / / The texture coordinate uv of the screen is multiplied by 10 to get w, which is used as the parameter of the subsequent sliding trajectory in the x direction. The aforementioned multiplication by 10 is used to adjust the function frequency;

[0089] / /

[0090] float x=0.8*(n-0.5); / / Randomly adjust the x position of the center of the water drop in each cell;

[0091] x+=(0.4-abs(x))*sin(3*w)*pow(sin(w),6)*0.45; / / Function simulates sliding in the x direction

[0092] float y = -sin(t+sin(t+sin(t)*0.5))*0.45; / / Function simulates sliding in the y direction

[0093] col = float3 (gv.y, gv.y, 1); / / meaningless, used for debugging

[0094] dropPo5 = (gv-float2(x,y)) / aspect; / / Calculate the two-dimensional vector of gv from the current pixel to the center of the water drop, aspect is the screen aspect ratio;

[0095] float drop_size=lerp(DropSize.x,DropSize.y,random_value2); / / Randomly get a drop size drop_size through random values;

[0096] drop=smoothstep(drop_size+0.02,drop_size,length(dropPos));

[0097] / / Use the smoothstep function. If the distance from the current pixel to the center of the water drop is less than the size of the water drop, the part close to the center of the water drop is considered as the water drop range, that is, drop is 1; if the distance from the current pixel to the center of the water drop is greater than the size of the water drop, the part far from the center of the water drop is considered as the non-water drop range, that is, drop is 0;

[0098] / / The drop_size plus 8.02 is mainly to allow a slight transition between non-water drops and water drops.

[0099] Among them, the x and y values ​​represent the center position of the water droplet. The x value represents the center position of the water droplet in the horizontal axis direction, and the y value represents the center position of the water droplet in the vertical axis direction. In the implementation of the above pseudo code, the value obtained by the water droplet falling time t and the sin function can be used as the y value, that is, as the value of the center position of the water droplet in the vertical axis direction, so that the vertical position of the water droplet and the water droplet falling time t are associated.

[0100] In a preferred embodiment of the present invention, after the preliminary water drop sliding effect is generated, a trailing effect may be added to the preliminary water drop sliding effect to improve the authenticity of the water drop sliding on the terminal screen.

[0101] Specifically, a trailing effect control parameter can be set for the water droplets on each cell, and the water droplets on each cell can be controlled according to the trailing effect control parameter to add a trailing effect to the initial water droplet sliding effect on each cell. The trailing effect control parameter is used to indicate that the trailing effect of the water droplets is weakened from bottom to top along the longitudinal axis, thereby obtaining the following Figure 4B The trailing effect shown gradually decreases.

[0102] For example, the specific pseudo code implementation can be as follows:

[0103] float fogTrail = smoothstep(-0.05, 0.05, dropPos.y); / / No tail will appear under the water drop. This step makes the fogTrail value under the water drop 0;

[0104] fogTrail*=smoothstep(0.5,y,gv.y); / / The gradual weakening effect of the trailing is achieved through smoothstep. This step makes the value of fogTrail decrease from bottom to top along the vertical axis;

[0105] fogTrailfogTrail*=smoothstep(drop_size,drop_size-0.01,abs(dropPos.x));

[0106] / / Define the tail. Since the tail is long in the y direction, only the range that exceeds the water drop size in the x direction is not the tail. Based on dropPos.x, the horizontal axis range of the water drop is restricted, while the restriction in the vertical axis direction of the water drop is ignored, thus obtaining a vertical line along the path of the water drop.

[0107] Among them, fogTrail can refer to the trailing effect control parameter, and the value of this variable represents the trailing intensity.

[0108] In a preferred embodiment of the present invention, after the preliminary water drop sliding effect is generated, an interference effect may be added to the preliminary water drop sliding effect to enhance the vividness of the water drop sliding on the terminal screen.

[0109] Specifically, a preset noise map can be sampled, and the sampling result and the texture coordinates of each cell can be superimposed to add a disturbance effect to the initial water drop sliding effect of the water drop on each cell. For example, a noise map can be sampled, and the sampling result and the texture coordinates uv of the terminal screen can be superimposed to achieve the following: Figure 4C The overall disturbance effect on the terminal screen uv is shown.

[0110] Step S204, sampling the material illumination information of the current pixel using the texture coordinates of each water droplet;

[0111] In a preferred embodiment of the present invention, the stylized effect of water drops falling can be further achieved based on the sampling and rendering of material illumination information. Specifically, by sampling and rendering material illumination information, the generated water drop falling effect can have a stylized effect while maintaining efficient rendering performance, thereby achieving a water drop effect with artistic expression.

[0112] Optionally, first, the material lighting information of the current pixel can be sampled according to the texture coordinates of each water drop, and then the preliminary water drop falling effect can be rendered according to the material lighting information obtained by the aforementioned sampling, so as to obtain the final water drop falling effect, and the final water drop falling effect is a stylized water drop falling effect.

[0113] In one embodiment of the present invention, the center position of a water drop in a preliminary water drop sliding effect can be obtained, the texture coordinates of each water drop are calculated using the center position of the water drop, and then the texture coordinates of each water drop are used to sample the material lighting information of the current pixel.

[0114] Step S205, rendering a preliminary water drop sliding effect according to the material lighting information to obtain a final water drop sliding effect.

[0115] The sampled material lighting information may include texture color. In one embodiment of the present invention, the texture color may be used to adjust the rendering result of the preliminary water drop falling effect to obtain the final water drop falling effect.

[0116] Specifically, the texture coordinates uv of each water droplet (i.e., dropPos in the above pseudo code) can be sampled as follows: Figure 4D The matcap image shown in the figure is used to obtain the color on the matcap; the sampled color can be used to adjust the final water drop sliding effect, that is, the rendering result of the preliminary water drop sliding effect is adjusted by using the texture color to achieve the following: Figure 4E A stylized rendering of a water droplet shown sliding down.

[0117] For example, the specific pseudo code implementation can be as follows:

[0118] float4 local285=Matcap.Sample(local227,(local8+0.5));

[0119] / / Sampling to get the color of matcap, the texture coordinates uv of each water drop used for sampling can be obtained by dropPos+0.5 involved in the pseudo code above;

[0120] float local166=(local285.r*2.0);

[0121] 1ocal142=lerp(lerp(MatcapDarkcolor,MatcapMidcolor,saturate(local166)).MatcapBrightcolor,saturate((local166 -1.0));

[0122] / / Remap the color of matcap, for example, map black to MatcapDarkColor, gray to MatcapMidcolor, and white to MatcapBrightColor;

[0123] float4 local273=StageInput.Sample(local227,local16);

[0124] / / local273 is the screen color

[0125] ran data.Color

[0126] =lerp(loca1273.rgb,Ilerp(local273.rgb,Ierp(local273.rge,(local142).xyz,Ioca142.a),(lerp(iateapntensity Drep,Hateaprntensity static,...

[0127] / / lerp(local273.rgb,(local142).xyz,local142.a) This step uses the matcap remapped channel as the mixing intensity and mixes the matcap color and the screen color through the lerp function;

[0128] return raw_data;

[0129] / / Get the stylized rendering effect when the water droplets slide down.

[0130] In an embodiment of the present invention, the falling path of water droplets on corresponding cells is controlled according to the texture coordinates of each cell, that is, the falling path of water droplets on the objects to which they are attached is flexibly controlled by utilizing the texture coordinate space to generate a water drop falling effect. This generation method does not require complex physical calculations and can save performance overhead. Moreover, in the aforementioned water drop falling effect generation method utilizing the texture coordinate space, random water drop falling can be achieved by randomly controlling the falling trajectory of water droplets on corresponding cells, thereby avoiding the repetitive feeling of water drop falling in a method based solely on texture mapping. Furthermore, based on the sampling and rendering of material lighting information, a stylized effect of water drop falling can be further achieved.

[0131] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0132] Reference Figure 5 , shows a structural block diagram of an embodiment of a device for generating a water droplet sliding down effect of the present invention, which may specifically include the following modules:

[0133] A cell division module 501 is used to divide the texture coordinate space of the object to which the water droplet is attached into a plurality of cells;

[0134] The sliding path control module 502 is used to control the sliding path of the water drop on the corresponding cell according to the texture coordinates of each cell to obtain a preliminary water drop sliding effect;

[0135] The water drop falling effect generating module 503 is used to sample the material illumination information of the current pixel according to the texture coordinates of each water drop, render the preliminary water drop falling effect according to the material illumination information, and obtain the final water drop falling effect.

[0136] In an embodiment of the present invention, the water droplet sliding path is determined based on the center position of the water droplet; the sliding path control module 502 may include the following submodules:

[0137] The preliminary water droplet sliding effect generation submodule is used to offset the center position of the water droplet on the corresponding cell according to the texture coordinates of each cell; and / or, according to the texture coordinates of each cell, control the center position of the water droplet on the corresponding cell during the sliding process to obtain the preliminary water droplet sliding effect.

[0138] In one embodiment of the present invention, the preliminary water drop falling effect generation submodule may include the following units:

[0139] The water drop center position offset unit is used to calculate the random value of each cell according to the texture coordinates of each cell; and use the random value to offset the water drop center position of the water drop on each cell.

[0140] In one embodiment of the present invention, the water drop center position offset unit may include the following subunits:

[0141] The random value calculation subunit is used to calculate the cell identification of each cell using the texture coordinates of each unit cell; and to obtain the random value of each cell using the cell identification of each cell and a preset random function.

[0142] In an embodiment of the present invention, the sliding path control module 502 may further include the following submodules:

[0143] The water drop shape forming submodule is used to calculate the distance from the current pixel to the center position of the water drop on the corresponding cell; if the distance is less than the preset water drop size, the current pixel is determined to be a target pixel for forming the water drop shape; and at least one of the target pixels is used to form the water drop shape of the water drop at the center position of the water drop.

[0144] In one embodiment of the present invention, the preliminary water drop falling effect generation submodule may include the following units:

[0145] The cell downward movement unit is used to obtain the random value of each cell calculated based on the texture coordinates of each cell, and use the random value of each cell to calculate the water drop sliding time of each cell; according to the preset moving speed, each cell is moved downward along with the water drop sliding time of each cell, and the center position of the water drop on the corresponding cell during the sliding process is controlled to obtain a preliminary water drop sliding effect.

[0146] In one embodiment of the present invention, the preliminary water drop falling effect generation submodule may include the following units:

[0147] A water drop falling control unit is used to obtain random values ​​of each cell calculated based on the texture coordinates of each cell, and use the random values ​​of each cell to calculate the water drop falling time of each cell; use the water drop falling time and a preset mathematical function to calculate the center position of the water drop when the water drop performs periodic movement on the corresponding cell within the water drop falling time; periodically control the periodic movement of the water drop according to the center position of the water drop to obtain a preliminary water drop falling effect.

[0148] In one embodiment of the present invention, the preliminary water drop sliding effect generation submodule may further include the following units:

[0149] A trailing effect control unit is used to set trailing effect control parameters for the water drops on each cell, and control the water drops on each cell according to the trailing effect control parameters to add a trailing effect to the initial water drop sliding effect of the water drops on each cell; wherein the trailing effect control parameters are used to indicate that the trailing effect of the water drop weakens from bottom to top along the longitudinal axis.

[0150] In one embodiment of the present invention, the preliminary water drop sliding effect generation submodule may further include the following units:

[0151] The disturbance effect adding unit is used to sample the preset noise map, and to superimpose the sampling result with the texture coordinates of each cell, so as to add a disturbance effect to the preliminary water drop sliding effect of the water drop on each cell.

[0152] In one embodiment of the present invention, the water drop sliding effect generation module 503 may include the following submodules:

[0153] The water droplet falling effect adjustment submodule is used to obtain the center position of the water droplet in the preliminary water droplet falling effect, and use the water droplet center position to calculate the texture coordinates of each water droplet; use the texture coordinates of each water droplet to sample the material lighting information of the current pixel; the material lighting information includes texture color; use the texture color to adjust the rendering result of the preliminary water droplet falling effect to obtain the final water droplet falling effect.

[0154] In an embodiment of the present invention, the device for generating a water droplet sliding effect provided by the embodiment of the present invention obtains a plurality of cells by dividing the texture coordinate space of the object to which the water droplet is attached, and then controls the water droplet sliding path of the water droplet on the corresponding cell according to the texture coordinates of each cell to obtain a preliminary water droplet sliding effect, and then samples the material illumination information of the current pixel according to the texture coordinates of each water droplet, and renders the aforementioned preliminary water droplet sliding effect according to the sampled material illumination information to obtain the final water droplet sliding effect. By utilizing the texture coordinate space to flexibly control the water droplet sliding path on the object to which the water droplet is attached, the generation of the water droplet sliding effect is achieved with low computational complexity and low performance overhead, and by sampling and rendering the material illumination information, while maintaining efficient rendering performance, the generated water droplet sliding effect has a stylized effect, thereby achieving a water drop effect with artistic expression.

[0155] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0156] An embodiment of the present invention further provides an electronic device, including:

[0157] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned water drop sliding effect generation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0158] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned water droplet sliding effect generation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0159] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0160] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0161] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0162] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable terminal device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0164] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0165] Finally, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0166] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0167] The above is a detailed introduction to a method for generating a water droplet sliding down effect, a device for generating a water droplet sliding down effect, a corresponding electronic device and a corresponding computer-readable storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for a person skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for generating a water drop sliding effect, characterized in that: The method comprises: Divide the texture coordinate space of the object to which the water droplet is attached to obtain a number of cells; According to the texture coordinates of each cell, the water droplet sliding path of the water droplet on the corresponding cell is controlled to obtain a preliminary water droplet sliding effect; The material illumination information of the current pixel is sampled according to the texture coordinates of each water drop, and the preliminary water drop sliding effect is rendered according to the material illumination information to obtain the final water drop sliding effect.

2. The method according to claim 1, characterized in that The water drop sliding path is determined based on the center position of the water drop; the water drop sliding path of the water drop on the corresponding cell is controlled according to the texture coordinates of each cell to obtain a preliminary water drop sliding effect, including: According to the texture coordinates of each cell, the center position of the water droplet on the corresponding cell is offset; And / or, according to the texture coordinates of each cell, the center position of the water drop on the corresponding cell during the sliding process is controlled to obtain a preliminary water drop sliding effect.

3. The method according to claim 2, characterized in that The step of offsetting the center position of the water drop on the corresponding cell according to the texture coordinates of each cell includes: Calculating a random value of each cell according to the texture coordinates of each cell; The random value is used to offset the center position of the water drop on each cell.

4. The method according to claim 3, characterized in that The step of calculating the random value of each cell according to the texture coordinates of each cell includes: The texture coordinates of each unit cell are used to calculate the cell identification of each cell; The cell identifier of each cell and a preset random function are used to obtain a random value of each cell.

5. The method according to claim 2 or 3, characterized in that: The method further comprises: On the corresponding cell, calculate the distance from the current pixel to the center position of the water droplet; If the distance is smaller than a preset water drop size, determining that the current pixel is a target pixel for forming a water drop shape; At least one of the target pixels is used to form a water drop shape of the water drop at the center position of the water drop.

6. The method according to claim 2, characterized in that According to the texture coordinates of each cell, the center position of the water drop on the corresponding cell during the sliding process is controlled to obtain a preliminary water drop sliding effect, including: Obtaining a random value of each cell calculated based on the texture coordinates of each cell, and using the random value of each cell to calculate the water drop sliding time of each cell; According to the preset moving speed, each cell is moved downward as the water drop of each cell slides down, and the center position of the water drop on the corresponding cell during the sliding process is controlled to obtain a preliminary water drop sliding effect.

7. The method according to claim 2 or 6, characterized in that: The controlling of the center position of the water droplet on the corresponding cell during the sliding process to obtain a preliminary water droplet sliding effect includes: Obtaining a random value of each cell calculated based on the texture coordinates of each cell, and using the random value of each cell to calculate the water drop sliding time of each cell; Using the water droplet sliding time and a preset mathematical function, calculate the center position of the water droplet when the water droplet moves periodically on the corresponding cell within the water droplet sliding time; The periodic movement of the water drop is periodically controlled according to the center position of the water drop to obtain a preliminary water drop sliding effect.

8. The method according to claim 7, characterized in that The step of periodically controlling the periodic movement of the water drop according to the center position of the water drop to obtain a preliminary water drop sliding effect further includes: Setting a trailing effect control parameter for the water drop on each cell, and controlling the water drop on each cell according to the trailing effect control parameter, so as to add a trailing effect to the preliminary water drop sliding effect of the water drop on each cell; The trailing effect control parameter is used to indicate that the trailing effect of the water drop is weakened from bottom to top along the longitudinal axis.

9. The method according to claim 7, characterized in that: The method further comprises: The preset noise map is sampled, and the sampling result and the texture coordinates of each cell are superimposed to add a disturbance effect to the preliminary water drop sliding effect of the water drop on each cell.

10. The method according to claim 1, characterized in that The step of sampling the material illumination information of the current pixel according to the texture coordinates of each water drop, rendering the preliminary water drop sliding effect according to the material illumination information, and obtaining the final water drop sliding effect includes: Acquire the center position of the water drop in the preliminary water drop sliding effect, and calculate the texture coordinates of each water drop using the center position of the water drop; The texture coordinates of each water drop are used to sample the material illumination information of the current pixel; the material illumination information includes texture color; The rendering result of the preliminary water drop sliding effect is adjusted using the texture color to obtain the final water drop sliding effect.

11. A device for generating a water drop sliding effect, characterized in that: The device comprises: A cell division module is used to divide the texture coordinate space of the object to which the water droplet is attached into a plurality of cells; A sliding path control module, used to control the sliding path of the water drop on the corresponding cell according to the texture coordinates of each cell, so as to obtain a preliminary water drop sliding effect; The water drop falling effect generation module is used to sample the material illumination information of the current pixel according to the texture coordinates of each water drop, render the preliminary water drop falling effect according to the material illumination information, and obtain the final water drop falling effect.

12. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for generating a water drop sliding down effect as claimed in any one of claims 1 to 10 is implemented.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for generating a water droplet sliding down effect as claimed in any one of claims 1 to 10 is implemented.