Byte Engine Docs

.bema files

Look up the fields of a .bema material or variant file, the values they accept, and the resources that baking one produces.

A .bema file declares a material or a material variant in JSON5. A material names the BEMX graph that computes its surface, a render domain, and named parameters. A variant names a parent material and supplies a value for each of its parameters. .bema is a declaration format, not runtime data: at runtime, applications use the processed Material, Variant, Shader, and Image resources. To write one, follow Author assets.

Material files

A root material is a file without parent. The handler reads these fields and ignores any other, such as a material-level type:

FieldValue
domainRequired. The render domain, such as World. It's recorded in the material and not read by shader generation.
graphRequired. The asset ID of the .bemx file that describes the material's surface.
variablesRequired. The material's parameters, in order. Each is an object with name, data_type, value, and optionally type. The graph's parameter and image nodes read them by name.

A variable's type says how its value reaches the shader:

typeMeaning
Static, or no fieldThe value is compiled into the shader.
Dynamicvalue is the default, and applications can change the value at runtime; see Change a parameter at runtime. Only float, vec3f, and vec4f variables can be dynamic.

Any other type, or a dynamic Texture2D, fails the bake.

Variant files

FieldValue
parentRequired. The asset ID of the material this variant specializes.
variablesRequired. One object with name and value for parameters of the parent material. A static parent parameter without a value fails the bake; a dynamic one keeps the parent's default. Each value resolves with the parent parameter's data_type, and keeps the parent's type.
transparency"Blend" or true selects blended transparency. Any other value, or no field, selects opaque.

Values

data_type selects how value resolves:

data_typevalue
vec4fAn array of four numbers, or a named color: Red, Green, Blue, Purple, White, or Black. Any other name resolves to the magenta placeholder (1, 0, 1, 1).
vec3fAn array of three numbers, or a named color, as for vec4f, without the alpha component.
floatA number.
Texture2DThe asset ID of an image, which bakes as a dependency and is stored as a reference.

Any other data_type, or a value of the wrong form, fails the bake.

What baking produces

  • A Material resource for a root material file, referring to its generated shader and resolved parameters.
  • A Variant resource for a variant file, referring to its parent material and resolved values.
  • A Shader resource generated from the graph for the active render pipeline, with the material's ID and a #shader fragment. A graph that reads a parameter the material doesn't declare with a matching type fails the bake.
  • A dependent Image resource for each image a Texture2D parameter names.

On this page