# lgabellini1/ue5-custom-grass-plugin architecture

> Architecture diagram of the GitHub repository lgabellini1/ue5-custom-grass-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lgabellini1/ue5-custom-grass-plugin
- Repository: https://github.com/lgabellini1/ue5-custom-grass-plugin

## Overview

1. **Project shape**
   - This is an **Unreal Engine 5 plugin** named `CustomGrass`, not a standalone app.
   - The repo is organized around a single runtime module in `Source/CustomGrass` plus a small shader bundle in `Shaders/`.

2. **Primary purpose**
   - The plugin implements a **custom procedural grass system for landscapes**.
   - It hooks into the **UE5 rendering pipeline** directly, rather than using only high-level gameplay objects or standard foliage tooling.

3. **Top-level module boundary**
   - `CustomGrass.Build.cs` defines the module’s UE dependencies and is the main boundary between this plugin and the engine.
   - `CustomGrass.cpp` / `CustomGrass.h` are the module entry points that register the plugin’s runtime behavior.

4. **Gameplay/runtime orchestration**
   - `CustomGrassWorldSubsystem` is the system-level coordinator that likely lives per-world and manages grass lifecycle for a loaded level.
   - `CustomGrassSettings` provides configuration/state for the system, while `CustomGrassDataAsset` suggests authoring data for grass behavior or appearance.
   - These pieces form the **non-rendering control plane** of the plugin.

5. **Scene integration**
   - `CustomGrassPrimitiveComponent` is the bridge from gameplay/world data into the renderer.
   - It likely creates and owns the renderable representation of the grass, exposing the component to the engine’s actor/component framework.
   - This is the main boundary where grass becomes a scene object that the renderer can consume.

6. **Render proxy boundary**
   - `CustomGrassSceneProxy` is the key rendering-side abstraction.
   - In Unreal, the scene proxy is the per-scene-thread render representation of a component, so this is where the plugin crosses from game-thread ownership into render-thread rendering.
   - `CustomGrassSceneProxy.h/.cpp` are therefore central to the architecture diagram.

7. **Custom geometry/shader path**
   - `CustomGrassVertexFactory` is the low-level integration point that tells UE how to feed grass vertex data into the GPU pipeline.
   - This strongly suggests the plugin does not rely on standard mesh rendering alone; it defines its own vertex layout/streaming path for procedural grass.
   - The vertex factory is likely consumed by custom shaders in `Shaders/VertexFactory.ush` and `Shaders/VertexShader.ush`.

8. **Shader subsystem**
   - The `Shaders/` folder contains UE shader source files:
     - `Shared.ush` for common shader code,
     - `VertexFactory.ush` for vertex input/format logic,
     - `VertexShader.ush` for vertex-stage behavior,
     - `Compute.usf` for compute-shader work.
   - This indicates a split between **compute-driven data generation** and **GPU rendering of grass blades**.

9. **Data flow through the system**
   - Typical flow is: world/subsystem configures grass rules and data assets -> primitive component creates scene representation -> scene proxy submits render resources -> vertex factory and shaders draw the grass.
   - The compute shader likely participates earlier in the pipeline to generate, cull, or prepare grass instances before the final draw.

10. **Runtime vs render responsibilities**
   - The plugin is structured around UE’s standard thread boundary:
     - **Game/world side**: subsystem, settings, data asset, primitive component.
     - **Render side**: scene proxy, vertex factory, shader code.
   - This separation is important for diagramming because most architecture decisions hinge on which side owns state and which side consumes it.

11. **Platform and engine context**
   - The README states development targeted **Unreal Engine 5.7 on Windows 11**.
   - The design is therefore tightly coupled to UE’s modern rendering architecture and is not intended to be engine-agnostic.

12. **Maturity/usage scope**
   - The README explicitly says this is a **personal learning/showcase project**, not a polished public plugin.
   - For an architecture diagram, treat it as a focused experimental subsystem with a narrow domain: procedural landscape grass rendering.

13. **What to emphasize in a diagram**
   - Show one clear chain from **world/system configuration** to **component ownership** to **render proxy** to **custom vertex factory + shaders**.
   - Also show the **compute shader path** as a supporting GPU processing stage feeding the final grass rendering.

Main entry points: [`Source/CustomGrass/Private/CustomGrassVertexFactory.cpp`](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassVertexFactory.cpp) (Vertex factory), [`Source/CustomGrass/Private/CustomGrassPrimitiveComponent.cpp`](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassPrimitiveComponent.cpp) (Grass component), [`Source/CustomGrass/Private/CustomGrassWorldSubsystem.cpp`](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassWorldSubsystem.cpp) (World subsystem), [`Source/CustomGrass/Private/CustomGrass.cpp`](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrass.cpp) (Plugin module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Game / World"]
  node_node_build["Module build<br/>UE build module"]
  node_node_module["Plugin module<br/>UE runtime module<br/>[CustomGrass.cpp]"]
  node_node_module_hdr["Module API<br/>module header<br/>[CustomGrass.h]"]
  node_node_subsystem["World subsystem<br/>world coordinator"]
  node_node_settings["Settings<br/>config object"]
  node_node_dataasset["Grass data<br/>authoring asset"]
  node_node_component["Grass component<br/>scene component"]
  node_node_component_hdr["Component API<br/>component header"]
end

subgraph group_group_render["Render Path"]
  node_node_proxy["Scene proxy<br/>render proxy"]
  node_node_proxy_hdr["Proxy API<br/>proxy header"]
  node_node_vf["Vertex factory<br/>GPU input"]
  node_node_vf_hdr["VF API<br/>vertex factory header"]
end

subgraph group_group_shaders["Shaders"]
  node_node_shared["Shared shader<br/>shader common<br/>[Shared.ush]"]
  node_node_vf_shader["VF shader<br/>shader include<br/>[VertexFactory.ush]"]
  node_node_vs["Vertex shader<br/>shader stage<br/>[VertexShader.ush]"]
  node_node_compute["Compute pass<br/>compute shader<br/>[Compute.usf]"]
end

node_node_build -->|"builds"| node_node_module
node_node_module -->|"registers"| node_node_subsystem
node_node_module -->|"exposes"| node_node_component
node_node_subsystem -->|"configures"| node_node_settings
node_node_subsystem -->|"consumes"| node_node_dataasset
node_node_subsystem -->|"spawns"| node_node_component
node_node_settings -->|"drives"| node_node_component
node_node_dataasset -->|"feeds"| node_node_component
node_node_component -->|"creates"| node_node_proxy
node_node_component_hdr -->|"declares"| node_node_component
node_node_proxy_hdr -->|"declares"| node_node_proxy
node_node_proxy -->|"binds"| node_node_vf
node_node_vf_hdr -->|"declares"| node_node_vf
node_node_vf -->|"includes"| node_node_shared
node_node_vf -->|"drives"| node_node_vf_shader
node_node_vf -->|"feeds"| node_node_vs
node_node_compute -.->|"prepares"| node_node_vf
node_node_compute -.->|"supports"| node_node_vs

click node_node_build "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/CustomGrass.Build.cs"
click node_node_module "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrass.cpp"
click node_node_module_hdr "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Public/CustomGrass.h"
click node_node_subsystem "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassWorldSubsystem.cpp"
click node_node_settings "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassSettings.cpp"
click node_node_dataasset "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Public/CustomGrassDataAsset.h"
click node_node_component "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassPrimitiveComponent.cpp"
click node_node_component_hdr "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Public/CustomGrassPrimitiveComponent.h"
click node_node_proxy "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassSceneProxy.cpp"
click node_node_proxy_hdr "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassSceneProxy.h"
click node_node_vf "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassVertexFactory.cpp"
click node_node_vf_hdr "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassVertexFactory.h"
click node_node_shared "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/Shared.ush"
click node_node_vf_shader "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/VertexFactory.ush"
click node_node_vs "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/VertexShader.ush"
click node_node_compute "https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/Compute.usf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_build,node_node_module,node_node_module_hdr,node_node_subsystem,node_node_settings,node_node_dataasset,node_node_component,node_node_component_hdr toneBlue
class node_node_proxy,node_node_proxy_hdr,node_node_vf,node_node_vf_hdr toneAmber
class node_node_shared,node_node_vf_shader,node_node_vs,node_node_compute toneMint
```

## Components

### Game / World

World-side orchestration and authoring data.

- [Module build](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/CustomGrass.Build.cs): UE build module · Defines engine dependencies and plugin module boundary. · `Source/CustomGrass/CustomGrass.Build.cs`
- [Plugin module](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrass.cpp): UE runtime module · Module entry point that registers runtime behavior. · `Source/CustomGrass/Private/CustomGrass.cpp`
- [Module API](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Public/CustomGrass.h): module header · Public module declarations and exported interface. · `Source/CustomGrass/Public/CustomGrass.h`
- [World subsystem](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassWorldSubsystem.cpp): world coordinator · Per-world runtime coordinator for grass lifecycle. · `Source/CustomGrass/Private/CustomGrassWorldSubsystem.cpp`
- [Settings](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassSettings.cpp): config object · Runtime configuration for grass behavior and tuning. · `Source/CustomGrass/Private/CustomGrassSettings.cpp`
- [Grass data](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Public/CustomGrassDataAsset.h): authoring asset · Authoring data for grass appearance or rules. · `Source/CustomGrass/Public/CustomGrassDataAsset.h`
- [Grass component](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassPrimitiveComponent.cpp): scene component · Bridge from world data into the renderer. · `Source/CustomGrass/Private/CustomGrassPrimitiveComponent.cpp`
- [Component API](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Public/CustomGrassPrimitiveComponent.h): component header · Public declarations for the grass component. · `Source/CustomGrass/Public/CustomGrassPrimitiveComponent.h`

### Render Path

Scene-thread and GPU rendering integration.

- [Scene proxy](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassSceneProxy.cpp): render proxy · Per-scene render representation of the grass component. · `Source/CustomGrass/Private/CustomGrassSceneProxy.cpp`
- [Proxy API](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassSceneProxy.h): proxy header · Render-side proxy declarations and interface. · `Source/CustomGrass/Private/CustomGrassSceneProxy.h`
- [Vertex factory](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassVertexFactory.cpp): GPU input · Defines custom vertex streams and GPU input layout. · `Source/CustomGrass/Private/CustomGrassVertexFactory.cpp`
- [VF API](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Source/CustomGrass/Private/CustomGrassVertexFactory.h): vertex factory header · Vertex factory declarations used by the render path. · `Source/CustomGrass/Private/CustomGrassVertexFactory.h`

### Shaders

Custom shader sources used by the plugin.

- [Shared shader](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/Shared.ush): shader common · Common shader code shared across the grass pipeline. · `Shaders/Shared.ush`
- [VF shader](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/VertexFactory.ush): shader include · Vertex factory shader logic and input mapping. · `Shaders/VertexFactory.ush`
- [Vertex shader](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/VertexShader.ush): shader stage · Vertex-stage behavior for rendering grass blades. · `Shaders/VertexShader.ush`
- [Compute pass](https://github.com/lgabellini1/ue5-custom-grass-plugin/blob/main/Shaders/Compute.usf): compute shader · GPU preprocessing for generation, culling, or setup. · `Shaders/Compute.usf`

## Connections

- Module build → Plugin module: builds · Build rules define the runtime module boundary.
- Plugin module → World subsystem: registers · Module startup enables world-level grass orchestration.
- Plugin module → Grass component: exposes · Module provides the scene component integration point.
- World subsystem → Settings: configures · Subsystem uses settings to control runtime behavior.
- World subsystem → Grass data: consumes · Subsystem reads authoring data for grass rules and appearance.
- World subsystem → Grass component: spawns · World logic creates component-backed grass representation.
- Settings → Grass component: drives · Configuration affects component setup and updates.
- Grass data → Grass component: feeds · Authoring data is turned into scene-facing grass state.
- Grass component → Scene proxy: creates · Component hands off render ownership to a scene proxy.
- Component API → Grass component: declares · Public component interface backs the runtime implementation.
- Proxy API → Scene proxy: declares · Proxy header defines the render-side abstraction.
- Scene proxy → Vertex factory: binds · Scene proxy binds the custom GPU input path.
- VF API → Vertex factory: declares · Vertex factory header supports the render implementation.
- Vertex factory → Shared shader: includes · Vertex factory logic reuses common shader code.
- Vertex factory → VF shader: drives · Vertex factory feeds its shader-side input contract.
- Vertex factory → Vertex shader: feeds · Custom vertex streams are consumed by the vertex shader stage.
- Compute pass → Vertex factory: prepares · Compute work can generate or cull data used by the draw path.
- Compute pass → Vertex shader: supports · Compute preprocessing supports final vertex-stage rendering.
