s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentation
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Documentation

s&box documentation

All 235 official developer docs across 19 topics — the real, current reference, organized for browsing.

Every page below mirrors the official Facepunch s&box documentation, kept in sync from the source repo and licensed CC-BY-4.0. Each page links back to its canonical source. Use this as a fast, searchable index of how to actually build in s&box — in C#, with the scene system, the editor tools, and the engine.

ActionGraph 9Animation 1Assets 19Code 13Editor 17Exporting 2Game Mounts 2Gameplay 20Getting Started 13Media 3Movie Maker 11Networking 18Overview 1Physics 4Rendering 57Scene 28Services 6Sound 2UI 9

ActionGraph

Action Resources

You can create your own nodes by making a .action game resource.

ActionGraph

ActionGraph is a visual scripting system that lets you create game logic using nodes instead of code. Connect nodes together to build behaviors, respond to events, and control your scene, all from a graphical editor.

C# Method Nodes

Making a custom node in C is as easy as writing a static method with a special \[ActionGraphNode( id )\] attribute. You should also add \[Pure\] if you want your node to be an expression node - a node without signals.

Component Actions

The easiest way to add an ActionGraph to your scene is through the Actions Invoker component. Just click Add Component on an object, then you can find it under Actions.

Custom Nodes

There are two ways to create your own node types:

Examples

Here's how to do some common things. Each has a code you can copy to your clipboard, then Ctrl+V to paste in the ActionGraph editor.

Getting Started

ActionGraph is a visual scripting language. Each node describes an action or expression, and links between nodes carry values or signals.

Using With C#

Here's how you can use ActionGraph with your game code written in C.

Variables

Variables are useful for making your graph easier to understand, cleaning up link spaghetti, and when performing calculations in loops.

Animation

Animation

S&box uses Valve's Animgraph system for character animation, providing a powerful node-based animation state machine. The system supports skeletal animation, IK, animated ragdolls, morph targets, and animation events.

Assets

Assets

Assets are the building blocks of your game: models, materials, sounds, textures, and custom resources. S&box provides tools for creating, importing, managing, and distributing assets.

Binary Serialization

If you find your JSON files growing too large, you can store data as a binary blob instead. This works with anything that serializes to JSON.

Citizen Characters

All source files come with the game: VMDLs, FBXs, animgraphs, etc.

Clothing

Create, skin, and publish cosmetic clothing items for the Citizen character model.

Cloud Assets

There is a large selection of Assets (Textures, Models, Sounds, etc) available to use on sbox.game, and you can use them without needing to think about downloading the files/mounting the content/etc.

Custom Assets

You can define your own custom asset types as GameResources. They give you a nice inspector window and they're hotloaded in-game, which means you can whip things up pretty quickly if you're using them.

File System

Standard .NET file access is restricted to prevent rogue access to your files, this means you can not use System.IO.File or variants directly.

First Time Setup

Open S&box and make a new project. You can select 'Addon' as your template since we're only going to publish a model.

First-Person Weapons

Facepunch provides some ready-to-use first-person weapons for you!

GameResource Extensions

ResourceExtensions can be used to append additional data to existing GameResources without modifying the original class or assets. This is useful for adding additional properties to resources such as Clothing, Surfaces, Models, etc.

Guidelines & Quality Bar

These quality guidelines will help you through the process of creating clothing that stands a better chance of being accepted for sale on the s&box store.

Layering Clothing

In S&box, we want a library of clothing that all fit together, resulting in hundreds, thousands of outfit combinations.

Making a Hat

A somewhat simple set-up compared to other clothing pieces, with less concern of layering with other clothing. This is a simple asset to rig and is easy to make a human version.

Morphing to Humans

Dependant on how complex / simple your model is, morphing to the human mesh can be very straightforward.

Naming Conventions

The editor can automatically assign the textures in a Material as long as they follow the naming conventions below.

Publishing Clothing

First, you'll need a fully set up .Clothing file. This is where we store our VMDLs and certain logic so your clothing works correctly.

Ready-to-use Assets

Pages documenting some of the assets we're providing to you.

Resources

Custom asset types, cloud assets, serialization, and GameResource extensions.

Storage (UGC)

The Storage system provides a simple, unified way to manage user-generated content in your game. Whether you're saving game progress, storing player creations, or anything else, Storage handles everything from local file management to Steam Workshop integration.

Code

Advanced Topics

Wrap methods and properties with the [CodeGenerator] attribute. This is the mechanism behind RPCs and networked variables.

Api Whitelist

We prevent access to classes and functions that could be used maliciously by whitelisting what can be used.

Cheat Sheet

Sometimes you know what you're looking for, but you don't know where it is.

Code

S&box games are written in C. The engine features a hotload system that compiles and applies your code changes within milliseconds, so you can iterate without restarting.

Code Basics

The essentials for writing C in s&box.

Code Generation

s&box has a [CodeGenerator] attribute that you can use to decorate another attribute specifically for use with methods and properties. It lets you wrap methods and properties to perform some other action when the method is called or the property is set or to return a different va

Console Variables

You can create variables and commands that you can run from the console.

Hotloading

Whenever you save a code file in your project (.cs or .razor files), we recompile and attempt to live-reload the changed assembly. This lets you quickly iterate and see your changes without needing to restart the editor. Ideally we want to support this for 99% of code changes wit

IsValid

Destroying a GameObject or Component doesn't erase the C reference. Any variable that was pointing to it still holds a non-null object - it's just a dead one. Accessing its properties will do nothing useful or throw an exception.

Libraries

Libraries can be used to create self-contained code and assets that you can reuse in multiple projects. These can be shared with your organisation or with the whole community.

Math Types

A Vector is just a set of numbers that describe a position or a direction in space.

Time

s&box provides a set of utilities for working with time in your game. These let you write things like cooldowns, countdowns, and frame-rate independent movement cleanly and without manual bookkeeping.

Unit Tests

If you add a UnitTests directory to your project folder, we will automatically generate a Unit Test project for you. In order for the project to be generated you need to restart your editor if you have it open.

Editor

Asset Previews

If you want a specific file/asset type to have a custom Thumbnail/Inspector Preview, you can simply create an AssetPreview. An AssetPreview initializes its own Scene and Camera, rendering the Camera to the Preview output, so all you need to do is populate it and/or position the C

Component Editor Tools

Component Editor Tools work a lot like regular Editor Tools, but they're always active when a specific Component is selected. These tools generally create UI in the scene view, but they can also override input too.

Custom Editors

When creating your own Classes/Structs/Assets/etc, you'll sometimes want custom editors that pair with them. For example, a Gradient Editor so you can visually see what the Gradient looks like instead of editing the Gradient as if it were a Struct with a list of Colours.

Editor

The s&box editor is your workspace for building games: scene editing, asset management, visual scripting, and more.

Editor Apps

Editor Apps are apps that run in the editor. They generally have their own window. They're sometimes used to edit specific types of asset.

Editor Events

Editor Events are events that are broadcast globally throughout the editor and can be listened to/fired from any Editor Project. These are useful for creating your own custom Editor Tools and making sure they can work in tandem with existing systems.

Editor Project

Your game can have an editor component to it. Your game's editor project is special in that it can access both the tools and the game code.

Editor Shortcuts

When creating a Tool or Editor Project, it's common to want to be able to trigger certain actions with a key press or combined keystroke (Like O to enter Object Mode, or SHIFT+B to enter the Block Tool).

Editor Tools

You can create your own editor tool to help you create your game. Your tool needs to be created in an editor project.

Editor Widgets

The Editor UI is built entirely out of Widgets. Widgets are different from Panels, which are used for in-game UI. Widgets can be various elements or components, such as labels, buttons, text boxes, trees, or images.

Mapping

Mapping is where you build, shape, and texture playable spaces in the editor. This section covers the mapping workflow, toolset, and setup needed to start creating levels quickly.

MCP Server

The editor can run a Model Context Protocol server. This lets AI agents like Claude Code see and drive the project you have open. An agent can read your scene, create and edit game objects, search assets, enter play mode, read the console, take screenshots, and anything else you

Model Editor

The "Model Editor", also known as "ModelDoc", is where you can create and edit model (VMDL) files. This is the modern equivalent of Source 1's .QC files. You can find it under the "Tools" menu.

Property Attributes

You can add attributes to your Component's properties in C to change how they look in the editor/inspector.

Shortcuts

Covers: Selection · Grid · Tools · Mesh Editing · View · Object.

Texture Generators

In the editor Textures can be generated in a number of ways. They can be created from an image (which is pretty normal), or a color, or a gradient, or text, or SVG source. These are called texture generators.

Undo System

The scope based system works by creating a snapshot of a change set when the scope is entered and another one when the scope is disposed of. The system will automatically take care of restoring the state on undo/redo.

Exporting

Exporting Standalone

:::warning Exporting standalone games is currently in preview. Distribution requires approval from Valve - we're working with them to open this up to everyone. In the meantime, please don't distribute exported builds without a license from us (contact garry@facepunch.com).

Standalone Code

When your game is exported as a standalone build, it runs outside of the s&box platform. This gives you access to APIs and capabilities that aren't available in platform games.

Game Mounts

Creating Mounts

The mount system is extensible - anyone can write a mount to add support for a new game or engine and contribute it to s&box via pull request. A mount detects a game's install directory via Steam, scans its files, and converts assets into s&box compatible assets, all at runtime.

Game Mounts

Game Mounts let users play with assets from other games they have installed inside s&box. Models, textures, materials, and sounds are converted on-the-fly - no manual importing or file conversion required.

Gameplay

Clutter

The Clutter System lets you quickly scatter large amounts of small objects like grass, rocks, and debris across your scene. It handles placement, streaming, and GPU-instanced rendering for models automatically.

Controller Input

Some Input methods are specific to Controllers/Gamepads, and are useful to know for making sure your player experience caters to those who don't play on a Keyboard + Mouse.

Costs & Filters

Areas can be used:

Creating Terrain

To add Terrain to your Scene, right click in the Hierarchy and select 3D Object → Terrain from the menu. The Terrain inspector will then prompt you to create, import or link an existing Terrain asset.

Gameplay

Core gameplay systems: input, navigation, terrain, and more.

Glyphs

Input glyphs are an easy way to show users which buttons to press for actions, they automatically adjust for whatever device you're using and return appropriate textures.

Input

Input is accessed using the… Input class!

Inventory

Add a BaseInventoryComponent to your player and it can carry things. It keeps items in slots, remembers which one is deployed, and handles picking up, dropping and switching.

Inventory & Weapons

The engine ships with an inventory and weapon system, modelled loosely on Garry's Mod. It gives you pickups, slots, weapon switching, ammo, shooting and reloading without you having to build any of it.

Navigation

We implement Recast Navigation in s&box, the industry standard for navmesh generation and navigation agents. It's used in Unreal, Unity and Godot. So if it seems familiar, that's why.

NavMesh Agent

A NavMesh Agent will move from position to position on the NavMesh, automatically. It features crowd control features, so they will try to avoid bumping into each other if possible.

NavMesh Areas

NavMesh Areas can affect NavMesh generation and agent behavior/pathing. The NavMeshArea component is used to define the location, shape and type of an area.

NavMesh Links

You can create links by adding a NavMeshLink Component to an GameObject.

Obstacles

Areas can be used to block off certain areas of the NavMesh both in editor and at runtime. This will completely omit an area from navmesh generation.

Raw Input

:::tip We very much recommend that you only use this if you can't use input actions for whatever reason. You can't rebind these at all.

Terrain

The Terrain System allows you to create expansive outdoor environments quickly and easily in your scenes.

Terrain Materials

A Terrain Material is an Asset that defines a set of PBR textures, physics surfaces, detail meshes and other properties that the Terrain uses to render.

VR

Editor: Launch the editor with a headset connected. You'll see a VR button at the top right of your editor. It should be on by default. Game: If you have a VR headset plugged in and it's active, you'll launch in VR.

Weapon Models

BaseWeaponModel marks up a weapon's GameObject with the points it fires from. Put it on the model prefab, assign the renderer and the attachment GameObjects, and the weapon holding it finds everything through there.

Weapons

BaseCombatWeapon is the base for anything a player holds and uses. Guns work straight out of the box, and it stretches to melee weapons and tools with a small subclass.

Getting Started

Addon Project

An addon project adds to a Game Project. The addon project isn't published directly, you create assets and publish those individually.

Download & Install

The s&box editor and game are available on Steam.

Explore the Engine

S&box uses a scene system to create games. We feel this is the easiest system for people to pick up, while still being powerful.

FAQ

s&box is available on Steam for $20.

Game Project

A game project is the base level of project. It contains a game.

Getting Started

S&box is coded in C. Under the hood, it uses the Source 2 engine (CS2, HL:Alyx, DOTA2) and some of its systems: rendering, resources, physics, and audio.

Monetization

An important part of s&box being a modern game platform is allowing the developers that use it to make money from it.

Project Types

When creating a new project in s&box you are presented with a few different project types to make.

Reporting Errors

Errors will happen. Here's how to make a useful error report.

Staging Branch

The Staging Branch in s&box is a separate version of s&box where new updates and features are tested before being released to the main build. It's essentially the experimental build, allowing us to identify bugs and performance issues with help from developers and players who opt

Status

As you play with developing in s&box, you will notice some things are weird, missing, or suck. We are aware.

System Requirements

:::warning Integrated Intel graphics are not supported. AMD integrated graphics (e.g. Ryzen APUs) will work. :::

Your First Project

The best way to learn is to do. Open the s&box editor and on the welcome screen, choose New Project. Create a Game - Empty project.

Media

Audio

MusicPlayer is for music tracks and streaming audio that need programmatic control over playback, positioning, or visualization. For in-game sound effects and Sound components, see Sound.

Media

s&box supports video playback, audio streaming, music, voice chat, positional 3D audio, and video encoding.

Video

Decodes a video file or URL and exposes the current frame as a Texture.

Movie Maker

Editor Map

Create, open, or import movies.

Exporting Video

The video will be rendered from the perspective of any active camera in the scene. You should therefore control camera motion using tracks in your movie project. You can also use tracks to toggle which cameras are enabled in the scene, if necessary.

Getting Started

In this article you'll find out:

Keyframe Editing

It will be active by default, but you can toggle it with the key-shaped button in the toolbar.

Motion Editing

To motion edit, you select a time range of one or more tracks, then tweak the properties that those tracks represent to manipulate track data. You can also cut / copy / paste ranges of time, or save the selection as a separate .movie file.

Movie Maker

Movie Maker is a timeline-based editor built into S&box for animating anything in your scene. Keyframe object properties, record gameplay, animate characters with bones and IK, and export finished videos, all without leaving the editor.

Playback API

You can define movies and play them back using C.

Recording

This lets you act out the roles of characters by controlling them directly in-game, be a camera operator for a scene you've already animated, or capture gameplay for a trailer.

Recording API

You can record gameplay into a MovieClip, which can be played back or imported into Movie Maker for editing. This could be useful for killcams in shooters, leaderboard replays in racing games, or for capturing gameplay to edit into a trailer.

Sequences

Sequence blocks are clips taken from other .movie assets. This helps you divide up big projects however you like: individual scenes, or individual actors in each scene can be grouped into their own .movie files. There's no limit to how deep you nest your sequences.

Skeletal Animation

You can animate skinned characters directly in the editor using Movie Maker. This tutorial covers:

Networking

Connection Permissions

The host can change some permissions for a specific Connection. The ideal place to set these permissions would be in the OnActive network event.

Custom Snapshot Data

In some circumstances you may want to add additional data to the network snapshot that gets sent to clients when they join a server. One example of this might be serializing and deserializing voxel world data.

Dedicated Servers

You can find information about how to install and use SteamCMD here <https://developer.valvesoftware.com/wiki/SteamCMD to install the s&box Dedicated Server.

Http Requests

s&box provides a static Http class, this lets you easily create asynchronous HTTP requests of different methods (GET, POST, DELETE, etc…) providing JSON content and parsing JSON responses.

Network Events

Your games will likely want to react to people joining and leaving the game. To help with this you can implement Component.INetworkListener or Component.INetworkSpawn on a component and place it in the scene.

Network Helper

To make a multiplayer game you need to take care of a few things. There's a special component that helps with those things, called NetworkHelper. This is a simple component that fits a lot of situations, but can be used as an example to code your own network component.

Network Visibility

Network Visibility controls whether a networked object should be visible for a specific player (Connection). Visibility determines whether the object receives ongoing network updates, such as Sync Vars and Transform updates, for that client.

Networked Objects

Any game object can become a networked object by simply calling NetworkSpawn() on it. It will then be sent to all clients and can have Sync Properties and RPC Messages.

Networking & Multiplayer

Networking is built right into s&box, so turning a single-player scene into a shared multiplayer experience takes surprisingly little code. GameObjects can be easily replicated to other clients, RPCs can be sent to the server or peer-to-peer and there is full dedicated server sup

Ownership

Networked GameObjects can be owned by a connection.

Platform Chat

Built-in text chat for multiplayer games. Messages are routed through the host, validated, filtered, and displayed via the standard overlay UI - no game code required.

RPC Messages

Components can contain RPCs. An RPC is a function that when called, is called remotely too.

Running Local Projects

When running a dedicated server - you have the option of running an entirely local project as the game. I.e:

Serverside Code

:::info Serverside Code only works when running local projects - please read that page first.

Sync Properties

Adding the [Sync] attribute to a property on a Component will have its latest value sent to other players each time it changes.

Testing Multiplayer

The number one best way to test multiplayer is to have someone join your game.. but that's obviously not always possible.

User Permissions

On a Dedicated Server, you can specify who is an admin of your server, or customize permissions even further with claims for individual Steam accounts.

WebSockets

s&box allows you to use WebSockets to interface with an external server. Common usages include custom networking, or persistent data outside of a local filesystem.

Overview

S&box Documentation

S&box is coded in C. Under the hood, it uses the Source 2 engine (CS2, HL:Alyx, DOTA2) and some of its systems: rendering, resources, physics, and audio.

Physics

IScenePhysicsEvents

This interface allows you to wrap logic around the physics step. This can be useful when you have an object, or a system, that works closely with the physics system.

Physics

S&box includes a full 3D and 2D physics system powered by the Source 2 engine, with great performance and stability. Rigidbodies, colliders, joints, raycasting, and trigger volumes are all usable through Components on GameObjects.

Tracing

Scenes can be traced against using Scene.Trace - which uses a builder pattern to make construction a bit easier. At a minimum, traces have a shape, start, and end. You can also filter which specific tags will be hit or ignored, or opt-in to using your project's collision rule mat

Triggers

A trigger is a collider that detects when other physics objects enter or exit it, without blocking their movement. They're useful for things like pickup zones, death planes, checkpoints, and area detection.

Rendering

AmbientLight

This class is part of the standard shading model, which allows fetching proper diffuse light contribution from appropriate sources on scene.

Animated Effects

Properties of the decal can be animated over the lifetime of it. These work exactly the same way as in the ParticleEffect component.

Attributes and Variables

Attributes are the bridge to pass information around the CPU to the GPU, like Variables, Textures or entire Buffers.

BeamEffect

With the BeamEffect you have basically got a LineRenderer that can be animated. You can have it make multiple beams, fade them out over time, scale over time and scroll and scale the texture over time.

Beams

The BeamEffect component draws animated line/laser effects, useful for things like tracers and lasers.

Bindless API

The fancy new way to do things in Vulkan / DX12 is bindless. This removes the limitations of the binding model allowing you to have access to far more textures and other resources within a shader and the ability to sample them from a dynamically provided identifier from buffers,

C# Shader Nodes

Just like Subgraphs, you can also create your own custom Nodes with C (and shader code) to be used in Shader Graphs.

Classes

s&box comes with a good amount of helper classes that simplifies working with various renderer features, such as lighting, decals, depth, envmaps, g-buffer, and many others.

Command Lists

Command Lists are deferred commands to execute on the renderer on certain rendering stage, this replaces the previous RenderHook system

Creating a Subgraph

Subgraphs are a collection of Shader Graph nodes that can be easily reused as a single node across other Shaders and even other Subgraphs. This is an easy way of develop custom Shader Graph Functions of your own.

Creating PostProcesses

To make a post process shader you should derive from BasePostProcess<T. This makes it easier to make a component that will be able to blend from multiple others.

Custom Nodes

There are two ways to create your own node types:

Custom Particle Controller

The particle system is designed to let you control the particles via your own code based components, if you choose to.

Decal Component

The decal component draws a decal in the game world.

DecalDefinition

A DecalDefinition holds what a single Decal should look like. It describes its color, normals, roughness, metalness and ambient occlusion. If you define a Height texture, it will define its parallax too.

Decals

The Decal component projects textures onto opaque or transparent surfaces in the world.

Decals

Decals is a class that handles whole process of rendering decals on scene. Usually you may need to use this class if you are building a custom shading model and you want it to support decal rendering. You don't have to use this function if your shader passes all data into a stand

Default Vertex and Pixel Shader Inputs

If you're just opting for default Vertex and Pixel inputs which are usable on the default shading model, these are the reference member variables for each:

Depth

We have some utility functions for reading from the depth buffer. We generate it in an early depth pass, so you can re-use this even on operations that also write to depth.

Dynamic Reflections

Much like SSAO, you can composite dynamic specular reflections on your object, whether they are SSR or eventually Raytraced Reflections

Effects

Visual effects you can add to a scene as components, including particles, beams, decals, and indirect lighting.

Effects

We have a bunch of built in post processing effects.

EnvMap

EnvMap class allows easily sampling environment probes that are present on your scene, with appropriate mip level (if roughness is set) and clustered culling.

Feature Upgrade

FeatureUpgrade is a special utility in FEATURES block that mark an already-declared feature as an internal upgrade toggle. New materials will be automatically created with a new value assigned, while keeping old materials unaffected. This may be useful if you are changing some sh

FilmGrain

The FilmGrain component adds simulated film-style grain to the camera output. It's purely visual, it does not affect gameplay or lighting, and is intended to add texture, grit or stylistic noise to the final image.

Fog

This class applies atmospheric effects to a fragment.

G-Buffer

Materials that write to Depth PrePass also write to a G-Buffer, if you are using the standard ShadingModel, you just have to make sure you have a Depth(); mode enabled.

Getting Started

Shader Graph is a visual scripting language that compiles to shader code. This is great for those who have never touched shader languages as well as those who have deep shader knowledge and want to quickly and easily prototype a shader idea they have.

Getting Started

You can create different types of shaders in s&box through code or the ShaderGraph.

Global Variables

Shaders have access to a number of variables that are available from everywhere. They are defined per-view, meaning that some data will vary depending on current viewport. Compute shader can access this data as well, as long as they are being dispatched from render context.

GPU Instancing

GPU instancing is an optimization where multiple instances of the same model with the same material can be drawn in a single draw call. This is a big optimization when rendering things that appear many times in a scene such as foliage.

Indirect Light Volumes

Indirect Light Volumes are in Feedback Preview

Lifetime

The "life" properties on the decal component allow you to define how long it should live for. Any lifetime curve properties on the Decal will be played back using this time. You can randomise it to add variety.

Light

If you want to access lighting information directly you can use this.

Material

The Material API is a structure to define the surface properties of what you're drawing as described by traditional PBR shading models.

Modes

Modes are different ways your shader will render under different passes or conditions.

Motion

The Motion class provides functions for calculating motion vectors, reprojection, and performing temporal filtering in HLSL shaders. It is useful for implementing effects like Temporal Anti-Aliasing (TAA), motion blur or general reprojection by blending current and previous frame

Particle Effect

The scene system includes a programmable particle system, which can be controlled completely with components.

Post Processing

Post-processing effects can be applied by adding components to the Camera or to a PostProcessVolume.

PostProcessVolume

PostProcessVolume It is a component that applies a set of post-processing components when a camera is inside it.

Procedural Effects

:::tip Unlike other classes, procedural.hlsl is located directly at the Shader folder root and simply provides a collection of various helper functions, it isn't a proper class. It does not come included in your shader by default, and must be manually imported by adding include "

Properties

There are a few basic properties that each Shader Graph has that affect the way the resulting Shader is drawn and how it can be used.

Reference

Reference material for writing shaders: the default vertex and pixel shader inputs, global variables, vertex helpers, and screen-space reflections.

Render States

You can control render states in your shaders using this syntax anywhere outside of functions.

Rendering

Rendering, shaders, visual effects, and post-processing in s&box.

Sampler States

Sampler states control how textures are sampled in shaders, how they're filtered and addressed.

Screen Space Tracing

ScreenSpace::Trace provides functionality for tracing rays in screen space to compute effects like Dynamic Reflections or any kind of ray in world space. It leverages hierarchical ray marching for efficient performance.

Screen-Space Reflections

SSR is done in three steps

Shader Graph

Shader Graph is a visual node editor that compiles to shader code, so you can build and prototype materials without writing HLSL.

Shaders

Writing shaders in code for s&box: HLSL in a VFX wrapper that combines vertex and pixel stages, with hot reloading on save.

Shading Model

Shading Models are what process how a model is lit, this is typically the final step and output of your shader.

SSAO

If your custom shader implements custom lighting you can sample the screen space ambient occlusion value for your lighting calculations.

Texture Sheets

Using texture sheets in shaders is made easy using the Sheet class.

Tonemapping

In s&box, tonemapping is a built-in post-processing effect that remaps HDR colors for display, which by default can appear dark until tuned. You can run other post-processing effects before or after tonemapping to use a full HDR buffer, or to use the resulting LDR buffer respecti

Tracers

The BeamEffect can be used to easily make tracers. To do this, you'd simply:

Variables

Variables are useful for making your Graph easier to follow and understand, while also giving the option to expose certain values to the Material Editor and Code.

Vertex Helpers

Helper functions to do standard vertex shader, does instancing, skinning, etc.

Scene

Advanced Topics

Deeper component topics for when you need more control over how components are defined and serialized.

Async

By default, async tasks in s&box run on the main thread. They operate a lot like coroutines, making them the perfect replacement.

Camera Effects

Shake, punch and tilt on any CameraComponent. Effects stack, run out on their own, and don't touch the player's aim, they only move what's rendered.

Component Interfaces

There are various interfaces that can be given to components for specific purposes.

Component Methods

When creating a component there are a number of methods you can override and implement.

Component Versioning

You can define upgraders for components. Useful when making a breaking change to a component such as property renaming, or new data structures.

Components

A Component is added to a GameObject to provide functionality. This functionality can vary wildly.

Events

You can broadcast and listen to events in your scene using interfaces.

Execution Order

:::warning You should not rely on the order in which the same callback methods get invoked for different GameObjects, it is not predictable. If you need more control, you should use a GameObjectSystem.

GameObject

A GameObject represents an object in the scene world. It contains a few different elements.

GameObjectSystem

A scene can contain systems that need to do work in specific places during the frame.

Hammer Mesh

The HammerMesh component is added automatically to game objects in Hammer that are tied to a mesh.

IGameObjectNetworkEvents

Allows a GameObject's Components to listen to changes in ownership state.

Instance Overrides

Prefab instance overrides allow you to customize individual instances of a prefab without affecting the original prefab or other instances. This lets you create variations of the same prefab while maintaining the connection to the original template.

ISceneStartup

This event interface allows you to listen to Scene startup events. These events are run in three places:

ITemporaryEffect

The interface Component.ITemporaryEffect is used on a component that comes to an end.

Loading Maps

The MapInstance component is what you use to load a map into your scene. Add it to any GameObject, set the map, and it handles the rest - loading geometry, creating physics, and spawning entities.

Map Entities

When a map is loaded, its embedded entities are converted into GameObjects as children of the MapInstance's GameObject. The following entity types are handled automatically:

Maps

Loading maps, map entities, and how maps interact with networking.

Networking

Maps and networking work together automatically. Most of the map's content does not need to be networked because it is loaded identically on every client from the same map file.

Player Controller

The PlayerController component is a first and third person player controller.

Prefab Templates

If you want to add your own templates to the GameObject Create menu, it's as simple as enabling "Show In Menu" on a Prefab File:

Prefabs

A prefab is a GameObject that can be used in multiple places. They're usually used to contain an object that is used across multiple scenes, or needs to be instantiated at runtime.

Reference

Reference documentation for some of the built-in components.

Scene

S&box uses a scene system, similar to Godot and Unity. Scenes are JSON files on disk that are fast to load and switch between.

Scene Metadata

You can implement the ISceneMetadata interface in any Component that has data you'd like saved to Metadata. Metadata is data that can be accessed without needing to load a Scene or clone a Prefab (accessed via either the SceneFile or PrefabFile)

Scenes

A scene is a collection of GameObjects.

TemporaryEffect

This component is generally added to Prefabs that contain ParticleEffects and Sounds. It will automatically delete the GameObject after the particles are all gone and the sounds are done.

Services

Achievements

Your game can have multiple achievements for players to unlock.

Auth Tokens

If you are using HTTP requests or WebSockets in your game, you can use Auth Tokens to validate that the requests were sent from a valid Steam user in a s&box game session. This is useful if you want to tie data to a specific Steam account, or prevent botting.

Leaderboards

Leaderboards are just stats, aggregated and ordered.

Services

Backend services for achievements, leaderboards, stats, and authentication.

Stats

Your game can record stats for each player that plays it. Here are some examples of things stats can record.

Web Api

The API for leaderboards is publicly accessible. Have fun!

Sound

Playing Sounds

s&box provides several ways to play sounds in code. You can fire-and-forget a sound at a world position, control it via a SoundHandle, attach it to a GameObject, or use scene components entirely.

Sound

s&box has a full audio system including 2D/3D sound playback, voice chat, positional audio, an audio effects pipeline, and lip sync support.

UI

HudPainter

Each camera has a HudPainter that can be used to draw onto the HUD. You do this every frame, in any Update function.

Localization

When displaying text such as Hello World, you should instead use a localization token like menu.helloworld. This will automatically replace the text with the corresponding language set by the user when set on a Label, allowing you to easily support multiple languages.

Razor Components

Razor Component allow you to define some content to show inside another razor file. This makes it easy to create Panels that are more agile and reusable.

Razor Panels

UI can also be created using Razor, which allows you to use web-like HTML/CSS to create and style each Panel while also being able to leverage C.

Style Properties

We try to keep as close to standard web styles as possible - but not every property is implemented. We'll use this page to highlight any differences.

Styling Panels

:::info It is common to have a file system like this:

UI

Our UI system is structured around Panels. A Panel is a c class that can have parent and child panels.

UI Interactions

By default, panels do not receive mouse input. You need to enable pointer-events in your stylesheet to make a panel interactable.

VirtualGrid

VirtualGrid is a Panel that allows you to create a grid of items virtually. What this means is that if you have 1 million items, it won't render them and try to lay them all out at the same time. It'll just pick the few that are visible and create them. When you scroll down, it'l

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.