public sealed class Sandbox.Material : Sandbox.Resource
A material. Uses several `Sandbox.Texture`s and a `Sandbox.Material.Shader` with specific settings for more interesting visual effects.
Related Guides
Broader workflow and conceptual references connected to this API.
Attributes are the bridge to pass information around the CPU to the GPU, like Variables, Textures or entire Buffers.
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.
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.
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.
You can create your own editor tool to help you create your game. Your tool needs to be created in an editor project.
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.
Methods
Showing 19 methods
public static Sandbox.Material Create(string materialName, string shader, bool anonymous = True)
Create a new empty material at runtime.
Parameters
materialName: Name of the new material.shader: Shader that the new material will use.anonymous: If false, material can be found by name. Default: True
Returns
The new material.
public Sandbox.Material CreateCopy(string name = null)
Create a copy of this material
Parameters
name: Default: null
public Color GetColor(string name)
Get Color parameter, by name
public int GetFeature(string name)
Get a feature flag on the material. This is usually used to enable/disable shader permutations.
public Sandbox.Texture GetTexture(string name)
Get texture parameter, by name
public Vector4 GetVector4(string name)
Get Vector4 parameter, by name
public static Sandbox.Material Load(string filename)
Load a material from disk. Has internal cache.
Parameters
filename: The filepath to load the material from.
Returns
The loaded material, or null
public static System.Threading.Tasks.Task`1<Sandbox.Material> LoadAsync(string filename)
Load a material from disk. Has internal cache.
Parameters
filename: The filepath to load the material from.
Returns
The loaded material, or null
public void SetFeature(string name, int value)
Set a feature flag on the material. This is usually used to enable/disable shader permutations. This is kind of a define, also known as a combo.
No results match this filter.
Properties
Showing 7 properties
public Sandbox.RenderAttributes Sandbox.Material.Attributes { get; set; }
Access to all of the attributes of this material.
public Sandbox.Texture Sandbox.Material.FirstTexture { get; set; }
Get thje first texture assigned to this material, if any.
public Sandbox.Material.FlagsAccessor Sandbox.Material.Flags { get; set; }
Access flags on this material, which usually hint about the contents. These are generally added by the shader procedurally - but developers can add these in material editor too.
public virtual bool Sandbox.Material.IsValid { get; set; }
public string Sandbox.Material.Name { get; set; }
Name (or path) of the material.
public string Sandbox.Material.ShaderName { get; set; }
Gets the underlying shader name for this material.
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Material |