loadShader static method
Loads a shader program from the given path
. If the program is already in
the cache, it is returned directly. Otherwise, the program is loaded from
the given path and stored in the cache (with the optional cacheId
) for
future use.
Implementation
static Future<FragmentProgram> loadShader(String path,
[String? cacheId]) async {
if (shaderCache.containsKey(cacheId)) {
return shaderCache[cacheId]!;
}
final program = await FragmentProgram.fromAsset(path);
if (cacheId != null) shaderCache[cacheId] = program;
return program;
}