Skip to content

How to adjust grass leaves simulation in homepage landscape

Daniele Guido edited this page Jan 25, 2024 · 1 revision

The grass.jsx file in the components might seems like the primary location for animation adjustments. However, it’s primarily for grass distribution. The actual animation is controlled by the compute.frag, a shader that manages multiple elements like terrain height and wind.

Adjusting Animation Speed

In compute.frag shader, look for the time vector, specifically on line 40. The time vector’s current computation involves multiplying the actual time (in milliseconds) by a negative value (-0.125). This is for normalization purposes, making it easier to read and correlate with other factors.

To Speed Up

Increase the multiplier (e.g., change -0.125 to 0.25).

To Slow Down

Decrease the multiplier (e.g., change -0.125 to -0.025).

After modifying the value, save the file. Note that this change is not taken into account by Vite hot reloader, just refresh the page :)

Understanding Compute Fragment Efficiency

The compute fragment shader is utilized for its efficiency in handling multiple computations. It calculates various elements like terrain displacement, wind variations across the screen, and fog. This approach enables sharing computations across components, such as terrain, grass, and pebbles. By adjusting the compute fragment, you effectively control the speed of the entire animation, including the wind and cloud movements that affect the grass.