PhysicallyBasedMaterial class Materials
A glTF-style metallic-roughness physically based material with image-based lighting.
Wraps the StandardFragment shader and exposes the parameters from
the glTF 2.0 PBR metallic-roughness model:
- Albedo: baseColorFactor, baseColorTexture (multiplied with the optional per-vertex color, weighted by vertexColorWeight).
- Metallic-roughness: metallicFactor, roughnessFactor, metallicRoughnessTexture (B = metallic, G = roughness).
- Normal: normalTexture with normalScale.
- Emissive: emissiveFactor, emissiveTexture.
- Occlusion: occlusionTexture with occlusionStrength.
- Lighting: environment (overrides the Scene-wide environment when set).
Translucency is determined by baseColorFactor's alpha component;
the material is treated as opaque when alpha is exactly 1.
Constructors
- PhysicallyBasedMaterial({TextureSource? baseColorTexture, TextureSource? metallicRoughnessTexture, TextureSource? normalTexture, TextureSource? emissiveTexture, TextureSource? occlusionTexture, EnvironmentMap? environment})
- Creates a PBR material with the given textures.
Properties
- alphaCutoff ↔ double
-
Alpha-test threshold used when alphaMode is AlphaMode.mask:
fragments whose alpha falls below this are discarded.
getter/setter pair
- alphaMode ↔ AlphaMode
-
How the material's alpha is interpreted; see AlphaMode.
getter/setter pair
- baseColorFactor ↔ Vector4
-
Linear RGBA tint multiplied with baseColorTexture. Alpha controls
translucency: values below
1push the material into the depth- sorted translucent pass.getter/setter pair - baseColorTexture ↔ TextureSource?
-
The albedo (base color) texture, sampled in linear space and
multiplied by baseColorFactor. Defaults to white when null.
getter/setter pair
- depthAlphaMasked → bool
-
Whether the depth-writing passes (the shadow map and the camera depth
prepass) must alpha-test this material's coverage instead of writing its
full geometry, so cutout surfaces (foliage, fences) occlude, shadow, and
receive screen-space effects only where they are actually opaque. When
true, those passes draw with a masked fragment shader (which needs the
full-vertex varyings, so the position-only depth path is skipped) and
call bindDepthAlphaMask. The base material writes full geometry.
no setter
- 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 - emissiveFactor ↔ Vector4
-
Linear RGBA emissive tint. Alpha is unused; the default
Vector4.zero()disables emission.getter/setter pair - emissiveTexture ↔ TextureSource?
-
Optional emissive texture. Defaults to white when null and is
gated by emissiveFactor.
getter/setter pair
- environment ↔ EnvironmentMap?
-
Per-material image-based-lighting environment, overriding the
scene-wide
Scene.environmentwhen set.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
- metallicFactor ↔ double
-
Scalar multiplier applied to the metallic channel.
0is fully dielectric,1is fully metallic.getter/setter pair - metallicRoughnessTexture ↔ TextureSource?
-
The combined metallic-roughness texture (B = metallic,
G = roughness). Defaults to white when null.
getter/setter pair
- name ↔ String
-
The name of this material, used for identification.
getter/setter pairinherited
- normalScale ↔ double
-
Strength of normalTexture's perturbation.
1is the unmodified map.getter/setter pair - normalTexture ↔ TextureSource?
-
Tangent-space normal map. Defaults to a flat normal when null.
getter/setter pair
- occlusionStrength ↔ double
-
Strength of occlusionTexture's effect.
0ignores the map;1applies it fully.getter/setter pair - occlusionTexture ↔ TextureSource?
-
Optional ambient-occlusion texture (R channel). Defaults to white
when null.
getter/setter pair
- reflectionRoughnessFactor → double
-
The roughness multiplier applied to reflectionRoughnessTexture in the
depth prepass (the material's roughness factor).
no setter
- reflectionRoughnessTexture → Texture?
-
The metallic-roughness texture the camera depth prepass samples so
screen-space reflections have a per-pixel roughness (roughness in G),
or null to use a fully-rough placeholder. The base material has none, so
it reads as fully rough and receives no screen-space reflection; a lit
material overrides this.
no setter
- roughnessFactor ↔ double
-
Scalar multiplier applied to the roughness channel.
0is a perfect mirror,1is fully diffuse.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 a snapshot of the scene color
taken after the opaque phase (splitting the scene pass in two).
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 setterinherited - specularAntiAliasingThreshold ↔ double
-
Upper bound on the extra roughness specularAntiAliasingVariance may add,
in the squared-roughness domain. Caps the effect so strongly varying
normals cannot over-roughen a surface. Default
0.2.getter/setter pair - specularAntiAliasingVariance ↔ double
-
Strength of geometric specular antialiasing.
getter/setter pair
- vertexColorWeight ↔ double
-
How strongly per-vertex colors influence the final albedo.
0disables vertex color contribution;1(the default) fully applies it.getter/setter pair
Methods
-
bind(
RenderPass pass, TransientWriter transientsBuffer, Lighting lighting) → void -
Binds this material's render-pass state, uniforms, and textures.
override
-
bindDepthAlphaMask(
RenderPass pass, Shader shader, TransientWriter transientsBuffer) → void -
Binds the mask texture and MaskInfo parameters consumed by the masked
depth fragment shaders;
shaderis the masked variant the pass drew with. Called only when depthAlphaMasked is true. -
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
shaderused when this material is drawn.inherited -
setFragmentShaderName(
String name) → void -
Assigns the fragment shader by
namefrom baseShaderLibrary.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited