Scripting API
Scripting API
MaterialFiles
Class in Abyss.Core, from Abyss.Core.
A material as a file of its own: a .mat in a game's assets, which says what shader the material runs and what its values are.
public static class MaterialFilesRemarks
Loaded as any material is, by World.LoadMaterial with its path under the asset root, and known by that path from then on: a scene names the file, and asking for it twice gives one material. It is JSON, and the engine reads it the moment it is asked for:
{ "abyssMaterial": 2, "ids": { "base_texture": "6d33cf113bfc4cd183855291b38be3c0", "shader": "b612f1ee9f5e49a0b04e2e28e9f37485" }, "shader": "shaders/glow.wesl", "textures": { "base_texture": "textures/stone.png" }, "values": { "glow_color": [1, 0.55, 0.15, 1], "speed": 2 }}shader is standard — Bevy's own surface, whose values are a MaterialSpec's fields by their engine names, base_color, perceptual_roughness — or a file in the game's shaders folder, whose values are the names the shader gives them. What the file does not say starts as the shader says, and what it says that its shader does not take is kept, so a material switched from one shader to another and back keeps what the first took.
Each file it names is named by its identity as well, under ids, so an image or a shader moved or renamed is still found: the engine looks an identity up in the index the world was given (World.UseAssetIndex), and uses the path where the identity is unknown.
Methods
Is
public static bool Is(string path)Whether a path names a material file, by its extension.
Parameters
path
ShaderOf
public static (string? Path, AssetGuid Id) ShaderOf(string json)The shader a material file's text says it runs, by its path in the game's folder — shaders/glow.wesl — and its identity where the file gives one; a null path for Bevy's own surface, and for text that is no material file.
Parameters
json
Constants
Extension
public const string Extension = ".mat"The extension a material file has.
Standard
public const string Standard = "standard"What a material file's shader says for Bevy's own surface.
Version
public const int Version = 2The version of a material file this build writes; it reads this and every one before it.
New
public const string New = "{\n \"abyssMaterial\": 2,\n \"shader\": \"standard\"\n}\n"What a new material file says: Bevy's own surface, as it starts — white.
