getWhitePlaceholderTexture static method
Returns a 1×1 opaque-white texture, lazily created on first use.
Used as a default for missing color textures so shader code can always sample without conditionals.
Implementation
static gpu.Texture getWhitePlaceholderTexture() {
if (_whitePlaceholderTexture != null) {
return _whitePlaceholderTexture!;
}
_whitePlaceholderTexture = gpu.gpuContext.createTexture(
gpu.StorageMode.hostVisible,
1,
1,
);
if (_whitePlaceholderTexture == null) {
throw Exception('Failed to create white placeholder texture.');
}
_whitePlaceholderTexture!.overwrite(
Uint32List.fromList(<int>[0xFFFFFFFF]).buffer.asByteData(),
);
return _whitePlaceholderTexture!;
}