getBlackPlaceholderTexture static method

Texture getBlackPlaceholderTexture()

Returns a 1×1 opaque-black texture, lazily created on first use.

Used as the specular source for EnvironmentMap.empty so the shader can sample an "atlas" that contributes no reflection.

Implementation

static gpu.Texture getBlackPlaceholderTexture() {
  if (_blackPlaceholderTexture != null) {
    return _blackPlaceholderTexture!;
  }
  _blackPlaceholderTexture = gpu.gpuContext.createTexture(
    gpu.StorageMode.hostVisible,
    1,
    1,
  );
  if (_blackPlaceholderTexture == null) {
    throw Exception('Failed to create black placeholder texture.');
  }
  _blackPlaceholderTexture!.overwrite(
    Uint32List.fromList(<int>[0xFF000000]).buffer.asByteData(),
  );
  return _blackPlaceholderTexture!;
}