Material class abstract Materials
Base class for shading a MeshPrimitive.
A material owns the fragment shader plus any per-material parameters (colors, factors, textures) bound when the primitive is drawn. The built-in subclasses are UnlitMaterial (constant color / texture) and PhysicallyBasedMaterial (PBR metallic-roughness with image-based lighting). Custom subclasses can be implemented by overriding bind and supplying their own fragment shader.
The default bind enables back-face culling with native counter-clockwise winding.
Constructors
- Material()
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 pair
- 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 pair - fragmentShader → Shader
-
The fragment shader used when rendering geometry with this material.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- name ↔ String
-
The name of this material, used for identification.
getter/setter pair
- 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
.fmatmaterial declares these withengine_inputs:.no setter
Methods
-
bind(
RenderPass pass, TransientWriter transientsBuffer, Lighting lighting) → void - Binds this material's render-pass state, uniforms, and textures.
-
isOpaque(
) → bool - Whether geometry rendered with this material is fully opaque.
-
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. -
setFragmentShaderName(
String name, {String? cubeName}) → void -
Assigns the fragment shader by
namefrom baseShaderLibrary. -
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. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getBlackPlaceholderTexture(
) → Texture - Returns a 1×1 opaque-black texture, lazily created on first use.
-
getDefaultEnvironmentMap(
) → EnvironmentMap - Returns the package's built-in procedural "studio" image-based lighting environment (see EnvironmentMap.studio), built once and memoized.
-
getNormalPlaceholderTexture(
) → Texture -
Returns a 1×1 "flat" tangent-space normal texture (
(0.5, 0.5, 1)), lazily created on first use. -
getWhitePlaceholderTexture(
) → Texture - Returns a 1×1 opaque-white texture, lazily created on first use.
-
initializeStaticResources(
) → Future< void> - Builds the BRDF lookup texture and loads the physical shader variants.
-
normalPlaceholder(
Texture? texture) → Texture -
Returns
textureif non-null, otherwise getNormalPlaceholderTexture. -
whitePlaceholder(
Texture? texture) → Texture -
Returns
textureif non-null, otherwise getWhitePlaceholderTexture.