PreprocessedMaterial class

A material driven by a .fmat custom-material shader and its sidecar metadata (produced at build time by buildMaterials).

Construct one from a shader bundle entry and its metadata, then set parameters by name through parameters:

final library = gpu.ShaderLibrary.fromAsset('build/shaderbundles/materials.shaderbundle')!;
final metadata = jsonDecode(await rootBundle.loadString(
    'build/shaderbundles/materials.fmat.json')) as Map<String, Object?>;
final toon = PreprocessedMaterial(
  fragmentShader: library['Toon']!,
  metadata: (metadata['Toon'] as Map).cast<String, Object?>(),
)..parameters.setColor('base_color', const Color(0xff8844ff));

A lit material is lit by the engine's physically based pipeline (the shader's Surface() fills the surface description); an unlit material outputs its base_color directly. The render state (blending, culling) comes from the material's metadata.

Inheritance

Constructors

PreprocessedMaterial({required Shader fragmentShader, required Map<String, Object?> metadata})

Properties

doubleSided bool
Whether to render both faces of triangles drawn with this material (glTF's material.doubleSided). When true, bind disables back-face culling so the geometry is visible from both sides; otherwise back faces are culled. Defaults to false. The runtime importer sets it from the glTF material.
getter/setter pairinherited
environment EnvironmentMap?
Per-material image-based-lighting environment, overriding the scene-wide environment when set. Only used for FmatShadingModel.lit materials.
getter/setter pair
fragmentShader Shader
The fragment shader used when rendering geometry with this material.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
parameters MaterialParameters
The material's parameters, set by name. See MaterialParameters.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shadingModel → FmatShadingModel
Whether the engine runs its lighting (FmatShadingModel.lit) or the shader's color is output directly (FmatShadingModel.unlit).
final

Methods

bind(RenderPass pass, HostBuffer transientsBuffer, Lighting lighting) → void
Binds this material's render-pass state, uniforms, and textures.
override
isOpaque() bool
Whether geometry rendered with this material is fully opaque.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setFragmentShader(Shader shader) → void
Assigns the fragment shader used when this material is drawn.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited