0
\$\begingroup\$

I have a quadratic bezier curve, i want add a sine wave to it to animate it, simulate the grass animation. Currently i add the sine wave to P2.y and P3.y, but it don't look very nature. How to add the sine wave to bezier curve? P2 is Mid Point, P3 is End Point. grass animation

\$\endgroup\$
8
  • 2
    \$\begingroup\$ Maybe have the sin wave add to the normal direction of the bezier curve? To get normal direction you can derivate the Bezier curve to get the tangent direction, and then rotate it 90 degrees. \$\endgroup\$
    – Mangata
    Commented Jan 16, 2023 at 7:26
  • 2
    \$\begingroup\$ Is the bezier curve representing the bent shape of a single blade of grass, or is it an animation curve controlling some feature over time? \$\endgroup\$
    – DMGregory
    Commented Jan 16, 2023 at 12:04
  • \$\begingroup\$ @DMGregory The bezier curve representing the bent shape of a single blade of grass. \$\endgroup\$ Commented Jan 17, 2023 at 1:53
  • \$\begingroup\$ @Mangata If i add sine wave to the normal direction of the bezier curve, i need know bezier curve arc length to send it to sine wave function Amplitude * sin((arc length + time) * frequency + phase), but bezier curve arc lenth don't have a formula to calculate it, we need segmentation the bezier curve to many section and sum up, but we can't do it in vertex shader because of performance reason. \$\endgroup\$ Commented Jan 17, 2023 at 2:03
  • \$\begingroup\$ There is a formula to calculate the arc length of a quadratic Beziér curve, but it's messy. Would you be willing to substitute another curve that's easier to bend while maintaining its length, like circular arcs (lines of constant curvature)? \$\endgroup\$
    – DMGregory
    Commented Jan 17, 2023 at 2:30

0

You must log in to answer this question.

Browse other questions tagged .