load static method
Loads and caches a fragment program for shaderPath.
Implementation
static Future<ui.FragmentProgram> load(String shaderPath) async {
if (_cache.containsKey(shaderPath)) {
return _cache[shaderPath]!;
}
try {
final program = await ui.FragmentProgram.fromAsset(shaderPath);
_cache[shaderPath] = program;
return program;
} on FormatException catch (e) {
const message = '''Shader format error - this usually means:
1. GLSL syntax is incompatible with Flutter runtime
2. Missing #include <flutter/runtime_effect.glsl>
3. Using unsupported GLSL features
4. Incorrect uniform declarations
5. Invalid precision qualifiers (lowp, mediump, highp)
6. Unsupported texture formats or samplers
7. Missing main() function or incorrect signature
8. Incompatible varying declarations
9. Disallowed built-in variables or functions
10. Version directive mismatch (#version conflicts)''';
debugPrint('loadFragmentProgram.error: $shaderPath $e');
throw FormatException('$shaderPath: $message', e.source);
} on PlatformException catch (e) {
debugPrint('loadFragmentProgram.error: $shaderPath $e');
rethrow;
}
}