# Sandbox.Shader.CompileFileAsync

## Overload 1

```csharp
static System.Threading.Tasks.Task<Shader> CompileFileAsync(string path, System.Threading.CancellationToken token = null)
```

Compile a .shader, VFX or Slang by its content, from the game's files (Slang imports what's beside it). Compiling the same path again swaps the new version in, and anything
using the shader picks it up. Unchanged source isn't compiled again. A dedicated server compiles it too, so
errors show up there, but returns null, the same as [Sandbox.Shader.Load](/api/Sandbox.Shader/Load) does there.

### Parameters

- `path` (`string`)
- `token` (`System.Threading.CancellationToken`), default `null`

### Returns

`System.Threading.Tasks.Task<Shader>`

### Exceptions

- `Sandbox.ShaderCompileException`: The shader didn't compile

## Overload 2

```csharp
static System.Threading.Tasks.Task<Shader> CompileFileAsync(BaseFileSystem fileSystem, string path, System.Threading.CancellationToken token = null)
```

Compile a .shader, VFX or Slang by its content, from a filesystem, like [Sandbox.FileSystem.Data](/api/Sandbox.FileSystem/Data) for shaders the game writes itself.
Includes are read from the same filesystem, then from the engine's shaders. Compiling the same path again
swaps the new version in, and anything using the shader picks it up. Unchanged source isn't compiled again.
A dedicated server compiles it too, so errors show up there, but returns null, the same as [Sandbox.Shader.Load](/api/Sandbox.Shader/Load).

### Parameters

- `fileSystem` (`BaseFileSystem`)
- `path` (`string`)
- `token` (`System.Threading.CancellationToken`), default `null`

### Returns

`System.Threading.Tasks.Task<Shader>`

### Exceptions

- `Sandbox.ShaderCompileException`: The shader didn't compile

Declared in [Sandbox.Shader](/api/Sandbox.Shader).
Assembly: `Sandbox.Engine`.
