s&box docs

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.

Broader workflow and conceptual references connected to this API.

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.

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.

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.Material

On this page

Methodspublic static Sandbox.Material Create(System.String materialName, System.String shader, System.Boolean anonymous = True)public Sandbox.Material CreateCopy(System.String name = null)public static Sandbox.Material FromShader(Sandbox.Shader shader)public static Sandbox.Material FromShader(System.String path)public Color GetColor(System.String name)public System.Int32 GetFeature(System.String name)public Sandbox.Texture GetTexture(System.String name)public Vector4 GetVector4(System.String name)public static Sandbox.Material Load(System.String filename)public static System.Threading.Tasks.Task`1<Sandbox.Material> LoadAsync(System.String filename)public System.Boolean Set(System.String param, Color value)public System.Boolean Set(System.String param, Sandbox.Texture texture)public System.Boolean Set(System.String param, System.Boolean value)public System.Boolean Set(System.String param, System.Int32 value)public System.Boolean Set(System.String param, System.Single value)public System.Boolean Set(System.String param, Vector2 value)public System.Boolean Set(System.String param, Vector3 value)public System.Boolean Set(System.String param, Vector4 value)public System.Void SetFeature(System.String name, System.Int32 value)Propertiespublic Sandbox.RenderAttributes Sandbox.Material.Attributes { get; set; }public Sandbox.Texture Sandbox.Material.FirstTexture { get; set; }public Sandbox.Material.FlagsAccessor Sandbox.Material.Flags { get; set; }public virtual System.Boolean Sandbox.Material.IsValid { get; set; }public System.String Sandbox.Material.Name { get; set; }public Sandbox.Shader Sandbox.Material.Shader { get; set; }public System.String Sandbox.Material.ShaderName { get; set; }Metadata