# CWD-Sim: Real-Time Simulation on Grass Swaying with Controllable Wind Dynamics
## 3 Proposed Algorithms
### Deformation of the Grass Model  
From real-world observations of grass swaying in the wind, we propose a basic grass deformation model. It replicates grass dynamics through a blend of the two most significant grass motions, as shown in Figure 3. Bending is due to the influence of gravity, and the swaying of the grass is due to the wind force. The deformation of the grass is carried out in the vertex shader. Initially, before the wind force is applied, the only force that acts on the grass is gravity. This force consistently bends the blade downward, and the amount of bending depends on the weight of the blade in the absence of wind force. This process is divided into gravity deformation and external force deformation. In the first step, we apply an initial deformation based on the elevation value \(P_{y}\in\mathbb{R}\) of the position of the vertex. This step modifies the original position of the vertex \(P\in\mathbb{R}^{3}\) to a new position \(P^{\prime}\), as shown in Figure 4. The second step converts the external force into a translation vector using a quadratic equation, as shown in Figure 5.  
Figure 3: Shows the detailed bending effect of a grass blade due to the wind force. (**a**): Default state. (**b**): Only gravity. (**c**): Gravity with external wind force. This calculation of a quadratic equation eliminates the computational overhead of using a Bezier curve in [6] and provides a similar translation result. \[P^{\prime}=\left(P_{x},P_{y}-k_{1}\cdot\left(P_{y}\right)^{2},P_{z}+k_{2}\cdot \left(P_{y}\right)^{2}\right) \tag{11}\]  
where \(k_{1}\) and \(k_{2}\) are parameters to control the shape of the curve. For comparison, Figure 4a,b show an example of bending of a grass blade. Figure 4a is the result when we apply our simple quadratic equation, whereas Figure 4b shows the case when we apply the Bezier curve. For comparison, we put two graphs together to check the similarity for both Figures 4a and 5a where the dotted curves are the Bezier curves and the green curves are our proposed methods. We also show the red dots for control points for the Bezier curves. As we can see from the picture, the bending result is quite similar for both cases, although our equation needs fewer computations. We also add numerical comparisons in Table 1.  
Figure 4: Comparison of grass’s default state due to gravity. **(a)**: Proposed deformation Equation (11) is shown as a green line, the Bezier curve is shown as a red dotted line superimposed on our equation. **(b)**: Bezier curve equation \(\left(P=(1-t)^{3}P_{1}+3(1-t)^{2}tP_{2}+3(1-t)t^{2}P_{3}+t^{3}P_{4},0\leq t\leq 1\right)\) proposed in [20]. Figure 5: Comparison of grass’s swaying state due to external force. **(a)**: Proposed deformation Equations (11) and (12) applied are shown as a green line, the Bezier curve is shown as a red dotted line superimposed on our equation. **(b)**: Bezier curve equation \(\left(P=(1-t)^{3}P_{1}+3(1-t)^{2}tP_{2}+3(1-t)t^{2}P_{3}+t^{3}P_{4},0\leq t\leq 1\right)\) proposed in [20]. Table 1 shows the evaluation of up to 10,000 virtual vertex points. Our proposed algorithm (11) shows a speed faster than that of using the Bezier curve in terms of computation times, which is approximately 82.8% faster, with a time savings of 62.8 ms. This efficiency difference is quite important when we are dealing with a large set of vertex points such as grasses because it underscores the impact of computational complexity on processing speed and therefore highlights the importance of choosing the right algorithm for time-sensitive computational tasks. In the second step of our process, we take into account the impact of the wind force on the grass blades. We calculate the wind translation vector \(T\) from the wind direction vector \(W\) and its magnitude \(F\). This vector \(T\) essentially quantifies how the wind force should alter the position of the grass blades. The elevation value of the deformed vertex \(P^{\prime}_{y}\) is again used to calculate the wind translation.