AA Grass Pro v2.0
Scalable GPU-driven procedural foliage system for Unity. Paint anywhere on any collider mesh โ featuring 3D V-keel blades, real-time shadow receiving, 4-tier continuous LOD blending, analytical multi-collider physics interaction, and dual-sided BSDF translucency.
๐ What's New in Version 2.0
3D V-Shape Keel Blades
Replaced flat 2-vertex ribbon strips with 3-vertex V-creased cross-sections featuring a central spine keel and outward-flared cylindrical normals for realistic volumetric depth.
Dynamic Shadow Receiving
Directional sunlight and scene shadow casters are now received directly on grass blades in both HDRP and URP with automatic two-sided normal bias correction.
Auto-Detect & Attach Assets
Adding the Grass System component to any GameObject automatically discovers and links the required Compute Shader and Material assets without null references.
Volumetric Fog Sync
Eliminated double-fog conflicts and horizontal slicing artifacts with synchronized depth prepasses, allowing HDRP atmospheric scattering to blend smoothly.
Modernized GUI & Global Reset
Header features a top-right โบ Reset All button with safety confirmation, per-section resets, styled subcards, and responsive master toggles.
Analytical Multi-Collider Physics
True 64-byte GPU mathematical formulations for Spheres, Capsules, Oriented Boxes, and Wheels with elastic recovery and UV-shift tracking.
โก Quick Start
Create Grass System โ Go to
GameObject โ AA Grass Pro โ Create Grass System. Auto-creates system root, Wind Direction child, and auto-links compute shader + material.Open Painter โ Click
๐จ Open Painterin the Grass System Inspector or menuWindow โ AA Grass Pro โ Grass Painter.Paint โ Left-click and drag across any surface with a Collider. A
GrassRendereris auto-spawned per unique surface.Fine-Tune โ Adjust Blade Geometry, 3-Tier Gradients, Wind, LOD Transition, and Physics in the modernized Inspector.
No Unity Terrain required! Paint freely on static meshes, moving platforms, procedural geometry, or organic rocks.
๐ง Scene Setup
Scene Hierarchy Elements
| Object | Purpose |
|---|---|
Grass System (GameObject) | Root orchestrator holding global simulation settings. Exactly one per scene. |
Wind Direction (child) | Rotate in the scene view to orient global wind wave propagation. |
GrassRenderer_{surface} | Auto-attached child to painted surfaces. Holds GrassData + GPU compute buffers. |
GeneratedAssets/GrassMaterial.mat | Universal instanced material configured for URP or HDRP. |
GeneratedAssets/GrassData_{surface}.asset | ScriptableObject storing all serialized instances for persistence across sessions. |
Platform & System Requirements
| Requirement | Detail |
|---|---|
| Unity Version | 2022.3 LTS, 2023.x, or Unity 6 (6000.x) |
| Render Pipelines | Universal Render Pipeline (URP) or High Definition Render Pipeline (HDRP) |
| Target Hardware | Compute Shader support (Shader Model 4.5+ / DX11 / DX12 / Vulkan / Metal) |
| Colliders | Standard Unity Collider attached to surfaces you wish to paint on |
๐จ Painting Grass
Viewport Controls
| Input | Action |
|---|---|
| Left-Click | Paint a single cluster at cursor position |
| Left-Click + Drag | Smooth continuous painting (throttled at ~30 ops/sec with 0.15m move delta) |
| Ctrl + Click / Drag | Instant eraser mode |
| Shift + Scroll | Dynamically adjust brush radius |
Brush Properties
| Setting | Range | Default | Description |
|---|---|---|---|
| Radius | 0.1 โ 20 | 2.0 | Brush influence radius in world units |
| Density | 1 โ 100 | 15 | Instances per stroke. Calculated as: ฯ ร rยฒ ร density ร 0.1 |
| Height Min / Max | 0.2 โ 2.0 | 0.7 โ 1.3 | Randomized vertical height scaling multiplier |
| Width Min / Max | 0.2 โ 2.0 | 0.7 โ 1.3 | Randomized horizontal blade width multiplier |
| Layers | LayerMask | Everything | Layers that the painting raycast recognizes |
โ๏ธ Grass System & Modern GUI
The Inspector features high-visibility master toggle cards, a top-right โบ Reset All button with safety confirmation dialog, individual section reset controls, and clean color palette subcards.
Inspector Toolbar & Header
- Top-Right โบ Reset All: Instantly resets all parameters back to factory defaults with an undo record and safety prompt.
- ๐จ Open Painter: Opens the brush tool window docked or floating.
- ๐ Refresh All: Forces GPU indirect buffers and spatial chunks to rebuild across all active renderers.
- Live Telemetry Card: Real-time counter of total Renderers, Instances, Spatial Chunks, and estimated GPU memory footprint.
๐ฟ 3D V-Shape Keel Blades
Standard billboard ribbons appear paper-thin when viewed from angles. AA Grass Pro generates procedural 3D V-keel blades with true cross-sectional geometry:
- 3-Vertex Rows: Each height segment contains 3 vertices (Left Wing, Central Keel Spine, Right Wing).
- Central Fold Crease: The central spine is indented inward along the Z-axis (
-keelDepth), while outer wings flare outward. - Curvature Normals: Cylindrical outwards-angled normals (
-0.75, 0.25, 0.62and0.75, 0.25, 0.62) create soft, natural specular highlights and diffuse wrap.
โก Shadow Receiving (HDRP & URP)
Grass blades receive direct sunlight shadows and scene shadows from characters, vehicles, and structures:
| Feature | HDRP Implementation | URP Implementation |
|---|---|---|
| Sun Shadow Index | Resolves via _DirectionalShadowIndex dynamically | Samples Main Light shadow cascade attenuation |
| Two-Sided Normal Bias | Applies FastSign(dot(N, L)) normal bias flip | Aligns bias with light direction on double-sided geometry |
| Inspector Control | Receive Shadows checkbox in Rendering & Shadows | Receive Shadows checkbox in Rendering & Shadows |
๐ Hierarchical LOD & Blending
AA Grass Pro eliminates visible circular "pop" seams through a smooth 4-Tier Continuous LOD Pipeline.
Seamless Blending Mechanism
- Continuous Density Ramp: Blades transitioning out dissolve smoothly into the ground rather than abruptly popping off.
- Continuous Width Lerp: Surviving distant blades gradually widen to preserve visual screen coverage and foliage density.
- Deterministic Hash: Every instance has a stable pseudo-random ID so density transitions remain 100% stable regardless of camera movement.
LOD Settings
| Property | Range | Default | Description |
|---|---|---|---|
| Enable LOD | bool | true | Master toggle. When disabled, full LOD0 geometry renders at all distances. |
| Transition Range | 1.0 โ 20.0m | 6.0m | Distance over which density dissolving and width scaling smoothly blend. |
| LOD Distance 1 | 5 โ 100m | 30m | Near-to-mid range threshold. |
| LOD Distance 2 | 20 โ 200m | 60m | Mid-to-far range threshold. |
| LOD Distance 3 | 30 โ 300m | 90m | Far-to-billboard quad threshold. |
| Density Reductions | 0.0 โ 0.95 | 0.3 / 0.6 / 0.8 | Target cull fraction for each respective tier. |
๐ค Physics & Interaction
The interaction subsystem runs entirely on the GPU, handling up to 32 simultaneous interactors with true analytical mathematical collision.
Collider Classification
| Collider Type | GPU Representation | Interaction Behavior |
|---|---|---|
| Sphere | Center + Radius | Radial spherical displacement outward from impact center. |
| Capsule | Start + End Segment + Radius | Smooth cylindrical lateral displacement along character capsules. |
| Oriented Box | Center + Half-Extents + Forward | Directional flattening along moving vehicle chassis and boxes. |
| Wheel | Contact Patch + Radius | Aggressive tire compression track with high-friction push. |
Interaction Properties
| Property | Range | Default | Description |
|---|---|---|---|
| Enable Interaction | bool | true | Master switch for physics simulation. |
| Recovery Duration | 0.05 โ 5.0s | 0.25s | Time in seconds for flattened grass blades to elastically spring back upright. |
| Push Strength | 0.1 โ 3.0 | 1.0 | Max lateral displacement angle applied to pushed blades. |
| Height Threshold | 0.0 โ 2.0m | 0.8m | Vertical cutoff preventing overhead objects from leaving ground trails. |
| Map Size | 5 โ 100m | 30m | World-space footprint of the persistent interaction render texture around camera. |
| Map Resolution | 64 โ 2048 | 512 | Render texture resolution for continuous footprint/tire stamping. |
| Interaction Layers | LayerMask | Everything | Physics layer mask filtering interactable scene colliders. |
๐ฌ๏ธ Wind Simulation
Procedural noise-driven wind evaluated directly in the vertex stage without requiring scene WindZones.
| Property | Range | Default | Description |
|---|---|---|---|
| Enable Wind | bool | true | Master toggle. Bypasses vertex wind displacement when disabled. |
| Direction Object | Transform | Wind Direction | Grass leans in this transform's forward vector direction. |
| Wind Strength | 0.0 โ 3.0 | 0.8 | Base oscillation amplitude. |
| Wind Speed | 0.0 โ 8.0 | 2.0 | Wave propagation velocity across the field. |
| Turbulence | 0.0 โ 2.0 | 0.4 | High-frequency flutter added to blade tips. |
| Gust Strength & Freq | Various | 0.25 / 0.8 | Intermittent high-amplitude wind gusts sweeping across the scene. |
| Stiffness | 0.0 โ 1.0 | 0.6 | Root rigidity preventing blades from detaching from ground. |
๐ก Lighting & 3-Color Gradients
3-Tier Vertical Color Gradient
Blades sample a continuous vertical gradient across their height:
- Root Color: Dark ambient base anchoring the blade to the terrain surface.
- Mid Color: Body foliage tone representing primary chlorophyll pigmentation.
- Tip Color: Sun-lit, brighter blade tip capturing direct ambient illumination.
Lighting Properties
| Property | Default | Description |
|---|---|---|
| Dual-Sided Translucency | Enabled (0.85) | Simulates sunlight transmitting through thin grass membrane. |
| Rim Lighting | Enabled (0.40) | Fresnel rim glow toward direct sunlight. |
| Specular Highlight | Disabled (0.15) | Blinn-Phong specular shimmer for wet or waxy vegetation. |
| Full Detail Distance | 35m | Advanced lighting terms smoothly fade out past this distance to conserve fillrate. |
๐ท URP Shader
Shader: AA Grass Pro/Grass URP. Passes: ForwardLit, ShadowCaster, DepthOnly.
Fully compatible with Universal Render Pipeline Forward and Forward+ rendering paths, screen-space ambient occlusion (SSAO), and soft cascaded shadows.
๐ถ HDRP Shader & Volumetric Fog
Shader: AA Grass Pro/Grass HDRP. Passes: ForwardOnly, ShadowCaster, DepthForwardOnly.
Synchronized depth prepass ensures clean volumetric fog integration via HDRP's native OpaqueAtmosphericScattering pass.
HDRP Fog Best Practice: In your Volume Profile's Fog component, set Base Height slightly below your terrain level and Maximum Height comfortably above grass blade tops. Set Slice Distribution Uniformity between 0.7 and 0.85 to prevent visible voxel slice stepping across dense vegetation fields.
โก Performance & Hardware Scalability
Performance & Scalability Notice: Rendering performance, achievable instance counts, and framerates vary significantly based on your target hardware (GPU compute throughput, rasterization fillrate, VRAM bandwidth), screen resolution, active render pipeline (URP vs HDRP), shadow map distance, and scene lighting complexity. Rather than assuming static figures, tune the built-in Hierarchical LOD distance thresholds, density reduction ratios, blade segments, and view distance to achieve your desired performance profile on each target platform.
Hardware Scalability Guidelines
| Hardware Profile | Suggested Density Spacing | View Distance | Shadow Distance | LOD Transition |
|---|---|---|---|---|
| High-End Desktop / Current-Gen Consoles | Dense (0.03m โ 0.05m) | 120m โ 160m | 50m โ 80m | 6m (Full 4-tier LOD) |
| Mid-Range Desktop / Steam Deck / Last-Gen | Balanced (0.05m โ 0.08m) | 80m โ 100m | 30m โ 40m | 8m (Aggressive LOD2/3 reduction) |
| Mobile / Handheld / Integrated GPUs | Optimized (0.08m โ 0.12m) | 50m โ 70m | 15m โ 25m or Off | 10m (High density reduction) |
๐ Script API
GrassSystem API
| Member | Type | Description |
|---|---|---|
GrassSystem.Instance | static GrassSystem | Global singleton reference. |
ResetStyleSettings() | void | Resets style palette to Realistic. |
ResetGeometrySettings() | void | Resets blade segments, width, height, and curve. |
ResetColorSettings() | void | Resets realistic/stylized colors, dry patches, and variation. |
ResetLightingSettings() | void | Resets translucency, rim, specular, and curvature normals. |
ResetWindSettings() | void | Resets procedural wind amplitude, speed, gusts, and stiffness. |
ResetRenderingSettings() | void | Resets view distance, fade start, shadows, and frustum culling. |
ResetLODSettings() | void | Resets LOD distances and tier reduction ratios. |
ResetInteractionSettings() | void | Resets physics colliders, persistence, and resolution. |
ResetAllSettings() | void | Resets all system settings back to factory defaults. |
AutoAssignReferences() | void | Finds and binds compute shader and material assets (Editor). |
GrassRenderer API
| Member | Type | Description |
|---|---|---|
GrassDataAsset | GrassData | ScriptableObject storing per-surface instances. |
InstanceCount | int | Total number of grass instances on this surface. |
ChunkCount | int | Number of active 20m spatial chunks built. |
AllRenderers | static IReadOnlyList | All active renderers across the entire scene. |
UpdateBufferData() | void | Lightweight GPU re-upload during realtime painting. |
RefreshData() | void | Rebuilds spatial acceleration chunks and GPU indirect buffers. |
๐ Package File Structure
โโโ package.json โ Unity package manifest (v1.5.0)
โโโ README.md โ Package documentation & setup guide
โโโ Editor/
โ โโโ GrassGUI.cs โ Modernized UI toolkit (master toggles, cards, badges, reset all)
โ โโโ GrassPainter.cs โ Scene-view brush tool with surface isolation
โ โโโ GrassRendererEditor.cs โ Custom Inspectors for GrassSystem & GrassRenderer
โ โโโ GrassAutoSetup.cs โ GameObject menu automated scene creator
โ โโโ AA.GrassPro.Editor.asmdef
โโโ Runtime/
โ โโโ GrassSystem.cs โ Main orchestrator, culling dispatch, material binder
โ โโโ GrassRenderer.cs โ Per-surface chunk manager & instanced indirect draw calls
โ โโโ GrassData.cs โ ScriptableObject instance storage & GPU structs
โ โโโ GrassBladeMesh.cs โ Procedural 3D V-keel mesh generator with curvature normals
โ โโโ GrassInteractionMap.cs โ Multi-collider buffer manager & UV-shifted trail RT
โ โโโ AA.GrassPro.Runtime.asmdef
โโโ Shaders/
โ โโโ GrassCompute.compute โ GPU culling, continuous LOD blend, analytical collision
โ โโโ GrassProperties.hlsl โ CBUFFER material and instancing declarations
โ โโโ GrassLighting.hlsl โ BSDF dual-sided translucency, shadow receiving, rim, curvature
โ โโโ GrassCommon.hlsl โ Vertex transforms, wind dynamics, quad billboard
โ โโโ InteractionStamp.shader โ Analytical collider footprint stamping
โ โโโ InteractionFade.shader โ UV-offset blit with exponential elastic recovery
โ โโโ Grass.shader โ Core multi-pipeline grass shader
โ โโโ URP/
โ โ โโโ GrassURP.shader โ Dedicated Universal Render Pipeline shader
โ โโโ HDRP/
โ โโโ GrassHDRP.shader โ Dedicated High Definition Render Pipeline shader
โโโ Documentation/
โโโ index.html โ Official package documentation
โ FAQ & Troubleshooting
Q: Why does grass appear to dissolve smoothly instead of popping at distance?
This is the Continuous LOD transition blending. You can tune Transition Range in the Hierarchical LOD section if you want a tighter or broader transition zone.
Q: How do I test vehicle interaction with wheels?
Add colliders (such as WheelColliders, SphereColliders, or BoxColliders) to your vehicle. The GPU automatically detects their geometry type and applies directional push with elastic recovery.
Q: How do I prevent HDRP Volumetric Fog from creating harsh lines across the grass?
In your scene's Volume Profile, select the Fog component and set Base Height below the terrain and Maximum Height well above the grass. Increase Slice Distribution Uniformity to between 0.7 and 0.85 to smooth voxel slice transitions.
Q: Does my camera need to be tagged as MainCamera?
Tagging your active player/gameplay camera as MainCamera is recommended for standard Unity conventions. However, AA Grass Pro features an intelligent multi-fallback camera resolver that automatically detects active untagged cameras in the scene and seamlessly supports live Scene View inspection during Play Mode.
Q: How can I optimize performance on lower-spec devices?
Reduce View Distance (e.g. to 60mโ80m), increase LOD tier density reductions (e.g. 0.4, 0.7, 0.85), set Blade Segments to 3 or 4, and limit or disable shadow distance on grass blades.