# unitytechnologies/shadergraph_examplelibrary architecture

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

- Interactive diagram: https://gitdiagram.com/unitytechnologies/shadergraph_examplelibrary
- Repository: https://github.com/unitytechnologies/shadergraph_examplelibrary

## Overview

##### Project Type and Purpose
- This is a Unity “example library” of Shader Graph assets, Materials, Textures, Scenes, and one C# script.
- Its purpose is to demonstrate custom shaders (for mesh renderers, particles, sprites, procedural patterns, scenarios) under Unity’s Lightweight Scriptable Render Pipeline (LWRP).

##### Main Architectural Components
a. Unity Editor & Project Settings
b. Package Manager & Render Pipeline (LWRP)
c. Asset Folders (under Assets/)
– ShaderGraphs (the source .ShaderGraph assets)
– Materials (Materials that reference compiled shader code)
– Textures & Sprites & Models (inputs for Materials)
– Scenes (ExampleScene-*: collections of GameObjects with MeshRenderers, ParticleSystems, SpriteRenderers)
– Scripts (ToonShaderLightSettings)
d. Runtime Render Pipeline
– Graph Compiler (ShaderGraph → HLSL)
– Lightweight Render Pipeline asset (LightweightAsset.asset)
e. Output (Game View / Player)

##### Relationships & Data Flow
1. ShaderGraphs are edited in the Unity Editor → on Save they compile to HLSL shaders.
3. Scenes contain GameObjects with Components (MeshRenderer, ParticleSystem, SpriteRenderer) that reference Materials.
4. At playtime, the LWRP asset (from Packages/manifest.json) drives the render loop, consuming GameObjects & their Materials to produce the final frame.
5. The C# script (ToonShaderLightSettings.cs) can adjust lighting parameters at runtime.

##### Architectural Patterns & Principles
- Asset-Pipeline pattern: source assets (ShaderGraphs, Textures) → compiled assets (Shaders) → Materials → Render components.
- Separation of concerns:
– Shader creation (ShaderGraphs)
– Material configuration
– Scene composition
– Render pipeline orchestration
- Extensibility: users can drop new ShaderGraph files into the ShaderGraphs folder and hook them into new materials/scenes.

- “Assets/Materials” referencing Shader Library + “Assets/Textures”
- “Assets/Scenes” with GameObject→Renderer components pointing to Materials
- “Packages/Lightweight RP” + “ProjectSettings/GraphicsSettings” → runs the render loop
- Output: Game View / Player

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Project Setup
    subgraph "Project Setup"
        UE["Unity Editor & Project Settings"]:::editor
        PM["Package Manager Configuration"]:::editor
        GS["ProjectSettings/GraphicsSettings"]:::editor
    end

    %% Assets Folders
    subgraph "Assets"
        SG["Assets/ShaderGraphs"]:::asset
        MA["Assets/**/Materials"]:::asset
        TA["Assets/Textures & Assets/**/Textures"]:::asset
        SC["Assets/Scenes/*.unity"]:::asset
        SS["Assets/Scripts/ToonShaderLightSettings.cs"]:::asset
        RPAsset["Assets/Render Pipelines/LightweightAsset.asset"]:::asset
    end

    %% Runtime Systems
    subgraph "Runtime"
        SCMP["Shader Compiler"]:::compiler
        SL["Shader Library (HLSL binaries)"]:::compiler
        RL["Lightweight Render Pipeline Runtime"]:::runtime
        RLC["Runtime Lighting Config"]:::runtime
    end

    %% Output
    GV["Game View / Player"]:::output

    %% Connections
    UE -->|opens & edits| SG
    SG -->|on Save triggers| SCMP
    SCMP -->|compiles to HLSL| SL
    SL -->|used by| MA
    TA -->|input for| MA
    MA -->|assigned to| SC
    SC -->|contains GameObjects| RL
    PM -->|defines LWRP package| RL
    GS -->|configures graphics| RL
    RPAsset -->|loaded by| RL
    SS -->|adjusts lighting| RLC
    RLC -->|influences| RL
    RL -->|renders frame to| GV

    %% Click Events
    click UE "https://github.com/unitytechnologies/shadergraph_examplelibrary/tree/master/ShaderGraph_ExampleLibrary_Project/ProjectSettings"
    click PM "https://github.com/unitytechnologies/shadergraph_examplelibrary/blob/master/ShaderGraph_ExampleLibrary_Project/Packages/manifest.json"
    click GS "https://github.com/unitytechnologies/shadergraph_examplelibrary/blob/master/ShaderGraph_ExampleLibrary_Project/ProjectSettings/GraphicsSettings.asset"
    click SG "https://github.com/unitytechnologies/shadergraph_examplelibrary/tree/master/ShaderGraph_ExampleLibrary_Project/Assets/ShaderGraphs"
    click MA "https://github.com/unitytechnologies/shadergraph_examplelibrary/tree/master/ShaderGraph_ExampleLibrary_Project/Assets/**/Materials"
    click TA "https://github.com/unitytechnologies/shadergraph_examplelibrary/tree/master/ShaderGraph_ExampleLibrary_Project/Assets/Textures"
    click SC "https://github.com/unitytechnologies/shadergraph_examplelibrary/blob/master/ShaderGraph_ExampleLibrary_Project/Assets/Scenes/*.unity"
    click SS "https://github.com/unitytechnologies/shadergraph_examplelibrary/blob/master/ShaderGraph_ExampleLibrary_Project/Assets/Scripts/ToonShaderLightSettings.cs"
    click RPAsset "https://github.com/unitytechnologies/shadergraph_examplelibrary/blob/master/ShaderGraph_ExampleLibrary_Project/Assets/Render Pipelines/LightweightAsset.asset"

    %% Styles
    classDef editor fill:#FFD700,stroke:#333,stroke-width:1px
    classDef asset fill:#ADFF2F,stroke:#333,stroke-width:1px
    classDef compiler fill:#FFA500,stroke:#333,stroke-width:1px
    classDef runtime fill:#00CED1,stroke:#333,stroke-width:1px
    classDef output fill:#FF4500,stroke:#333,stroke-width:1px
```
