PreprocessedMaterial class Materials

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

Prefer loadFmatMaterial, which resolves the generated DataAssets by the checked-in .fmat source path, then set parameters through parameters:

final toon = await loadFmatMaterial('assets/toon.fmat');
toon.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, Map<String, Shader>? vertexShaders, Shader? radianceCubeFragmentShader})

Properties

depthBias double
World-space offset toward the camera used for coplanar surface details. Positive values keep an overlay in front of its supporting surface without modifying its node transform. Zero and negative values leave the draw position unchanged. A fixed world offset provides fewer depth-buffer units as camera distance grows, so distant coplanar surfaces may need a larger value.
getter/setter pairinherited
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
name String
The name of this material, used for identification.
getter/setter pairinherited
parameters MaterialParameters
The material's parameters, set by name. See MaterialParameters.
final
radianceCubeFragmentShader Shader?
The variant compiled for a cubemap prefiltered radiance, or null when this material does not sample the environment.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sceneInputs Set<RenderInput>
Per-frame engine inputs this material samples, produced only when a visible material asks for them: RenderInput.depth binds the linear scene depth of the opaque geometry (forcing the depth prepass), and RenderInput.opaqueSceneColor binds the accumulated scene color behind the current draw, and RenderInput.filteredSceneColor adds its roughness-filtered atlas. Together they enable refraction, depth-fade absorption, shoreline foam, and soft-particle style effects on translucent surfaces. The base material requests nothing; a .fmat material declares these with engine_inputs:.
no setteroverride
shadingModel → FmatShadingModel
The engine shading model used by this material.
no setter

Methods

bind(RenderPass pass, TransientWriter transientsBuffer, Lighting lighting) → void
Binds this material's render-pass state, uniforms, and textures.
override
bindVertexStage(RenderPass pass, Shader vertexShader, TransientWriter transientsBuffer) → void
Binds this material's vertex-stage uniforms to vertexShader, called by the encoder only when it used a material-supplied vertex shader (see materialVertexShader). The base implementation is a no-op; a material with vertex-stage parameters binds them here.
configureDepthAlphaMask({required TextureSource? texture, TextureTransform? transform, int texCoord = 0, double cutoff = 0.5, double alpha = 1.0}) → void
Configures cutout coverage for the camera-depth and shadow passes.
fragmentShaderForLighting(Lighting lighting) Shader
Selects this material's fragment shader for the frame lighting state.
isOpaque() bool
Whether geometry rendered with this material is fully opaque.
override
materialVertexShader(String variant) Shader?
The vertex shader this material supplies for a geometry's variant ('unskinned' / 'skinned' for the color pass, 'depth' for the position-only depth/shadow pass; see Geometry.materialVertexVariant), or null to use the engine's standard vertex shader for the geometry.
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
setFragmentShaderName(String name, {String? cubeName}) → void
Assigns the fragment shader by name from baseShaderLibrary.
inherited
setRadianceCubeFragmentShader(Shader? shader) → void
Assigns the already-loaded variant built with FLUTTER_SCENE_RADIANCE_CUBE, the counterpart of setFragmentShader for a material that samples the environment.
inherited
toString() String
A string representation of this object.
inherited
updateFromMetadata(Shader fragmentShader, Map<String, Object?> metadata) → void
Re-reads the render state and parameters from a regenerated fragmentShader and sidecar metadata (a hot-reloaded .fmat), in place.

Operators

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