# unity-technologies/postprocessing architecture

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

- Interactive diagram: https://gitdiagram.com/unity-technologies/postprocessing
- Repository: https://github.com/unity-technologies/postprocessing

## Overview

##### Main Components
- Runtime Effects & Systems: Located in “PostProcessing/Runtime”, this consists of the actual effect implementations, monitors (e.g., HistogramMonitor, VectorscopeMonitor), and logic that applies the post-process effects during game execution.
- Shaders: The “PostProcessing/Shaders” directory houses shader code for various effects (both Builtins and API-specific implementations). This module is key to the rendering pipeline, handling low-level graphics processing.
- Resources & Assets: You have configuration assets like “PostProcessResources.asset”, texture assets (under “PostProcessing/Textures”), and LUTs. These support the operation of both runtime and editor functionalities.
- Tests: There is a “Tests” directory that is divided into Editor and Runtime tests, ensuring that both components work as expected.

##### Relationships and Interactions
- The Editor tools (custom editors, decorators, attribute providers) provide the bridge between Unity’s Inspector UI and the post-processing settings. There is a clear separation: while the editor components help users design and adjust the effects, they instantiate or configure the Runtime components.
- Runtime components use the configured settings from profiles and volumes (e.g., PostProcessProfile, PostProcessVolume) and then execute effect renderers during actual frame rendering.
- Shaders interact with both runtime and resources; runtime systems call the shaders to perform the mathematical and graphic transformations to generate visual effects.
- The Resources (textures, LUTs, shader includes) are consumed by both runtime and editor functionalities to support the effects’ visual quality. Assembly definition files (.asmdef) define clear boundaries in the code and ensure proper modularity between the Editor and Runtime codebases.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project cleanly distinguishes between the Editor (development-time UI/UX) and Runtime (execution-time processing) components.
- Modularity: With distinct folders for Editor, Runtime, and Shaders (and further separation within each), the design promotes modularity and easier maintenance. The use of assembly definitions supports this modular design.
- Extensibility: The presence of attributes and decorators in the Editor implies that the design encourages extending or customizing effects (for example, through custom effect editors or decorators).
- Data Flow: Configuration (via profiles and volumes set in the Editor) flows into runtime processors which then interact with shaders and resources. This defines a clear pipeline from user input/configuration to final rendered output.

##### Technologies, Frameworks, and Libraries
- Unity 2018.3+ (as well as support for earlier versions) is central to the project.
- The project uses C# for both Editor and Runtime code.
- HLSL shader code in various formats (for different graphics APIs such as D3D11, Vulkan, Metal, etc.) is extensively used.
- The assembly definition files (.asmdef) reflect modern Unity practices, enforcing dependency boundaries between different parts of the code.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Editor Layer
    subgraph "Editor Layer"
        A["Editor Tools & UI"]:::editor
    end

    %% Runtime Layer
    subgraph "Runtime Layer"
        J["Post Process Manager"]:::runtime
        B["Runtime Post-processing Effects"]:::runtime
    end

    %% Shader Module
    subgraph "Shader Module"
        C["Shaders"]:::shader
    end

    %% Resources & Assets
    subgraph "Resources & Assets"
        G["Configuration Asset"]:::resource
        H["Texture & LUT Assets"]:::resource
    end

    %% Quality Assurance
    subgraph "Quality Assurance"
        I["Tests"]:::test
    end

    %% Relationships
    A -->|"configures"| J
    J -->|"coordinates"| B
    B -->|"calls"| C

    A ---|"loads"| G
    B ---|"utilizes"| G
    C ---|"requires"| G

    A ---|"loads"| H
    B ---|"utilizes"| H
    C ---|"requires"| H

    I -->|"tests"| A
    I -->|"tests"| B

    %% Click Events
    click A "https://github.com/unity-technologies/postprocessing/tree/v2/PostProcessing/Editor"
    click B "https://github.com/unity-technologies/postprocessing/tree/v2/PostProcessing/Runtime"
    click C "https://github.com/unity-technologies/postprocessing/tree/v2/PostProcessing/Shaders"
    click G "https://github.com/unity-technologies/postprocessing/blob/v2/PostProcessing/PostProcessResources.asset"
    click H "https://github.com/unity-technologies/postprocessing/tree/v2/PostProcessing/Textures"
    click I "https://github.com/unity-technologies/postprocessing/tree/v2/Tests"

    %% Styles
    classDef editor fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef runtime fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef shader fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef resource fill:#ffa07a,stroke:#333,stroke-width:2px;
    classDef test fill:#dda0dd,stroke:#333,stroke-width:2px;
```
