How unity-technologies/postprocessing works
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.