A processing method, device, electronic device and readable medium for a grass model

By adjusting the normal vector and force vector of the vertex of the grass model, combining wind force influence factors and animations, the effect of the grass model sags and swings naturally in three-dimensional scenes is solved, and the problem of grass model difficulty in naturally sags in the existing technology is enhanced, and the authenticity of the three-dimensional scenes is enhanced.

CN114445534BActive Publication Date: 2025-07-25NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111670106.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-07-25
Estimated Expiration
2041-12-30

Smart Images

  • Figure CN114445534B_ABST
    Figure CN114445534B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a method, device, electronic device and readable medium for processing a grass model, including: determining a normal vector of each vertex in the grass model to be rendered; controlling the normal vector to offset in a first direction, where the first direction is the opposite direction of the gravity direction; determining a force vector based on the offset normal vector, where the force vector is used to simulate gravity; determining a target position to be offset for each vertex of the grass model according to the force vector and the current position of each vertex of the grass model; controlling each vertex of the grass model to move to the corresponding target position respectively to obtain a grassland under the influence of gravity. And it realizes the rapid adjustment of the grass model, so that the grass model can naturally show the drooping effect. And it is easy to adjust the grass model subsequently, and it is relatively easy to show the mixed effect of the gravity effect and other effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of three-dimensional models, and particularly to a method for processing grass models, a device for processing grass models, an electronic device, and a computer-readable medium. Background Art

[0002] In a game, in order to display a three-dimensional scene with rich details, grass models can be added to the three-dimensional scene. At the same time, in order to make the three-dimensional scene more natural, it is usually necessary to display the effect that the grass models droop naturally under the influence of gravity.

[0003] Generally speaking, to display the effect that the grass models droop naturally under the influence of gravity, a number of intersecting insert models can be set, and then a texture map with grass drooping naturally is set on the insert models, so as to achieve the effect of displaying the natural drooping of grass. However, for the grass models set by this method, when it is necessary to add other display effects such as swaying with the wind and being trampled on to the grass models subsequently, it will be difficult to naturally display other display effects. Summary of the Invention

[0004] Embodiments of the present invention provide a method for processing grass models, a device, an electronic device, and a computer-readable storage medium to solve the problem of how to display the natural drooping of grass models under the influence of gravity.

[0005] Embodiments of the present invention disclose a method for processing grass models, including:

[0006] Determine the normal vectors of the vertices of the grass model to be rendered;

[0007] Control the normal vectors to deviate in a first direction, where the first direction is the opposite direction of the gravity direction;

[0008] Based on the offset normal vectors, determine a force vector, where the force vector is used to simulate gravity;

[0009] According to the force vector and the current positions of the vertices of the grass model, determine the target positions where the vertices of the grass model are to be offset;

[0010] Control each vertex of the grass model to move to the corresponding target position respectively to obtain a grassland under the influence of gravity.

[0011] Optionally, the method further includes:

[0012] Obtain a wind influence factor, where the wind influence factor is used to simulate the intensity of wind;

[0013] According to the force vector and the current positions of the vertices of the grass model, determining the target positions where the vertices of the grass model are to be offset includes:

[0014] Determine the gravity influence weight according to the wind influence factor;

[0015] Determine the target position to be offset for each vertex of the grass model according to the force vector, the current positions of the vertices of the grass model, and the gravity influence weight.

[0016] Optionally, the method further includes:

[0017] Determine a first target sub-position according to a preset vertex animation, where the first target sub-position is the position where the grass model is to be moved under the influence of wind;

[0018] The step of determining the target position to be offset for each vertex of the grass model according to the force vector, the current positions of the vertices of the grass model, and the gravity influence weight includes:

[0019] Obtain a second target sub-position according to the force vector, the current positions of the vertices of the grass model, and the gravity influence weight, where the second target sub-position is the position where the grass model is to be moved under the influence of the force vector;

[0020] Obtain the target position to be offset for each vertex of the grass model according to the first target sub-position and the second target sub-position.

[0021] Optionally, the step of obtaining the target position to be offset for each vertex of the grass model according to the first target sub-position and the second target sub-position includes:

[0022] Perform an interpolation operation on the first target sub-position and the second target sub-position according to the gravity influence weight to obtain an interpolation result;

[0023] Use the interpolation result as the target position to be offset for each vertex of the grass model.

[0024] Optionally, the method further includes:

[0025] Set the gravity offset weight corresponding to the vertex based on the position of the vertex on the grass model; wherein, the gravity offset weight decreases sequentially from the top to the bottom of the grass model.

[0026] The step of determining the target position to be offset for each vertex of the grass model according to the force vector and the current positions of the vertices of the grass model includes:

[0027] Determine the target position to be offset for each vertex of the grass model according to the force vector, the gravity offset weight, and the current positions of the vertices of the grass model.

[0028] Optionally, the step of setting the gravity offset weight corresponding to the vertex based on the position of the vertex on the grass model includes:

[0029] Determining the gravity offset weight of the vertex based on the vertex color corresponding to the vertex; wherein, the vertex color gradually becomes lighter from the top to the bottom of the grass model.

[0030] An embodiment of the present invention provides a processing device for a grass model, including:

[0031] A normal vector determination module, configured to determine the normal vector of each vertex in the grass model to be rendered;

[0032] An offset module, configured to control the normal vector to offset in a first direction, and the first direction is the opposite direction of the gravity direction;

[0033] An acting force vector determination module, configured to determine an acting force vector based on the offset normal vector, and the acting force vector is used to simulate gravity;

[0034] A target position determination module, configured to determine the target position to be offset for each vertex of the grass model according to the acting force vector and the current position of each vertex of the grass model;

[0035] A movement module, configured to control each vertex of the grass model to move to the corresponding target position respectively, and obtain a grassland under the influence of gravity.

[0036] Optionally, the device further includes:

[0037] A factor acquisition module, configured to acquire a wind force influence factor, and the wind force influence factor is used to simulate the intensity of wind force;

[0038] The target position determination module includes:

[0039] An influence weight determination module, configured to determine a gravity influence weight according to the wind force influence factor;

[0040] A first target position determination sub-module, configured to determine the target position to be offset for each vertex of the grass model according to the acting force vector, the current position of each vertex of the grass model, and the gravity influence weight.

[0041] Optionally, the device further includes:

[0042] A first sub-position determination module, configured to determine a first target sub-position according to a preset vertex animation, and the first target sub-position is the position where the grass model is to move under the influence of wind force;

[0043] The target position determination module includes:

[0044] A second sub-module determining sub-module, configured to obtain a second target sub-position according to the acting force vector, the current positions of the vertices of the grass model, and the gravity influence weight, where the second target sub-position is the position where the grass model is to be moved under the influence of the acting force vector;

[0045] A second target position determining sub-module, configured to obtain the target position to be offset for each vertex of the grass model according to the first target sub-position and the second target sub-position.

[0046] Optionally, the second target position determining sub-module includes:

[0047] An interpolation calculation unit, configured to perform an interpolation operation on the first target sub-position and the second target sub-position according to the gravity influence weight to obtain an interpolation result;

[0048] A target position determining unit, configured to use the interpolation result as the target position to be offset for each vertex of the grass model.

[0049] Optionally, the apparatus further includes:

[0050] An offset weight setting module, configured to set the gravity offset weight corresponding to a vertex based on the position of the vertex on the grass model; wherein, the gravity offset weight decreases sequentially from the top to the bottom of the grass model.

[0051] The target position determining module includes:

[0052] A third target position determining sub-module, configured to determine the target position to be offset for each vertex of the grass model according to the acting force vector, the gravity offset weight, and the current positions of the vertices of the grass model.

[0053] Optionally, the offset weight setting module includes:

[0054] A color weight setting sub-module, configured to determine the gravity offset weight of a vertex based on the vertex color corresponding to the vertex; wherein, the vertex color becomes lighter sequentially from the top to the bottom of the grass model.

[0055] An embodiment of the present invention also discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0056] The memory is used to store a computer program;

[0057] When the processor is configured to execute the program stored in the memory, the method as described in the embodiment of the present invention is implemented.

[0058] Embodiments of the present invention also disclose one or more computer-readable media having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the methods as described in the embodiments of the present invention.

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

[0060] Through the processing method of the grass model in the embodiments of the present invention, the normal vectors of the vertices in the grass model to be rendered are determined; the normal vectors are controlled to be offset in a first direction, where the first direction is the opposite direction of the gravity direction, so that the normal vectors of the vertices can record information related to the simulated gravity of the grass model; based on the offset normal vectors, a force vector is determined, and the force vector is used to simulate gravity; according to the force vector and the current positions of the vertices of the grass model, the target positions to which the vertices of the grass model are to be offset are determined; the vertices of the grass model are controlled to move to the corresponding target positions respectively, and a grassland under the influence of gravity is obtained. In the grassland under the influence of gravity, the grass model can simulate the drooping effect under the influence of medium gravity, and the drooping effect is natural. And it is easy to adjust the grass model subsequently, and it is relatively easy to display the mixed effect of the gravity effect and other effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 is a flowchart of the steps of a method for processing a grass model provided in an embodiment of the present invention;

[0062] Figure 2 is a schematic diagram of a grass model provided in an embodiment of the present invention;

[0063] Figure 3 is a schematic diagram of the normal direction of a grass model provided in an embodiment of the present invention;

[0064] Figure 4 is a schematic diagram of the color mask of a grass model provided in an embodiment of the present invention;

[0065] Figure 5 is another schematic diagram of a grass model provided in an embodiment of the present invention;

[0066] Figure 6 is a flowchart of the steps of another method for processing a grass model provided in an embodiment of the present invention;

[0067] Figure 7 is another schematic diagram of a grass model provided in an embodiment of the present invention;

[0068] Figure 8 is a schematic diagram of a grass model in a three-dimensional scene provided in an embodiment of the present invention;

[0069] Figure 9It is a structural block diagram of a processing device for a grass model provided in an embodiment of the present invention;

[0070] Figure 10 It is a block diagram of an electronic device provided in an embodiment of the present invention;

[0071] Figure 11 It is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. Detailed implementation manners

[0072] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners.

[0073] In an embodiment of the present invention, the grass model can be as Figure 2 exemplarily shown, which is formed by a number of irregular bodies approximated in the shape of grass. For this kind of grass model, its extending direction is approximately perpendicular to the ground, and the effect of natural drooping under the influence of gravity is not shown.

[0074] In order to conveniently show the effect of natural drooping of the grass model under the influence of gravity, in an embodiment of the present invention, by adjusting the normal vectors of the vertices of the grass model, the normal vectors of the vertices of the grass model can be further used to record simulated gravity information. Subsequently, based on the simulated gravity information recorded in the normal vectors of the vertices of the grass model, the force vectors for simulating gravity of the grass model can be determined, and the vertices on the grass model can be set to offset to the target position along the direction of the force vectors, thereby realizing the efficient processing of the grass model, enabling the grass model to show the effect of natural drooping under the influence of gravity, and if the subsequent display effect obtained by mixing the gravity effect with other effects can be further shown, the grass in the three-dimensional scene can be shown more naturally.

[0075] Referring to Figure 1 , a step flowchart of a method for processing a grass model provided in an embodiment of the present invention is shown, which may specifically include the following steps:

[0076] Step 101, determine the normal vectors of each vertex in the grass model to be rendered;

[0077] Generally speaking, the normal vectors of the vertices of the grass model can be as Figure 3 exemplarily shown in the left figure in, and the normal vectors of the vertices are usually approximately perpendicular to the plane of the grass model, so that when showing the lighting effect of the grass model, the effect that the grass model is fully affected by light can be shown.

[0078] In order to simply simulate the effect of the grass model under the influence of gravity, the normal vectors of each vertex in the grass model to be rendered can be determined, so that the normal vectors of each vertex can be further adjusted subsequently.

[0079] Step 102: Control the normal vector to offset in the first direction, where the first direction is the opposite direction of the gravity direction;

[0080] Specifically, in order to record the simulated gravity information of the grass model in the grass model, the normal vector of the vertex of the grass model can be adjusted so that the direction of the normal vector of the vertex offsets in the first direction. The first direction can be the opposite direction of the gravity direction, so that the normal vector of the vertex can be reflected as an effect of tilting relative to the horizontal plane. Thus, while minimizing the impact on the lighting effect of the grass model, the normal vector of the vertex can further be used to record the simulated gravity information of the grass model, so that during the model rendering process, the grass model can be conveniently adjusted based on the normal vector of the vertex.

[0081] In a specific implementation, the grass model can correspondingly have three-dimensional coordinate axes. Among them, the x-axis and the y-axis can be parallel to the ground, and the z-axis can be perpendicular to the ground. Thus, the z-axis direction can also be considered as the direction parallel to the gravity. Therefore, the direction of the normal vector of the vertex of the grass model can be set to offset toward the z-axis direction, so that the direction of the normal vector of the vertex of the grass model offsets toward the opposite direction of the gravity direction.

[0082] The offset angle of the normal vector of the vertex of the grass model can be determined according to actual needs. For example, the normal vectors of all vertices of the grass model can be set to offset toward the z-axis by a fixed angle, or the normal vectors of the vertices corresponding to the vertices close to the top of the grass model can be set to have a larger offset angle to reflect the effect that the top of the grass is more easily affected by gravity, and the normal vectors of the vertices corresponding to the vertices close to the bottom of the grass model can be set to have a smaller offset angle to reflect the effect that the bottom of the grass is more difficult to be affected by gravity. The present invention does not limit this.

[0083] As a specific example of the present invention, Figure 3 is a schematic diagram of the normal direction of a grass model provided in an embodiment of the present invention. When the normal direction of the grass model is not adjusted, the direction of the normal vector of the vertex of the grass model can be perpendicular to the plane of the grass model as shown in the left figure in Figure 3 . In order to enable the normal vector of the vertex to record the gravity direction information of the grass model, the direction of the normal vector of the vertex of the grass model can be set to be toward the z-axis direction, so that the normal vector of the grass model offsets toward the opposite direction of the gravity. The adjusted normal direction of the grass model can be as shown in the right figure in Figure 3 .

[0084] Step 103: Determine a force vector based on the offset normal vector, where the force vector is used to simulate gravity;

[0085] When the grass model is affected by gravity, it can spread out and droop around its location. Thus, based on the offset normal vector, the force vector can be determined to simulate the effect of the grass model spreading out and drooping under the influence of gravity through the force vector.

[0086] As a specific example of the present invention, the opposite direction of the offset normal vector can be used as the force vector to simulate the effect of the grass model affected by gravity. The angle between the force vector and the z-axis can be determined based on the angle between the offset normal vector and the z-axis; alternatively, the force vector can be determined based on the offset direction of the offset normal vector relative to the original direction. The force vector can also be determined based on the offset direction of the offset normal vector relative to the original direction and an adjustment coefficient, etc. The present invention does not limit this.

[0087] Step 104, determine the target position to be offset for each vertex of the grass model according to the force vector and the current position of each vertex of the grass model;

[0088] After determining the force vector, the target position to be offset for each vertex of the grass model can be determined based on the force vector and the current position of each vertex of the grass model, so that the vertices of the grass model can be offset along the direction simulating gravity.

[0089] In a specific implementation, the offset amount of each vertex of the grass model offset along the force vector can be calculated in sequence to determine the position of each vertex of the grass model after being affected by gravity. After the position update of each vertex of the grass model is completed, the overall shape of the grass model can show the effect of simulating drooping under the influence of gravity.

[0090] After that, if it is necessary to further display different effects of the grass model, the vertex positions of the grass model can be further adjusted so that the grass model can more easily show the mixed effect of the simulated gravity effect and other effects, making the grass model have a natural display effect in the three-dimensional scene.

[0091] As a specific example of the present invention, the target position gravityObjectPosition can be calculated in the following manner:

[0092] gravityObjectPosition = gravityVector + objectPosition

[0093] Among them, the gravityVector is the gravity offset vector, which can be obtained according to the gravity offset amount and the corresponding direction of the acting force vector. Among them, the gravity offset amount can be the amount corresponding to the acting force vector, or the gravity offset amount can be set separately according to actual needs, and the present invention does not limit this. The objectPosition is the current position of the vertex.

[0094] In an embodiment of the present invention, the method further includes:

[0095] S11. Set the gravity offset weight corresponding to the vertex based on the position of the vertex on the grass model; wherein, the gravity offset weight decreases successively from the top to the bottom of the grass model.

[0096] After determining the acting force vector of the vertex in the grass model, the gravity offset weight of the vertex can be further determined to determine the degree of adjustment of the vertex towards the direction of the acting force vector.

[0097] Since the upper part of the grass model is more easily affected by gravity, while the lower part of the grass model is less easily affected by gravity. Thus, the gravity offset weights of the vertices corresponding to different parts of the grass model can be different. For the vertices located in the upper part of the grass model, their gravity offset weights can be larger, and for the vertices located in the lower part of the grass model, their gravity offset weights can be smaller. Thus, the gravity offset weight can decrease successively from the top to the bottom of the grass model.

[0098] In an embodiment of the present invention, the step of setting the gravity offset weight corresponding to the vertex based on the position of the vertex on the grass model includes:

[0099] S21. Determine the gravity offset weight of the vertex based on the vertex color corresponding to the vertex; wherein, the vertex color fades successively from the top to the bottom of the grass model.

[0100] Specifically, the gravity offset weight of the vertex can be recorded by the vertex color corresponding to the vertex, so that the gravity offset weight of the vertex can be efficiently determined without adding additional information. Among them, if the vertex color is darker, the gravity offset weight corresponding to the vertex is larger, and if the vertex color is lighter, the gravity offset weight corresponding to the vertex is smaller.

[0101] Since the vertices located in the upper part of the grass model have larger gravity offset weights, and the vertices located in the lower part of the grass model have smaller gravity offset weights. Thus, the vertex color can fade successively from the top to the bottom of the grass model.

[0102] In a specific implementation, a color mask can be set, and the gravity offset weight of the vertex can be determined according to the color corresponding to each vertex in the color mask.

[0103] For the depth of the vertex color, it can be represented by the value of a certain color component in the vertex color. For example, the larger the value of the red component, the darker the red of the vertex color. The smaller the value of the red component, the lighter the red of the vertex color.

[0104] The depth of the vertex color can also be represented by the value of the transparency of the vertex color. For example, the larger the transparency value, the darker the overall vertex color; the smaller the transparency value, the lighter the overall vertex color.

[0105] As an example of the present invention, Figure 4 is a color mask schematic diagram of a grass model provided in an embodiment of the present invention. In this color mask, the vertex color, i.e., red, can gradually become lighter from the top to the bottom of the grass model, so that the gravity offset amount of the vertex can gradually decrease from the top to the bottom of the grass model.

[0106] The step of determining the target position to be offset for each vertex of the grass model according to the acting force vector and the current position of each vertex of the grass model includes:

[0107] S31. Determine the target position to be offset for each vertex of the grass model according to the acting force vector, the gravity offset weight, and the current position of each vertex of the grass model.

[0108] After obtaining the gravity offset weight, the target position to be offset for each vertex of the grass model can be determined according to the acting force vector, the gravity offset weight, and the current position of each vertex of the grass model.

[0109] Specifically, first, the direction and offset amount of the offset of the grass model vertex can be comprehensively determined according to the acting force vector and the gravity offset weight to determine the gravity offset vector, and then the target position to be offset for each vertex of the grass model can be determined based on the current position of the grass model vertex.

[0110] Step 105. Control each vertex of the grass model to move to the corresponding target position respectively to obtain a grassland under the influence of gravity.

[0111] After determining the target position to be offset, each vertex of the grass model can be controlled to move to the corresponding target position respectively. After the position of the vertex of the grass model changes, the overall shape of the grass model can also change accordingly, so that a grassland under the influence of gravity can be obtained. In the grassland under the influence of gravity, the grass model can simulate the effect of sagging under the influence of gravity, and the sagging effect is natural.

[0112] As an example of the present invention, Figure 5 is another schematic diagram of a grass model provided in an embodiment of the present invention. AsFigure 5 As shown in (a), the grass model does not show the effect of being affected by gravity in the initial state, and the overall grass model extends upward. Subsequently, based on the normal vectors of the vertices of the adjusted grass model, the force vectors of the grass model can be determined, and it can be set that the vertices of the grass model move to the target positions based on the force vectors, so that the grass model sags along the direction of gravity, and the obtained grass model is as shown in Figure 5 (b).

[0113] Through the processing method of the grass model according to the embodiments of the present invention, the normal vectors of the vertices in the grass model to be rendered are determined; the normal vectors are controlled to shift in the first direction, and the first direction is the opposite direction of the gravity direction, so that the normal vectors of the vertices can be used to record the information related to the simulated gravity of the grass model; based on the shifted normal vectors, the force vectors are determined, and the force vectors are used to simulate gravity; according to the force vectors and the current positions of the vertices of the grass model, the target positions to which the vertices of the grass model are to be shifted are determined; the vertices of the grass model are controlled to move to the corresponding target positions respectively, and the grassland under the influence of gravity is obtained. In the grassland under the influence of gravity, the grass model can simulate the effect of sagging under the influence of gravity, and the sagging effect is natural. And it is easy to adjust the grass model subsequently, and it is relatively easy to show the mixed effect of the gravity effect and other effects.

[0114] Referring to Figure 6 , a flowchart of the steps of a processing method of a grass model provided in the embodiments of the present invention is shown, which may specifically include the following steps:

[0115] Step 601, determine the normal vectors of the vertices in the grass model to be rendered;

[0116] In order to simply simulate the effect of the grass model being affected by gravity, the normal vectors of the vertices in the grass model to be rendered can be determined, so that the normal vectors of the vertices can be further adjusted subsequently.

[0117] Step 602, control the normal vectors to shift in the first direction, and the first direction is the opposite direction of the gravity direction;

[0118] Specifically, in order to record the simulated gravity information of the grass model in the grass model, the normal vectors of the vertices of the grass model can be adjusted so that the directions of the normal vectors of the vertices shift in the first direction. The first direction can be the opposite direction of the gravity direction, so that the normal vectors of the vertices can be reflected as the effect of tilting relative to the horizontal plane. Thus, while hardly affecting the lighting effect of the grass model, the normal vectors of the vertices can further be used to record the simulated gravity information of the grass model, so that during the model rendering process, the grass model can be conveniently adjusted based on the normal vectors of the vertices.

[0119] In a specific implementation, the grass model may correspondingly have three-dimensional coordinate axes. Among them, the x-axis and the y-axis may be parallel to the ground, and the z-axis may be perpendicular to the ground. Thus, the z-axis direction can also be considered as the direction parallel to gravity. Therefore, it is possible to set the direction of the normal vector of the vertices of the grass model to deviate towards the z-axis direction, so that the direction of the normal vector of the vertices of the grass model deviates towards the opposite direction of the gravity direction.

[0120] Step 603: Determine a force vector based on the offset normal vector. The force vector is used to simulate gravity.

[0121] When the grass model is affected by gravity, it can spread out and droop around its location. Therefore, based on the offset normal vector, a force vector can be determined to simulate the effect of the grass model spreading out and drooping under the influence of gravity through the force vector.

[0122] As a specific example of the present invention, the opposite direction of the offset normal vector can be used as the force vector to simulate the effect of the grass model being affected by gravity.

[0123] Step 604: Obtain a wind influence factor, where the wind influence factor is used to simulate the intensity of the wind.

[0124] Specifically, in order to naturally display the grassland in a three-dimensional scene, when the grass model is affected by gravity, it usually can also be affected by the wind. Therefore, in order to show the effect of the grass model being affected by both gravity and wind, it is possible to set the vertices of the grass model to offset along the gravity direction and the wind direction simultaneously, so as to display the effect that the entire grass model is simulated to offset under the influence of both gravity and wind.

[0125] Therefore, a wind influence factor can be obtained, which can be used to simulate the intensity of the wind, so that the grass model can obtain a grass model that is offset under the influence of both gravity and wind based on the wind influence factor.

[0126] Step 605: Determine the gravity influence weight according to the wind influence factor.

[0127] The wind intensity can affect the degree to which the grass model is affected by gravity. When the wind intensity is large, the influence of gravity on the grass model will be correspondingly reduced. When the wind intensity is small, the influence of gravity on the grass model increases relative to when the wind intensity is large. In the absence of wind influence, the grass model can be affected by gravity to the greatest extent.

[0128] Therefore, when affected by wind force, it is further necessary to determine the gravity influence weight according to the intensity of the wind force influence factor, so as to determine the degree to which the grass model is affected by gravity under the influence of wind force, so as to obtain the effect of offset caused by the combined influence of gravity and wind force.

[0129] In a specific implementation, the wind force influence factor can be used as the gravity influence weight to calculate the offset position of the grass model under the combined influence of gravity and wind force.

[0130] Step 606, determine the target position to be offset for each vertex of the grass model according to the force vector, the current position of each vertex of the grass model, and the gravity influence weight;

[0131] After determining the force vector, the target position to be offset for each vertex of the grass model can be determined according to the force vector, the current position of each vertex of the grass model, and the gravity influence weight, so that the vertices of the grass model can be offset along the directions simulating gravity and wind force.

[0132] In an embodiment of the present invention, the method further includes:

[0133] S11, determine a first target sub-position according to a preset vertex animation, where the first target sub-position is the position where the grass model is to be moved under the influence of the wind force.

[0134] A vertex animation with a swinging effect along with the wind can be preset, and based on the positions of the vertices in each frame of the vertex animation, the first target sub-position where the grass model is to be moved under the influence of the wind force can be determined.

[0135] Specifically, the vertex animation can record the positions to which the vertices of the grass model should be moved under the influence of the wind force in each frame, and the first target sub-position where the grass model is to be moved under the influence of the wind force can be directly determined based on the vertex animation.

[0136] In an embodiment of the present invention, the step of determining the target position to be offset for each vertex of the grass model according to the force vector, the current position of each vertex of the grass model, and the gravity influence weight includes:

[0137] S21, obtain a second target sub-position according to the force vector, the current position of each vertex of the grass model, and the gravity influence weight, where the second target sub-position is the position where the grass model is to be moved under the influence of the force vector;

[0138] Specifically, the wind intensity can affect the degree to which the grass model is affected by gravity. In the case of a relatively high wind intensity, the influence of gravity on the grass model will be correspondingly reduced. In the case of a relatively low wind intensity, the influence of gravity on the grass model will increase compared to when the wind intensity is high. In the absence of wind influence, the grass model can be affected by the maximum gravity.

[0139] Therefore, when calculating the offset position of the grass model affected by gravity, a second target sub-position can be obtained based on the force vector, the current positions of the vertices of the grass model, and the gravity influence weight. The second target sub-position can be the position where the grass model is to be moved under the influence of the force vector.

[0140] In a specific implementation, the second target sub-position gravityObjectPosition can be calculated in the following way:

[0141] gravityObjectPosition = gravityVector * (1 - windFactor) + objectPosition

[0142] where windFactor is the wind influence factor; gravityVector is the gravity offset vector without wind influence, which can be obtained based on the gravity offset amount without wind influence and the direction of the force vector. Among them, the gravity offset amount can be the amount corresponding to the force vector, or the gravity offset amount can be set separately according to actual needs. The present invention does not limit this. gravityVector * (1 - windFactor) is the gravity offset vector under the influence of wind, and objectPosition is the current position of the vertex.

[0143] S22. Obtain the target positions to be offset for each vertex of the grass model according to the first target sub-position and the second target sub-position.

[0144] After obtaining the first target sub-position and the second target sub-position, the target positions where the vertices of the grass model should be located under the combined influence of wind and gravity can be comprehensively determined according to the first target sub-position and the second target sub-position.

[0145] In an embodiment of the present invention, the step of obtaining the target positions to be offset for each vertex of the grass model according to the first target sub-position and the second target sub-position includes:

[0146] S31. Perform an interpolation operation on the first target sub-position and the second target sub-position according to the gravity influence weight to obtain an interpolation result;

[0147] Since the influence of gravity on the grass model decreases correspondingly under a relatively strong wind intensity, while the influence of gravity on the grass model increases relative to that under a relatively strong wind intensity under a relatively weak wind intensity. Therefore, in the process of jointly determining the target positions where the vertices of the grass model should be located under the combined influence of wind and gravity, the gravity influence weight can be further determined according to the wind influence factor, and interpolation operations are performed on the first target sub-position and the second target sub-position according to the gravity influence weight to obtain an interpolation result, so as to determine the position of the grass model under the influence of wind and gravity.

[0148] As a specific example of the present invention, the interpolation result finalObjectPosition can be calculated by the following formula:

[0149] finalObjectPosition = lerp(gravityObjectPosition, windObjectPosition, windFactor)

[0150] where gravityObjectPosition is the second target sub-position, windObjectPosition is the first target sub-position, and windFactor is the wind influence factor, which can be directly used as the gravity influence weight.

[0151] S32. Use the interpolation result as the target position for each vertex of the grass model to be offset.

[0152] After calculating the interpolation result, the interpolation result can be used as the target position for each vertex of the grass model to be offset under the influence of wind and gravity, so as to reflect the offset effect of the grass model under the influence of gravity and wind.

[0153] As an example of the present invention, as Figure 5 (a) shows, the grass model is not affected by gravity in the initial state, and the whole grass model extends upward. Subsequently, based on the normal vector of the vertices of the adjusted grass model, the acting force vector of the grass model can be determined, and based on the acting force vector, the target positions for each vertex of the grass model to be offset can be further determined, and the vertices of the grass model are set to move to the target positions, so that the grass model sags along the gravity direction, and the obtained grass model is as shown in Figure 5 (b). Subsequently, Figure 7 This is another schematic diagram of the grass model provided in the embodiment of the present invention. When only affected by wind, the shape of the grass model is as shown in Figure 7(a). Subsequently, according to a preset vertex animation, a first target sub - position can be determined. The first target sub - position is the position where the grass model is to be moved under the influence of wind force. And according to the acting force vector, the current positions of each vertex of the grass model, and the gravity influence weight, a second target sub - position is obtained. According to the gravity influence weight, an interpolation operation is performed on the first target sub - position and the second target sub - position to obtain an interpolation result, and the target positions of each vertex of the grass model under the influence of wind force and gravity are determined. The obtained grass model is as Figure 7 (b) shown.

[0154] Step 607, control each vertex of the grass model to move to the corresponding target position respectively, and obtain the grassland under the influence of gravity.

[0155] After determining the target position to be offset, each vertex of the grass model can be controlled to move to the corresponding target position respectively. After the positions of the vertices of the grass model change, the overall shape of the grass model can also change accordingly, so that the grassland under the influence of gravity can be obtained. In the grassland under the influence of gravity, the grass model can simulate the effect of drooping under the influence of gravity, and the drooping effect is natural.

[0156] As an example of the present invention, as Figure 8 is a schematic diagram of a grass model in a three - dimensional scene provided in an embodiment of the present invention. It can be seen that the grass model processed by the grass model processing method of the embodiment of the present invention can naturally display the effects of natural drooping and swaying with the wind in a three - dimensional scene.

[0157] Through the grass model processing method of the embodiment of the present invention, the normal vector of each vertex in the grass model to be rendered is determined; control the normal vector to offset in the first direction, and the first direction is the opposite direction of the gravity direction, so that the normal vector of the vertex can record the information related to the simulated gravity of the grass model; based on the offset normal vector, an acting force vector is determined, and the acting force vector is used to simulate gravity; according to the acting force vector and the current positions of each vertex of the grass model, the target positions where each vertex of the grass model is to be offset are determined; control each vertex of the grass model to move to the corresponding target position respectively, and obtain the grassland under the influence of gravity. In the grassland under the influence of gravity, the grass model can simulate the effect of drooping under the influence of gravity, and the drooping effect is natural. And it is easy to adjust the grass model subsequently, and it is relatively easy to display the mixed effect of the gravity effect and other effects.

[0158] Referring to Figure 9 , a structural block diagram of a grass model processing device provided in an embodiment of the present invention is shown, which specifically may include the following modules:

[0159] A normal vector determination module 901, configured to determine the normal vectors of the vertices in the grass model to be rendered;

[0160] An offset module 902, configured to control the offset of the normal vector in a first direction, where the first direction is the opposite direction of the gravity direction;

[0161] A force vector determination module 903, configured to determine a force vector based on the offset normal vector, where the force vector is used to simulate gravity;

[0162] A target position determination module 904, configured to determine the target positions to which the vertices of the grass model need to be offset according to the force vector and the current positions of the vertices of the grass model;

[0163] A movement module 905, configured to control each vertex of the grass model to move to the corresponding target position respectively, to obtain a grassland under the influence of gravity.

[0164] Optionally, the device further includes:

[0165] A factor acquisition module, configured to acquire a wind force influence factor, where the wind force influence factor is used to simulate the intensity of the wind force;

[0166] The target position determination module includes:

[0167] An influence weight determination module, configured to determine a gravity influence weight according to the wind force influence factor;

[0168] A first target position determination sub-module, configured to determine the target positions to which the vertices of the grass model need to be offset according to the force vector, the current positions of the vertices of the grass model, and the gravity influence weight.

[0169] Optionally, the device further includes:

[0170] A first sub-position determination module, configured to determine a first target sub-position according to a preset vertex animation, where the first target sub-position is the position where the grass model needs to move under the influence of the wind force;

[0171] The target position determination module includes:

[0172] A second sub-module determination sub-module, configured to obtain a second target sub-position according to the force vector, the current positions of the vertices of the grass model, and the gravity influence weight, where the second target sub-position is the position where the grass model needs to move under the influence of the force vector;

[0173] A second target position determination sub-module, configured to obtain the target positions to which the vertices of the grass model need to be offset according to the first target sub-position and the second target sub-position.

[0174] Optionally, the second target position determination sub-module includes:

[0175] An interpolation calculation unit, configured to perform an interpolation operation on the first target sub-position and the second target sub-position according to the gravity influence weight to obtain an interpolation result;

[0176] A target position determination unit, configured to use the interpolation result as the target position to be offset for each vertex of the grass model.

[0177] Optionally, the device further includes:

[0178] An offset weight setting module, configured to set the gravity offset weight corresponding to the vertex based on the position of the vertex on the grass model; wherein, the gravity offset weight decreases sequentially from the top to the bottom of the grass model.

[0179] The target position determination module includes:

[0180] A third target position determination sub-module, configured to determine the target position to be offset for each vertex of the grass model according to the force vector, the gravity offset weight, and the current position of each vertex of the grass model.

[0181] Optionally, the offset weight setting module includes:

[0182] A color weight setting sub-module, configured to determine the gravity offset weight of the vertex based on the vertex color corresponding to the vertex; wherein, the vertex color becomes lighter sequentially from the top to the bottom of the grass model.

[0183] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for the related parts, please refer to the partial description of the method embodiment.

[0184] In addition, an embodiment of the present invention further provides an electronic device, as Figure 10 shown, including a processor 1001, a communication interface 1002, a memory 1003, and a communication bus 1004. Among them, the processor 1001, the communication interface 1002, and the memory 1003 complete mutual communication through the communication bus 1004,

[0185] The memory 1003 is used to store a computer program;

[0186] The processor 1001, when executing the program stored in the memory 1003, implements the following steps:

[0187] Adjust the normal vector of the vertex of the grass model so that the direction of the normal vector of the vertex is offset towards the gravity direction;

[0188] Determine the gravity direction of the grass model based on the direction of the normal vector of the vertex;

[0189] Set the vertices of the grass model to offset along the gravity direction so that the grass model droops along the gravity direction.

[0190] Optionally, the step of determining the gravity direction of the grass model based on the direction of the normal vector of the vertex includes:

[0191] Take the opposite direction of the normal vector of the vertex as the gravity direction of the grass model.

[0192] Optionally, the method further includes:

[0193] Set the gravity offset of the vertex based on the position of the vertex on the grass model; wherein, the gravity offset decreases sequentially from the top to the bottom of the grass model.

[0194] The step of setting the vertices of the grass model to offset along the gravity direction includes:

[0195] Determine the first gravity offset position of the vertex of the grass model after being affected by gravity based on the original position, gravity direction, and gravity offset of the vertex of the grass model.

[0196] Optionally, the step of setting the gravity offset of the vertex based on the position of the vertex on the grass model includes:

[0197] Determine the gravity offset of the vertex based on the vertex color corresponding to the vertex; wherein, the vertex color becomes lighter sequentially from the top to the bottom of the grass model.

[0198] Optionally, the step of setting the vertices of the grass model to offset along the gravity direction includes:

[0199] Set the vertices of the grass model to offset along the gravity direction and the wind direction.

[0200] Optionally, the step of setting the vertices of the grass model to offset along the gravity direction and the wind direction includes:

[0201] Determine the gravity offset vector affected by the wind based on the wind intensity, gravity vector, and gravity offset;

[0202] Determine the second gravity offset position of the vertex of the grass model affected by gravity based on the original position of the vertex of the grass model and the gravity offset vector affected by the wind;

[0203] Using the wind force intensity as a weight, based on the second gravity offset position and the wind force offset position, determine the mixed offset position of the vertices of the grass model.

[0204] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only a thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.

[0205] The communication interface is used for communication between the above terminal and other devices.

[0206] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0207] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0208] As Figure 11 shown, in another embodiment provided by the present invention, there is also provided a computer-readable storage medium 1101. Instructions are stored in this computer-readable storage medium. When it runs on a computer, it causes the computer to execute the processing method of the grass model described in the above embodiment.

[0209] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions. When it runs on a computer, it causes the computer to execute the processing method of the grass model described in the above embodiment.

[0210] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).

[0211] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0212] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference can be made to the partial description of the method embodiment for the relevant parts.

[0213] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included in the protection scope of the present invention.

Claims

1. A method for implementing a grassland effect, characterized in that, Including: Determine the normal vectors of each vertex in the grass model to be rendered; Control the normal vectors to be offset in a first direction, where the first direction is the opposite direction of the gravity direction; Based on the offset normal vectors, determine a force vector, where the force vector is used to simulate gravity; According to the force vector and the current positions of each vertex of the grass model, determine the target positions to which each vertex of the grass model is to be offset; Control each vertex of the grass model to move to the corresponding target position respectively to obtain a grassland under the influence of gravity; The method further includes: Obtain a wind influence factor, where the wind influence factor is used to simulate the intensity of wind; According to the force vector and the current positions of each vertex of the grass model, determining the target positions to which each vertex of the grass model is to be offset includes: Determine a gravity influence weight according to the wind influence factor; According to the force vector, the current positions of each vertex of the grass model, and the gravity influence weight, determine the target positions to which each vertex of the grass model is to be offset.

2. The method according to claim 1, wherein The method further includes: Determine a first target sub-position according to a preset vertex animation, where the first target sub-position is the position where the grass model is to move under the influence of wind; The step of determining the target positions to which each vertex of the grass model is to be offset according to the force vector, the current positions of each vertex of the grass model, and the gravity influence weight includes: Obtain a second target sub-position according to the force vector, the current positions of each vertex of the grass model, and the gravity influence weight, where the second target sub-position is the position where the grass model is to move under the influence of the force vector; According to the first target sub-position and the second target sub-position, obtain the target positions to which each vertex of the grass model is to be offset.

3. The method according to claim 2, wherein The step of obtaining the target positions to which each vertex of the grass model is to be offset according to the first target sub-position and the second target sub-position includes: Perform an interpolation operation on the first target sub-position and the second target sub-position according to the gravity influence weight to obtain an interpolation result; Use the interpolation result as the target positions to which each vertex of the grass model is to be offset.

4. The method according to claim 1, characterized in that The method further includes: Based on the position of a vertex on the grass model, set the gravity offset weight corresponding to the vertex; where the gravity offset weight decreases sequentially from the top to the bottom of the grass model; The step of determining the target positions to which each vertex of the grass model is to be offset according to the force vector and the current positions of each vertex of the grass model includes: According to the force vector, the gravity offset weight, and the current positions of each vertex of the grass model, determine the target positions to which each vertex of the grass model is to be offset.

5. The method according to claim 4, wherein The step of setting the gravity offset weight corresponding to a vertex based on the position of the vertex on the grass model includes: Based on the vertex color corresponding to the vertex, determine the gravity offset weight of the vertex; where the vertex color becomes lighter sequentially from the top to the bottom of the grass model.

6. A processing device for a grass model, characterized in that, Including: A normal determination module for determining the normal vectors of each vertex in the grass model to be rendered; An offset module for controlling the normal vector to be offset in a first direction, which is the opposite direction of the gravity direction; A force vector determination module for determining a force vector based on the offset normal vector, where the force vector is used to simulate gravity; A target position determination module for determining the target positions to which the vertices of the grass model are to be offset according to the force vector and the current positions of the vertices of the grass model; A movement module for controlling the vertices of the grass model to move to the corresponding target positions respectively, obtaining a grassland under the influence of gravity; The apparatus further includes: A factor acquisition module for acquiring a wind influence factor, where the wind influence factor is used to simulate the intensity of wind; The target position determination module includes: An influence weight determination module for determining a gravity influence weight according to the wind influence factor; A first target position determination sub-module for determining the target positions to which the vertices of the grass model are to be offset according to the force vector, the current positions of the vertices of the grass model, and the gravity influence weight.

7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used for storing a computer program; When the processor executes the program stored on the memory, it implements the method according to any one of claims 1-5.

8. A computer-readable medium having instructions stored thereon, which when executed by one or more processors, cause the processors to execute the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Image rendering method and device, electronic equipment and storage medium

    CN113822981A