menu_bookDocumentation
Post Processing System
Post Processing System
Add visual effects like bloom, tonemapping, and film grain with post-processing volumes.
Overview
Post processing in s&box uses a volume-based system:
- PostProcessVolume components define effect regions
- BasePostProcess shaders create custom effects
- Effects blend based on volume weight and priority
Creating Custom Effects
Inherit from BasePostProcess<T>:
CSHARP
public sealed class MyBrightnessEffect : BasePostProcess<MyBrightnessEffect>
{
[Property, Range(-1, 1)]
public float Brightness { get; set; }
public override void Render()
{
// Apply post-processing shader
var shader = Material.Load("materials/postprocess/brightness.vmat");
shader.SetFloat("brightness", Brightness);
Graphics.Blit(shader);
}
}PostProcessVolume
Control where effects apply:
CSHARP
public class BrightnessVolume : PostProcessVolume
{
public MyBrightnessEffect Effect { get; set; }
protected override void OnUpdate()
{
// Update effect parameters
Effect.Brightness = CalculateBrightnessForPosition(WorldPosition);
}
}Volume Properties
| Property | Purpose |
|---|---|
| Priority | Higher priority volumes override lower ones |
| Weight | 0-1 blend factor for this volume's effects |
| IsGlobal | Apply to entire scene regardless of position |
Blending Effects
Multiple volumes blend together:
CSHARP
// Volume A: Bloom in one area
// Volume B: Tonemapping in another
// Where they overlap: Both effects apply with blended weightsBuilt-in Effects
Common post-processing effects available:
| Effect | Description |
|---|---|
| Bloom | Glow around bright areas |
| Tonemapping | HDR to LDR color mapping |
| Film Grain | Cinematic noise texture |
| Chromatic Aberration | RGB channel separation at edges |
| Vignette | Darkening at screen edges |
| Motion Blur | Blur based on camera movement |
| Depth of Field | Focus-based blur |
| Color Grading | LUT-based color correction |
Performance Tips
- Minimize overlapping volumes
- Use lower resolution effects for distant areas
- Disable effects when not visible
- Combine multiple effects into single shader when possible
- Use IsGlobal = false for localized effects
Was this helpful?