# qianmo/x-postprocessing-library architecture

> Architecture diagram of the GitHub repository qianmo/x-postprocessing-library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qianmo/x-postprocessing-library
- Repository: https://github.com/qianmo/x-postprocessing-library

## Overview

##### Project type and purpose
- Type: Unity engine extension / open-source post-processing effects library.

A. Unity Editor & Play Mode
- The central “host” application.
B. Built-in PostProcessing Stack v2
- Lives under Assets/PostProcessing-2
- Provides the pipeline and base classes.
C. XPL Package (Assets/X-PostProcessing)
1. Editor Extensions
- Editor scripts (.cs under Editor folder)
- Adds “Add effect…” menu items, effect custom inspectors.
2. Runtime Code
- Effect Settings & Renderers (.cs under Runtime folder)
- ParameterOverride, Utils, PostProcessBundle, Manager.
3. Shaders
- GPU code (.hlsl, .shader under Shaders folder)
4. Effects
- Individual effect folders (e.g. GaussianBlur, GlitchRGBSplitV5…)
- Each has C# setting, editor UI, and shader asset.
5. Utility & Profiles
- Utility helper classes, sample profiles (.asset).
D. Example Scene
- Assets/Example/ExampleScene.unity
- Demonstrates a PostProcessVolume with an XPL profile.
E. External Dependencies
- Unity engine runtime
- GPU (to run shaders)

##### Relationships & Data flows
1. Editor side:
- Unity Editor → Editor Extensions (menu/UI) → modifies ScriptableObject profiles.
2. Build/Play:
- Example Scene contains a PostProcessVolume → holds a PostProcessProfile asset.
- PostProcessing Stack v2 runtime pipeline → invokes XPL Runtime Code:
- Reads Effect Settings → instantiates corresponding EffectRenderer.
- EffectRenderer dispatches GPU shader passes.
- GPU executes Shaders → writes to camera render target.
3. Utility classes support both Editor and Runtime.

##### Architectural patterns & principles
- Plugin architecture: clear Editor vs. Runtime separation.
- ScriptableObject-based configuration (profiles & settings).
- Dependency injection into Unity’s existing PostProcessing pipeline.
- Modular effect sub-folders for extensibility.

##### Detailed elements
- Unity Editor (blocks: Editor UI, Play Mode).
- Assets/PostProcessing-2 (pipeline provider).
- Assets/X-PostProcessing:
- Editor folder (menu & inspectors).
- Runtime folder (effect logic).
- Shaders folder (GPU code).
- Effects sub-folders.
- Utility + Profiles.
- ExampleScene.unity → demonstrates usage.
- How Profile → Runtime Code → Shader → GPU → Framebuffer.
- How Editor Extensions → Profiles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Host
    UE["Unity Editor & Play Mode"]:::unity

    %% Example Scene
    EXS["Example Scene (ExampleScene.unity)"]:::example
    click EXS "https://github.com/qianmo/x-postprocessing-library/blob/master/Assets/Example/ExampleScene.unity"

    %% PostProcessing Stack v2
    PPS["PostProcessing Stack v2"]:::unity
    click PPS "https://github.com/qianmo/x-postprocessing-library/tree/master/Assets/PostProcessing-2/"

    %% XPL Package Container
    subgraph "X-PostProcessing Package"
        direction TB
        XE["XPL Editor Extensions"]:::editor
        click XE "https://github.com/qianmo/x-postprocessing-library/tree/master/Assets/X-PostProcessing/Editor/"

        SUB1["Effects Subfolder"]:::editor
        click SUB1 "https://github.com/qianmo/x-postprocessing-library/tree/master/Assets/X-PostProcessing/Effects/GaussianBlur/Editor/"

        XR["XPL Runtime Code"]:::runtime
        click XR "https://github.com/qianmo/x-postprocessing-library/tree/master/Assets/X-PostProcessing/Utility/"

        XS["XPL Shaders"]:::shaders
        click XS "https://github.com/qianmo/x-postprocessing-library/tree/master/Assets/X-PostProcessing/Shaders/"

        PROF["Utility & Profiles"]:::profiles
        click PROF "https://github.com/qianmo/x-postprocessing-library/blob/master/Assets/X-PostProcessing/Profiles/X-PostProcessing ExampleProfiles.asset"
    end

    %% GPU
    GPU["GPU Shader Execution"]:::gpu

    %% Flows
    UE -->|"UI Menu Actions"| XE
    XE -->|"creates/edits"| PROF
    EXS -->|"uses Profile"| PROF
    EXS -->|"runs Pipeline"| PPS
    PPS -->|"invokes Effects"| XR
    PROF -->|"loads Settings"| XR
    XR -->|"dispatches Shader Passes"| XS
    XS -->|"executes on"| GPU

    %% Styling
    classDef unity fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef editor fill:#90EE90,stroke:#333,stroke-width:1px
    classDef runtime fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef shaders fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef example fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef profiles fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef gpu fill:#FFA500,stroke:#333,stroke-width:1px
```
