Materialclass

A material. Uses several `Sandbox.Texture`s and a `Sandbox.Material.Shader` with specific settings for more interesting visual effects.

objectResourceMaterial
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.Material : Sandbox.Resource

Methods19

Showing 19 methods

public static Sandbox.Material Create(string materialName, string shader, bool anonymous = True)PUBLICSTATIC

Create a new empty material at runtime.

ParameterTypeDescription
materialNamestringName of the new material.
shaderstringShader that the new material will use.
anonymous = TrueboolIf false, material can be found by name.
Returns:MaterialThe new material.

public Sandbox.Material CreateCopy(string name = null)PUBLIC

Create a copy of this material

ParameterTypeDescription
name = nullstring
Returns:Material

public Color GetColor(string name)PUBLIC

Get Color parameter, by name

ParameterTypeDescription
namestring
Returns:Color

public int GetFeature(string name)PUBLIC

Get a feature flag on the material. This is usually used to enable/disable shader permutations.

ParameterTypeDescription
namestring
Returns:int

public Sandbox.Texture GetTexture(string name)PUBLIC

Get texture parameter, by name

ParameterTypeDescription
namestring
Returns:Texture

public Vector4 GetVector4(string name)PUBLIC

Get Vector4 parameter, by name

ParameterTypeDescription
namestring
Returns:Vector4

public static Sandbox.Material Load(string filename)PUBLICSTATIC

Load a material from disk. Has internal cache.

ParameterTypeDescription
filenamestringThe filepath to load the material from.
Returns:MaterialThe loaded material, or null

public static System.Threading.Tasks.Task`1<Sandbox.Material> LoadAsync(string filename)PUBLICSTATIC

Load a material from disk. Has internal cache.

ParameterTypeDescription
filenamestringThe filepath to load the material from.
Returns:Task<Material>The loaded material, or null

public void SetFeature(string name, int value)PUBLIC

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.

ParameterTypeDescription
namestring
valueint
Returns:void

Properties7

Showing 7 properties

public Sandbox.Texture Sandbox.Material.FirstTexture { get; set; }PUBLICGETSET

Get thje first texture assigned to this material, if any.

Returns:Texture

public Sandbox.Material.FlagsAccessor Sandbox.Material.Flags { get; set; }PUBLICGETSET

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.

Returns:FlagsAccessor

public virtual bool Sandbox.Material.IsValid { get; set; }PUBLICVIRTUALGETSET

Returns:bool

public string Sandbox.Material.Name { get; set; }PUBLICGETSET

Name (or path) of the material.

Returns:string

public string Sandbox.Material.ShaderName { get; set; }PUBLICGETSET

Gets the underlying shader name for this material.

Returns:string

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