The s&box rendering pipeline starts with aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/facepunch/sbox-public/llms.txt
Use this file to discover all available pages before exploring further.
CameraComponent, collects scene objects, runs them through the engine’s layered render passes, and finally applies post-processing effects. This page explains how each piece of the pipeline works and how you can hook into it from C#.
CameraComponent
CameraComponent is the component that drives rendering for a scene. Every active scene needs at least one. It wraps an internal SceneCamera and pushes the scene through the render pipeline each frame.
Key properties
| Property | Default | Description |
|---|---|---|
FieldOfView | 60 | Horizontal or vertical FOV in degrees (controlled by FovAxis). |
ZNear | 10 | Near clip plane. Values below 5 produce z-fighting artefacts. |
ZFar | 10000 | Far clip plane. Balance with ZNear for your game’s scale. |
IsMainCamera | true | Whether this camera is the primary game camera. |
Priority | 1 | Higher values render on top when multiple cameras are active. |
Orthographic | false | Switch to orthographic projection. Requires OrthographicHeight. |
Viewport | (0,0,1,1) | Normalised screen rect this camera renders into. |
RenderTags | empty | Include only objects with these tags. Empty = include all. |
RenderExcludeTags | empty | Exclude objects that have any of these tags. |
RenderTexture | null | Assign a RenderTextureAsset to render into a texture instead of the screen. |
Rendering to a texture
You can redirect a camera to render into anyTexture created as a render target.
CameraComponent.RenderToTexture to perform an immediate off-screen render without permanently redirecting the camera:
Coordinate helpers
CameraComponent has several helpers for converting between world space and screen space:
Post-processing
Post-processing is enabled by default (EnablePostProcessing = true). You can anchor the post-process volume lookup to a different position than the camera itself:
ClearFlags includes ClearFlags.Color.
The old render hook API (
AddHookAfterOpaque, AddHookAfterTransparent, etc.) is obsolete as of mid-2025. Use CommandList instead for custom render stages.RenderAttributes
RenderAttributes is a typed key-value store that passes data from C# to shaders. You set values in C# and read them in HLSL using the Attribute(...) annotation.
Setting values
Shader combos
Combos are compile-time shader permutations toggled at runtime:Reading values back
Accessing attributes inside a render pass
During a render callback,Graphics.Attributes gives you the current context’s attributes. Changes you make here persist only for the current render block:
Binding in HLSL
Graphics class
Graphics is a static class that exposes the active render context. It is only valid inside a render callback — accessing it outside one throws an exception.
Viewport and render target
Camera state
Frame and depth texture capture
You can grab a snapshot of the framebuffer or depth buffer and make it available to materials as a named attribute:Texture copy
Lighting setup
Primitive types
TheGraphics.PrimitiveType enum lists all supported draw topologies:
| Value | Description |
|---|---|
Points | Individual point sprites |
Lines | Disconnected line segments |
LineStrip | Connected line chain |
Triangles | Standard triangle list |
TriangleStrip | Triangle strip |
*WithAdjacency | Variants with geometry shader adjacency data |
Layer types
Graphics.LayerType tells you which render layer is currently executing. The engine calls render callbacks once per layer:
Next steps
Custom shaders
Write HLSL shaders, compute shaders, and ray-tracing shaders.
UI panels
Build screen and world-space UI with the Panel system.