ent_shaders 0.1.0-dev.2
ent_shaders: ^0.1.0-dev.2 copied to clipboard
The shaders of Ent Engine, written once for every renderer: the GLSL of the fixed shaders and the materials, and the variant scheme that turns the material setups an app lists into shader sources.
Example #
An app uses ent_shaders through a renderer, such as ent_flutter, and only tells it which material variants to
compile. List them in a registry file beside the app's pubspec.yaml, ent_shaders.json:
{
"variants": [
"basic map",
"lambert map normal_map",
"physical ao_map metalness_map roughness_map"
]
}
Name it in pubspec.yaml, under the renderer package the app uses (ent_flutter or ent_opengl), whose build
hook compiles the shaders:
hooks:
user_defines:
ent_flutter:
shaders: ent_shaders.json
The next build compiles these variants with the fixed shaders into the renderer's shader bundle. A renderer drawing a
material whose variant is missing throws a StateError naming the key to add.
To collect the keys an app needs, ent_flutter's renderer can record them while the app runs through its scenes:
final renderer = await FlutterGpuRenderer.create();
renderer.recorded = {};
// After the scenes:
debugPrint(JsonEncoder.withIndent('\t').convert({'variants': renderer.recorded!.toList()..sort()}));