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.

URP & HDRP 3D V-Keel Geometry Shadow Receiving Analytical Physics Scalable GPU Instancing Unity 2022.3+ / Unity 6

๐Ÿš€ 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

  1. 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.

  2. Open Painter โ€” Click ๐ŸŽจ Open Painter in the Grass System Inspector or menu Window โ†’ AA Grass Pro โ†’ Grass Painter.

  3. Paint โ€” Left-click and drag across any surface with a Collider. A GrassRenderer is auto-spawned per unique surface.

  4. 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

ObjectPurpose
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.matUniversal instanced material configured for URP or HDRP.
GeneratedAssets/GrassData_{surface}.assetScriptableObject storing all serialized instances for persistence across sessions.

Platform & System Requirements

RequirementDetail
Unity Version2022.3 LTS, 2023.x, or Unity 6 (6000.x)
Render PipelinesUniversal Render Pipeline (URP) or High Definition Render Pipeline (HDRP)
Target HardwareCompute Shader support (Shader Model 4.5+ / DX11 / DX12 / Vulkan / Metal)
CollidersStandard Unity Collider attached to surfaces you wish to paint on

๐ŸŽจ Painting Grass

Viewport Controls

InputAction
Left-ClickPaint a single cluster at cursor position
Left-Click + DragSmooth continuous painting (throttled at ~30 ops/sec with 0.15m move delta)
Ctrl + Click / DragInstant eraser mode
Shift + ScrollDynamically adjust brush radius

Brush Properties

SettingRangeDefaultDescription
Radius0.1 โ€“ 202.0Brush influence radius in world units
Density1 โ€“ 10015Instances per stroke. Calculated as: ฯ€ ร— rยฒ ร— density ร— 0.1
Height Min / Max0.2 โ€“ 2.00.7 โ€“ 1.3Randomized vertical height scaling multiplier
Width Min / Max0.2 โ€“ 2.00.7 โ€“ 1.3Randomized horizontal blade width multiplier
LayersLayerMaskEverythingLayers 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

๐ŸŒฟ 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:

โšก Shadow Receiving (HDRP & URP)

Grass blades receive direct sunlight shadows and scene shadows from characters, vehicles, and structures:

FeatureHDRP ImplementationURP Implementation
Sun Shadow IndexResolves via _DirectionalShadowIndex dynamicallySamples Main Light shadow cascade attenuation
Two-Sided Normal BiasApplies FastSign(dot(N, L)) normal bias flipAligns bias with light direction on double-sided geometry
Inspector ControlReceive Shadows checkbox in Rendering & ShadowsReceive Shadows checkbox in Rendering & Shadows

๐Ÿ“Š Hierarchical LOD & Blending

AA Grass Pro eliminates visible circular "pop" seams through a smooth 4-Tier Continuous LOD Pipeline.

LOD 0
0โ€“30m (Full)
LOD 1
30โ€“60m (70%)
LOD 2
60โ€“90m (40%)
LOD 3 Quad
90m+ (20%)
Culled
> View Dist

Seamless Blending Mechanism

LOD Settings

PropertyRangeDefaultDescription
Enable LODbooltrueMaster toggle. When disabled, full LOD0 geometry renders at all distances.
Transition Range1.0 โ€“ 20.0m6.0mDistance over which density dissolving and width scaling smoothly blend.
LOD Distance 15 โ€“ 100m30mNear-to-mid range threshold.
LOD Distance 220 โ€“ 200m60mMid-to-far range threshold.
LOD Distance 330 โ€“ 300m90mFar-to-billboard quad threshold.
Density Reductions0.0 โ€“ 0.950.3 / 0.6 / 0.8Target 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 TypeGPU RepresentationInteraction Behavior
SphereCenter + RadiusRadial spherical displacement outward from impact center.
CapsuleStart + End Segment + RadiusSmooth cylindrical lateral displacement along character capsules.
Oriented BoxCenter + Half-Extents + ForwardDirectional flattening along moving vehicle chassis and boxes.
WheelContact Patch + RadiusAggressive tire compression track with high-friction push.

Interaction Properties

PropertyRangeDefaultDescription
Enable InteractionbooltrueMaster switch for physics simulation.
Recovery Duration0.05 โ€“ 5.0s0.25sTime in seconds for flattened grass blades to elastically spring back upright.
Push Strength0.1 โ€“ 3.01.0Max lateral displacement angle applied to pushed blades.
Height Threshold0.0 โ€“ 2.0m0.8mVertical cutoff preventing overhead objects from leaving ground trails.
Map Size5 โ€“ 100m30mWorld-space footprint of the persistent interaction render texture around camera.
Map Resolution64 โ€“ 2048512Render texture resolution for continuous footprint/tire stamping.
Interaction LayersLayerMaskEverythingPhysics layer mask filtering interactable scene colliders.

๐ŸŒฌ๏ธ Wind Simulation

Procedural noise-driven wind evaluated directly in the vertex stage without requiring scene WindZones.

PropertyRangeDefaultDescription
Enable WindbooltrueMaster toggle. Bypasses vertex wind displacement when disabled.
Direction ObjectTransformWind DirectionGrass leans in this transform's forward vector direction.
Wind Strength0.0 โ€“ 3.00.8Base oscillation amplitude.
Wind Speed0.0 โ€“ 8.02.0Wave propagation velocity across the field.
Turbulence0.0 โ€“ 2.00.4High-frequency flutter added to blade tips.
Gust Strength & FreqVarious0.25 / 0.8Intermittent high-amplitude wind gusts sweeping across the scene.
Stiffness0.0 โ€“ 1.00.6Root 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:

Lighting Properties

PropertyDefaultDescription
Dual-Sided TranslucencyEnabled (0.85)Simulates sunlight transmitting through thin grass membrane.
Rim LightingEnabled (0.40)Fresnel rim glow toward direct sunlight.
Specular HighlightDisabled (0.15)Blinn-Phong specular shimmer for wet or waxy vegetation.
Full Detail Distance35mAdvanced 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

Indirect
GPU Draw Calls
68 B
GPU Instance Stride
64 B
Collider Data Stride
Dynamic
4-Tier LOD Scaling
โ„น๏ธ

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 ProfileSuggested Density SpacingView DistanceShadow DistanceLOD Transition
High-End Desktop / Current-Gen ConsolesDense (0.03m โ€“ 0.05m)120m โ€“ 160m50m โ€“ 80m6m (Full 4-tier LOD)
Mid-Range Desktop / Steam Deck / Last-GenBalanced (0.05m โ€“ 0.08m)80m โ€“ 100m30m โ€“ 40m8m (Aggressive LOD2/3 reduction)
Mobile / Handheld / Integrated GPUsOptimized (0.08m โ€“ 0.12m)50m โ€“ 70m15m โ€“ 25m or Off10m (High density reduction)

๐Ÿ“˜ Script API

GrassSystem API

MemberTypeDescription
GrassSystem.Instancestatic GrassSystemGlobal singleton reference.
ResetStyleSettings()voidResets style palette to Realistic.
ResetGeometrySettings()voidResets blade segments, width, height, and curve.
ResetColorSettings()voidResets realistic/stylized colors, dry patches, and variation.
ResetLightingSettings()voidResets translucency, rim, specular, and curvature normals.
ResetWindSettings()voidResets procedural wind amplitude, speed, gusts, and stiffness.
ResetRenderingSettings()voidResets view distance, fade start, shadows, and frustum culling.
ResetLODSettings()voidResets LOD distances and tier reduction ratios.
ResetInteractionSettings()voidResets physics colliders, persistence, and resolution.
ResetAllSettings()voidResets all system settings back to factory defaults.
AutoAssignReferences()voidFinds and binds compute shader and material assets (Editor).

GrassRenderer API

MemberTypeDescription
GrassDataAssetGrassDataScriptableObject storing per-surface instances.
InstanceCountintTotal number of grass instances on this surface.
ChunkCountintNumber of active 20m spatial chunks built.
AllRenderersstatic IReadOnlyListAll active renderers across the entire scene.
UpdateBufferData()voidLightweight GPU re-upload during realtime painting.
RefreshData()voidRebuilds spatial acceleration chunks and GPU indirect buffers.

๐Ÿ“ Package File Structure

Assets/AA_GrassPro/
โ”œโ”€โ”€ 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.

AA Grass Pro โ€” Documentation v2.0  ยท  Abyssal Ababeel