{"id":15463789,"url":"https://github.com/bdero/flutter_gpu_shaders","last_synced_at":"2025-04-22T10:36:56.031Z","repository":{"id":249717401,"uuid":"832382506","full_name":"bdero/flutter_gpu_shaders","owner":"bdero","description":"Build tools for Flutter GPU shader bundles/libraries.","archived":false,"fork":false,"pushed_at":"2025-04-13T04:22:22.000Z","size":17,"stargazers_count":12,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-22T10:36:22.207Z","etag":null,"topics":["build-hook","flutter","flutter-gpu"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flutter_gpu_shaders","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdero.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-22T23:14:37.000Z","updated_at":"2025-04-13T04:22:26.000Z","dependencies_parsed_at":"2024-07-22T23:48:04.112Z","dependency_job_id":"72ecc843-2c5b-4091-85d4-982cdf457bdb","html_url":"https://github.com/bdero/flutter_gpu_shaders","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"429174206434120be2c3f25b74f9d0ffd2cd2ccb"},"previous_names":["bdero/flutter_gpu_shaders"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdero%2Fflutter_gpu_shaders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdero%2Fflutter_gpu_shaders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdero%2Fflutter_gpu_shaders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdero%2Fflutter_gpu_shaders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdero","download_url":"https://codeload.github.com/bdero/flutter_gpu_shaders/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250221779,"owners_count":21394764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-hook","flutter","flutter-gpu"],"created_at":"2024-10-02T00:23:44.707Z","updated_at":"2025-04-22T10:36:56.002Z","avatar_url":"https://github.com/bdero.png","language":"Dart","readme":"Build tools for Flutter GPU shader bundles/libraries.\n\n## Features\n\nUse native asset build hooks to import Flutter GPU shader bundle assets.\n\n## Getting started\n\n1. This package requires the experimental \"native assets\" feature to be enabled. Enable it with the following command:\n    ```bash\n    flutter config --enable-native-assets\n    ```\n2. Place some Flutter GPU shaders in your project. For this example, we'll assume the existence of two shaders: `shaders/my_cool_shader.vert` and `shaders/my_cool_shader.frag`.\n3. Create a shader bundle manifest file in your project. The filename must end with `.shaderbundle.json`. For this example, we'll assume the following file is saved as `my_cool_bundle.shaderbundle.json`:\n    ```json\n    {\n        \"CoolVertex\": {\n            \"type\": \"vertex\",\n            \"file\": \"shaders/my_cool_shader.vert\"\n        },\n        \"CoolFragment\": {\n            \"type\": \"fragment\",\n            \"file\": \"shaders/my_cool_shader.frag\"\n        }\n    }\n    ```\n4. Next, define a build hook in your project that builds the shader bundle using `buildShaderBundleJson`. The build hook must be named `hook/build.dart` in your project; this script will be automatically invoked by Flutter when the \"native assets\" feature is enabled:\n    ```dart\n    import 'package:native_assets_cli/native_assets_cli.dart';\n    import 'package:flutter_gpu_shaders/build.dart';\n\n    void main(List\u003cString\u003e args) async {\n      await build(args, (config, output) async {\n        await buildShaderBundleJson(\n            buildConfig: config,\n            buildOutput: output,\n            manifestFileName: 'my_cool_bundle.shaderbundle.json');\n      });\n    }\n    ```\n5. In your project's `pubspec.yaml`, add an asset import rule to package the built shader bundles (this will become unnecessary once \"native assets\" supports `DataAsset` in a future release of Flutter):\n    ```yaml\n    flutter:\n      assets:\n        - build/shaderbundles/*.shaderbundle.json\n    ```\n6. You can now import the built shader bundle as a library using `gpu.ShaderLibrary.fromAsset` in your project. For example:\n    ```dart\n    import 'package:flutter_gpu/gpu.dart' as gpu;\n    \n    final String _kBaseShaderBundlePath =\n        'packages/my_project/build/shaderbundles/my_cool_bundle.shaderbundle';\n    \n    gpu.ShaderLibrary? _baseShaderLibrary = null;\n    gpu.ShaderLibrary get baseShaderLibrary {\n      if (_baseShaderLibrary != null) {\n        return _baseShaderLibrary!;\n      }\n      _baseShaderLibrary = gpu.ShaderLibrary.fromAsset(_kBaseShaderBundlePath);\n      if (_baseShaderLibrary != null) {\n        return _baseShaderLibrary!;\n      }\n    \n      throw Exception(\n          \"Failed to load base shader bundle! ($_kBaseShaderBundlePath)\");\n    }\n    ```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdero%2Fflutter_gpu_shaders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdero%2Fflutter_gpu_shaders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdero%2Fflutter_gpu_shaders/lists"}