setFragmentShaderName method

void setFragmentShaderName(
  1. String name, {
  2. String? cubeName,
  3. String? noShadowName,
  4. String? noShadowCubeName,
})

Assigns the fragment shader by name from baseShaderLibrary.

The shader is resolved lazily on first use and then cached, so a material can be constructed before Scene.initializeStaticResources has loaded the base shader bundle. The shader is only needed at render time, which the engine already defers until the bundle is ready.

cubeName is the twin built for the cubemap radiance layout, needed by any shader that samples the environment (see radianceCubeFragmentShader).

noShadowName and noShadowCubeName are the twins built with FLUTTER_SCENE_SKIP_SHADOWS, selected for a draw with no shadow atlas bound (see fragmentShaderForLighting). A material without them always draws with the full shaders.

Implementation

void setFragmentShaderName(
  String name, {
  String? cubeName,
  String? noShadowName,
  String? noShadowCubeName,
}) {
  _fragmentShaderName = name;
  _fragmentShader = null;
  _radianceCubeFragmentShaderName = cubeName;
  _radianceCubeFragmentShader = null;
  _noShadowFragmentShaderName = noShadowName;
  _noShadowFragmentShader = null;
  _noShadowRadianceCubeFragmentShaderName = noShadowCubeName;
  _noShadowRadianceCubeFragmentShader = null;
}