Interactive Grass

About Interactive Grass – Unity VFX & Shader Pack

Interactive Grass Unity Asset Overview

The Interactive Grass package provides a production-oriented foliage shading system designed primarily for Unity's Universal Render Pipeline (URP). The core rendering mechanism utilizes custom HLSL subshaders integrated alongside Visual Effect Graph and Shader Graph representations, giving technical artists fine-grained control over vertex deformation, lighting response, and distance-based tessellation.

Vertex Displacement & Wind Simulation

Deformation is executed directly in the vertex shader stage to minimize fragment overhead. Wind motion combines multi-layered sine wave evaluations with a sample from a scrolling world-space Simplex Noise texture. This dual-pass vertex pipeline provides smooth organic sway while retaining sharp, localized physics reactions when interacting objects cross the geometry bounds.

Depth Buffer & Overdraw Handling

Foliage rendering inherently strains the rasterizer through high overdraw. The asset mitigates frame-rate drops by offering two primary render modes:

Integrating with URP post-processing stack layers—such as Screen Space Ambient Occlusion (SSAO) and Depth of Field—is maintained via standard depth-texture writes (`_CameraDepthTexture`), ensuring grass geometry properly registers in depth-based atmospheric effects.

Dynamic Interaction & Controller Implementation

Dynamic foliage response relies on an efficient interactor system. Rather than executing expensive per-blade physics colliders, interaction is computed algebraically inside the vertex shader by reading world-space position data supplied by standard C# mono-components.

Interaction Techniques

The system supports two distinct methods for translating scene dynamics to vertex displacement:

To prevent material instantiation overhead and maintain batching efficiency, properties are injected at runtime using a MaterialPropertyBlock or through low-overhead global shader properties.

Inspector Properties & Scripting Guide

The standard inspector exposes intuitive controls for controlling physical attributes such as bend stiffness, elastic recovery speed, wind weight, and interactive influence radii. Configuring dynamic interactors requires a controller component attached to moving scene objects.

Interactor Script Implementation

The following C# script demonstrates passing interactor positions directly to the standard grass shader pipeline using global vector arrays. Attach this component to a manager object or primary scene controller:

using UnityEngine;

[ExecuteAlways]
public class GrassInteractionController : MonoBehaviour
{
    [Header("Interaction Settings")]
    [SerializeField] private Transform[] interactors = new Transform[8];
    [SerializeField] private float interactionRadius = 1.5f;
    [SerializeField] private float displacementStrength = 2.0f;

    private static readonly int InteractorPositionsID = Shader.PropertyToID("_GlobalGrassBufferPos");
    private static readonly int InteractionParamsID = Shader.PropertyToID("_GlobalGrassParams");

    private Vector4[] positionBuffer = new Vector4[16];

    private void Update()
    {
        UpdateShaderGlobals();
    }

    private void UpdateShaderGlobals()
    {
        int activeCount = Mathf.Min(interactors.Length, positionBuffer.Length);

        for (int i = 0; i < activeCount; i++)
        {
            if (interactors[i] != null)
            {
                Vector3 pos = interactors[i].position;
                // Store XYZ position, W component holds individual radius scaler
                positionBuffer[i] = new Vector4(pos.x, pos.y, pos.z, interactionRadius);
            }
            else
            {
                positionBuffer[i] = Vector4.zero;
            }
        }

        Shader.SetGlobalVectorArray(InteractorPositionsID, positionBuffer);
        Shader.SetGlobalVector(InteractionParamsID, new Vector4(displacementStrength, activeCount, 0f, 0f));
    }
}

Performance Profiling & Mobile Optimization

When deploying foliage shaders to mobile GPUs (such as ARM Mali or Qualcomm Adreno architectures), target performance hinges on tile-based deferred rendering (TBDR) bandwidth. The following profiling strategies ensure optimal framerates across target platforms:

Technical Profiling Highlights

Mobile Deployment Checklist

Asset Details & Specifications

CategoryVFX / Shaders
Latest Versionv2.4
File Size1.52 MB
Added to PlatformFebruary 7, 2026
Views3 views
Downloads1 downloads
Favourites0 favourites
Issue with Package?Report Broken Link →

Developers Who Downloaded This Also Downloaded

Related Unity VFX Assets