搜尋套件、儲存庫與 APP 分類

套件詳情v0.5.2

flutter_gpu_shaders

用於 Flutter GPU 着色器套件/函式庫的建構工具。

AndroidiOSLinuxmacOSWindows
近 30 天下載
10.9萬
喜歡數
21
Pub 分數
150

安裝套件

flutter pub add flutter_gpu_shaders

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,提供建立與管理 GPU 着色器套件與程式庫的工具,支援高效率的 3D 圖形繪製。支援與 Flutter 渲染流程在多個平台(包括 Android、iOS、Linux、macOS 與 Windows)整合。此套件專為需要底層 GPU 控制權的複雜視覺效果、遊戲或資料視覺化應用開發者設計。透過有效率地打包著色器,可簡化開發流程,並透過優化的著色器執行提升效能。

適用情境

  • 3D 遊戲開發
  • 即時資料視覺化
  • 複雜的UI動畫
  • 高效能圖形渲染
  • 基於著色器的視覺效果

主要特色

  • 跨平台 GPU 着色器支援
  • 高效著色器套件管理
  • 與 Flutter 渲染管道的整合
  • 針對3D內容優化的效能
  • 用於著色器編譯和打包的工具

適合對象

  • 開發3D應用的開發者
  • Flutter 中的遊戲引擎創建者
  • 視覺效果專家
  • 高效能UI設計
  • 圖形密集型應用建構器

使用建議

  • 需要了解 GLSL 或 HLSL
  • 僅限GPU加速渲染
  • 可能增加建構複雜性
  • 最適合進階使用者
  • 平台特定的著色器行為可能有所差異

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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)");
    }
    

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。

所在榜單