Material
public sealed class Material : Resource A material. Uses several Textures and a Shader with specific settings for more interesting visual effects.
Properties
| Name | Type | Description |
|---|---|---|
IsValid virtual | Boolean | |
Name | String | Name (or path) of the material. |
Attributes | RenderAttributes | Access to all of the attributes of this material. |
Flags | FlagsAccessor | 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. |
ShaderName | String | Gets the underlying shader name for this material. |
FirstTexture | Texture | Get thje first texture assigned to this material, if any. |
Shader | Shader | Gets the material's shader |
Methods
Material CreateCopy(String name = null) Create a copy of this material
Void SetFeature(String name, Int32 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.
Int32 GetFeature(String name) Get a feature flag on the material. This is usually used to enable/disable shader permutations.
static Material Load(String filename) Load a material from disk. Has internal cache.
filename — The filepath to load the material from. static Task<Material> LoadAsync(String filename) Load a material from disk. Has internal cache.
filename — The filepath to load the material from. Texture GetTexture(String name) Get texture parameter, by name
Vector4 GetVector4(String name) Get Vector4 parameter, by name
Color GetColor(String name) Get Color parameter, by name
Boolean Set(String param, Vector4 value) Overrides/Sets an Vector4 within the material
Boolean Set(String param, Texture texture) Override/Sets texture parameter (Color, Normal, etc)
Boolean Set(String param, Color value) Overrides/Sets an color within the material as a color value within the material
Boolean Set(String param, Vector3 value) Overrides/Sets an Vector3 within the material
Boolean Set(String param, Vector2 value) Overrides/Sets an Vector2 within the material
Boolean Set(String param, Single value) Overrides/Sets an float within the material
Boolean Set(String param, Int32 value) Overrides/Sets an int within the material
Boolean Set(String param, Boolean value) Overrides/Sets an bool within the material
static Material Create(String materialName, String shader, Boolean anonymous = True) Create a new empty material at runtime.
materialName — Name of the new material. shader — Shader that the new material will use. anonymous — If false, material can be found by name. static Material FromShader(Shader shader) Get an empty material based on the specified shader. This will cache the material so that subsequent calls will return the same material.
static Material FromShader(String path) Get an empty material based on the specified shader. This will cache the material so that subsequent calls will return the same material.