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.
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 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
- 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
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.
- lambert → const LightingModel
- normals → const LightingModel
- pbr → const LightingModel
- 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.