ShaderMaterial constructor
ShaderMaterial({
- Shader? fragmentShader,
- Shader? radianceCubeFragmentShader,
- Shader? vertexShader,
- Shader? skinnedVertexShader,
- Shader? depthVertexShader,
- bool useEnvironment = false,
- CullMode cullingMode = gpu.CullMode.backFace,
- WindingOrder windingOrder = gpu.WindingOrder.clockwise,
- bool isOpaqueOverride = true,
- Set<
RenderInput> sceneInputs = const {}, - List<
ShaderInstanceAttribute> instanceAttributes = const [],
Creates a ShaderMaterial wrapping fragmentShader.
The shader is typically loaded from a .shaderbundle produced
by flutter_gpu_shaders. May be omitted at construction and
assigned later via setFragmentShader; rendering throws until a
shader is set. Set useEnvironment to true to have the engine
bind the scene environment's IBL textures by their standard
names, and pass instanceAttributes to widen the instance record
this material's instanced meshes carry.
Implementation
ShaderMaterial({
gpu.Shader? fragmentShader,
gpu.Shader? radianceCubeFragmentShader,
gpu.Shader? vertexShader,
gpu.Shader? skinnedVertexShader,
gpu.Shader? depthVertexShader,
this.useEnvironment = false,
this.cullingMode = gpu.CullMode.backFace,
this.windingOrder = gpu.WindingOrder.clockwise,
this.isOpaqueOverride = true,
Set<RenderInput> sceneInputs = const {},
List<ShaderInstanceAttribute> instanceAttributes = const [],
}) : _sceneInputs = _normalizeSceneInputs(sceneInputs),
_instanceAttributes = _buildInstanceAttributes(instanceAttributes) {
// A material constructed with inputs is not in the frame's cached summary
// yet. Attaching it to a mounted mesh invalidates through the mesh
// component, but constructing before the first render does not, so cover
// the declaration itself.
if (_sceneInputs.isNotEmpty) {
markMaterialSceneInputsChanged();
}
if (fragmentShader != null) {
setFragmentShader(fragmentShader);
}
setRadianceCubeFragmentShader(radianceCubeFragmentShader);
setVertexShader(vertexShader);
setVertexShader(skinnedVertexShader, variant: MeshVariant.skinned);
setVertexShader(depthVertexShader, variant: MeshVariant.depth);
}