LightingModel class final
A lighting model: one pre-built fragment shader and what the engine may bind to it.
A value class rather than an enum, so this list is not closed. Shaders are compiled ahead of time, so a material graph cannot be assembled at run time — but an application that builds its own bundle can add an entry to it and describe it here, and the renderer will cache a pipeline for it like any other. What it cannot do is add a shader to a bundle it does not build; that is the remaining limit, and it belongs to the bundle rather than to this type.
Two properties used to be derived by comparing against particular constants, which is the sort of thing that works exactly until somebody adds a seventh model. They are declared now.
Shaders are compiled ahead of time into the bundle, so a material graph
cannot be assembled at runtime. Switching models therefore means switching
shader — and switching shader means a different RenderPipeline, which is
why the renderer caches pipelines by shaderName.
The uses… flags are declared rather than detected. Shader reflection cannot
answer the question: it reports a uniform block as present because the GLSL
declared it, even when the compiled shader binds no buffer for it, and
binding that phantom block segfaults inside Metal with no Dart stack trace.
The same applies to samplers — the compiler drops one whose result never
reaches the output, which is why Lambert does not sample the metal-rough map
even though the header declares it.
The truth is printed by tool/build_shaders.sh after every build, as a table
of what each entry point actually kept. When this metadata and that table
disagree, the table is right.
And since 0.8.0 the table is what binds — gfx-92n. Every backend hands
the engine's own stages that table as ShaderHandle.kept, the renderer asks
it first, and an encoder refuses anything it names as dropped. The binding
flags below are the answer only for a stage the device cannot answer for —
one from an application's own bundle, or a material language stage — and
on the built-in models they are the fallback a device without the table
would use. usesMaterialParameters and usesMetallic are not about
binding at all: they tell an editor which controls do something.
Constructors
- LightingModel(String label, String shaderName, {String? vertexShaderName, bool usesFragInfo = true, bool usesAlbedoTexture = true, bool usesMaterialMaps = true, bool usesMetallicRoughnessMap = true, bool usesMaterialParameters = true, bool usesMetallic = false, bool usesEnvironment = false, bool? usesLightList, bool? usesFogInfo, bool vertexStageMorphs = true})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- label → String
-
Shown in the UI.
final
- pipelineGroup → int
-
A small stable number for grouping draws that share a pipeline.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shaderName → String
-
Entry name inside whichever bundle the backend supplied.
final
- usesAlbedoTexture → bool
-
Whether the shader samples
base_color_texture.final - usesEnvironment → bool
-
Whether the shader declares the environment cube and samples it.
final
- usesFogInfo → bool
-
Whether the shader reads the
FogInfoblock: the fog, the eye, and the view axis the surface buffer measures depth along.no setter - usesFragInfo → bool
-
Whether the shader reads the
FragInfouniform block.final - usesLightList → bool
-
Whether the shader reads the light list: the
LightListInfoblock andlight_list_texture.no setter - usesMaterialMaps → bool
-
Whether the shader samples the normal, occlusion and emissive maps.
final
- usesMaterialParameters → bool
-
Whether the material's numeric parameters reach the shader, so a UI can
disable the sliders that would do nothing.
final
- usesMetallic → bool
-
Whether the shader interprets metallic. Only a physical model does.
final
- usesMetallicRoughnessMap → bool
-
Whether the shader samples
metallic_roughness_texture.final - usesPointShadow → bool
-
Whether the shader reads the
PointShadowblock and the two cube atlases.no setter - usesShadowMap → bool
-
Whether the shader samples
shadow_texture.no setter - vertexShaderName → String?
-
The vertex stage this material brings with it, or null for the engine's
own —
gfx-75n.final - vertexStageMorphs → bool
-
Whether the material's own vertex stage declares the morph block and
texture, and so has to be handed them on every draw.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withLayers(
MaterialExtensions? layers, {bool textureTransforms = false}) → LightingModel -
The model a surface with
layersis drawn with, when it asked for this one: pbrLayered in place of pbr when a layer changes the shading, and this model unchanged otherwise —M1. Every other model has no layered form, and a surface that picked one keeps it.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- blinnPhong → const LightingModel
-
builtIn
→ const List<
LightingModel> - The models this engine ships, in the order a picker should show them.
- impostor → const LightingModel
-
An octahedral impostor's card —
C4: its ownImpostorVertex, which turns the card to the eye, and theImpostorstage, which reads the albedo atlas from the base colour slot and the normal-depth atlas from the normal map slot and lights the result diffusely. - lambert → const LightingModel
- normals → const LightingModel
- pbr → const LightingModel
- pbrLayered → const LightingModel
-
pbr with the layers glTF adds on top of it —
M1–M3: a clear coat, a specular strength and tint, an index of refraction, a sheen, anisotropy, transmission through a volume, dispersion and a thin film. SeeMaterialExtensionsfor what each is. - polyline → const LightingModel
-
A line of constant screen width —
gfx-86n: unlit's fragment stage behind the engine's ownPolylineVertex, which widensbuildPolyline's geometry by the number of pixels each point carries. - toon → const LightingModel
- unlit → const LightingModel
- xray → const LightingModel
- unlit with the surface buffer taken away, and the x-ray stage's alone.