getNormalPlaceholderTexture static method
Returns a 1×1 "flat" tangent-space normal texture ((0.5, 0.5, 1)),
lazily created on first use.
Used as a default for missing normal maps so shader code can always sample without conditionals.
Implementation
static gpu.Texture getNormalPlaceholderTexture() {
if (_normalPlaceholderTexture != null) {
return _normalPlaceholderTexture!;
}
_normalPlaceholderTexture = gpu.gpuContext.createTexture(
gpu.StorageMode.hostVisible,
1,
1,
);
if (_normalPlaceholderTexture == null) {
throw Exception('Failed to create normal placeholder texture.');
}
_normalPlaceholderTexture!.overwrite(
Uint32List.fromList(<int>[0xFFFF7F7F]).buffer.asByteData(),
);
return _normalPlaceholderTexture!;
}