패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소bdero/flutter_gpu_shaders

flutter_gpu_shaders

Build tools for Flutter GPU shader bundles/libraries.

flutter_gpu_shaders 프로젝트 이미지
스타
18
포크
12
최근 푸시(UTC)
2026. 8. 11.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

Build tools for Flutter GPU shader bundles/libraries.

Features

Use native asset build hooks to import Flutter GPU shader bundle assets.

Getting started

  1. 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.
  2. 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:
    {
        "CoolVertex": {
            "type": "vertex",
            "file": "shaders/my_cool_shader.vert"
        },
        "CoolFragment": {
            "type": "fragment",
            "file": "shaders/my_cool_shader.frag"
        }
    }
    
  3. 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:
    import 'package:hooks/hooks.dart';
    import 'package:flutter_gpu_shaders/build.dart';
    
    void main(List<String> args) async {
      await build(args, (config, output) async {
        await buildShaderBundleJson(
            buildInput: config,
            buildOutput: output,
            manifestFileName: 'my_cool_bundle.shaderbundle.json');
      });
    }
    
    buildShaderBundleJson always declares the manifest and directly listed shader files as build dependencies. With Flutter SDKs whose impellerc supports --depfile for shader bundles, it also declares transitive #include dependencies from the generated depfile. Older impellerc builds continue to use the manifest scan fallback.
  4. In your project's pubspec.yaml, add the built shader bundle as an asset:
    flutter:
      assets:
        - build/shaderbundles/my_cool_bundle.shaderbundle
    
  5. If your Flutter toolchain supports Dart DataAssets, you can opt in to registering the generated bundle with the Flutter asset bundle instead of listing it in pubspec.yaml:
    await buildShaderBundleJson(
      buildInput: config,
      buildOutput: output,
      manifestFileName: 'my_cool_bundle.shaderbundle.json',
      assetMode: ShaderBundleAssetMode.dataAssetsIfAvailable,
    );
    
    With DataAssets enabled, the result's flutterAssetKey is the key to pass to gpu.ShaderLibrary.fromAsset. When DataAssets are unavailable, dataAssetsIfAvailable falls back to the legacy file output. Use ShaderBundleAssetMode.dataAssetsRequired to fail fast with guidance instead.
  6. You can now import the built shader bundle as a library using gpu.ShaderLibrary.fromAsset in your project. For example:
    import 'package:flutter_gpu/gpu.dart' as gpu;
    
    final String _kBaseShaderBundlePath =
        'build/shaderbundles/my_cool_bundle.shaderbundle';
    
    gpu.ShaderLibrary? _baseShaderLibrary;
    gpu.ShaderLibrary get baseShaderLibrary {
      if (_baseShaderLibrary != null) {
        return _baseShaderLibrary!;
      }
      _baseShaderLibrary = gpu.ShaderLibrary.fromAsset(_kBaseShaderBundlePath);
      if (_baseShaderLibrary != null) {
        return _baseShaderLibrary!;
      }
    
      throw Exception(
          "Failed to load base shader bundle! ($_kBaseShaderBundlePath)");
    }
    
Brandon DeRosier GitHub avatar
GitHub 작성자

Brandon DeRosier ↗

I print colors to the screen. Building Flutter GPU and fscene.dev. Expanding what you can create using Flutter & Dart.

California
언어DartShellGLSL

분류

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 7 개

  • crypto^3.0.3
  • data_assets^0.20.0
  • flutter{"sdk":"flutter"}
  • hooks^2.0.0
  • logging^1.3.0
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^6.0.0

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗