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.
Constructors
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.
getter/setter pairinherited
- depthLayer ↔ int
-
Which surface wins where this material's geometry and another's lie in
the same plane. A surface with a higher layer draws over coplanar
surfaces with a lower one, at any distance and on every backend.
getter/setter pairinherited
- displayReferred → bool
-
Whether this material's color is display-referred (already final screen
values) rather than scene-referred radiance.
no setterinherited
- 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.litmaterials.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
- instanceAttributes → InstanceAttributeSchema?
-
The per-instance attributes this material declares, or null when it
declares none. A
.fmatinstance_attributesblock declares them, as does a rawShaderMaterialconstructed withinstanceAttributes.no setter - 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
- participatesInDebugViews → bool
-
Whether this material's fragment shader declares the
DebugViewInfoblock and switches on it (seematerial_debug.glsl), so the scene's surface debug views can show its resolved surface.no setter - 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
- sceneColorSampleBoundsExpansion → double?
-
Maximum local-space distance sampled beyond the current surface.
no setter
-
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
.fmatmaterial declares these withengine_inputs:.no setteroverride - shadingModel → FmatShadingModel
-
The engine shading model used by this material.
no setter
- usesLightmapVariant → bool
-
Whether this material draws with its baked-lightmap variant, which reads
the diffuse ambient from a lightmap instead of the environment's SH
coefficients (and so declares no
sh_coefficientssampler).no setter - vertexAttributes → VertexAttributeSchema?
-
The custom vertex attributes this material's own vertex shaders read, or
null to bind every stream the geometry carries (a raw
ShaderMaterial, whose inputs the engine cannot see).no setter
Methods
-
adjustEngineLighting(
Float32List fragInfo) → void -
Hook for subclasses to override packed
FragInfolighting fields for this draw (a per-material shadow softness, say) without touching any scene-wide setting. Runs after the engine fields are packed and before the block is uploaded. The base implementation changes nothing. -
bind(
RenderPass pass, TransientWriter transientsBuffer, Lighting lighting) → void -
Binds this material's render-pass state, uniforms, and textures.
override
-
bindLightmap(
RenderPass pass, Shader shader, TransientWriter transientsBuffer) → void -
Binds the lightmap sampler and its
LightmapInfoblock, called only when usesLightmapVariant is true. SeeEngineLightingUniforms.bindLightmap. -
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(
{bool? masked, required TextureSource? texture, TextureTransform? transform, int texCoord = 0, double cutoff = 0.5, double alpha = 1.0}) → void - Configures cutout coverage for the depth-writing passes: the camera depth, the shadow maps, and the main pass's coverage pre-draw, which is what cuts the surface out on screen.
-
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; seeGeometry.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
shaderused when this material is drawn.inherited -
setFragmentShaderName(
String name, {String? cubeName, String? noShadowName, String? noShadowCubeName}) → void -
Assigns the fragment shader by
namefrom 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
fragmentShaderand sidecarmetadata(a hot-reloaded.fmat), in place.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
parsePlanarReflectionInput(
Object? value) → bool -
Whether the sidecar's
engine_inputsdeclaresplanar_reflection.