Byte Engine Docs

.bema files

Declare Byte Engine materials and material variants.

Use .bema files to declare materials and material variants.

A material describes shader stages, render-domain information, and named parameters. A variant references a parent material and supplies parameter values for a concrete material instance.

The .bema handler produces stored resources:

  • Material resources for root material files
  • Variant resources for variant files
  • Shader resources for referenced shader source files
  • dependent Image resources when material parameters reference textures

Material files

A root material has no parent. Declare its domain, shader stages, and variables:

{
	"domain": "World",
	"type": "Surface",
	"shaders": {
		"Fragment": "shaders/material.besl"
	},
	"variables": [
		{
			"name": "color",
			"data_type": "vec4f",
			"type": "Static",
			"value": "Purple"
		}
	]
}

During baking, the handler loads each shader source, parses BESL, applies the active render pipeline, compiles the result, and stores a shader resource. The material resource refers to the generated shaders and resolved parameters.

Variant files

A variant has a parent that identifies the material it specializes:

{
	"parent": "materials/base.bema",
	"variables": [
		{
			"name": "color",
			"value": "Red"
		}
	],
	"transparency": "Opaque"
}

Variants inherit the parameter list from the parent material and replace the values supplied in the file. The current handler supports scalar, vector color values, and texture references for material variables.

Values

The current value resolver is intentionally small. Named colors such as Red, Green, Blue, Purple, White, and Black can become vec3f or vec4f values. Texture2D values are baked as image resources and stored as references.

Treat .bema as a declaration format, not runtime data. At runtime, use the processed Material, Variant, Shader, and Image resources.

Next, bake your application resources with BELD.

On this page