How unitytechnologies/shadergraph_examplelibrary works
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