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

패키지 상세v0.5.2

flutter_gpu_shaders

Build tools for Flutter GPU shader bundles/libraries.

AndroidiOSLinuxmacOSWindows
30일 다운로드
7.8만
좋아요
21
Pub 점수
150

패키지 설치

flutter pub add flutter_gpu_shaders

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

A Flutter package that provides tools for creating and managing GPU shader bundles and libraries, enabling high-performance 3D graphics rendering. It supports integration with Flutter's rendering pipeline on multiple platforms including Android, iOS, Linux, macOS, and Windows. The package is designed for developers building complex visual effects, games, or data visualization applications requiring low-level GPU control. By bundling shaders efficiently, it streamlines the development workflow and enhances performance through optimized shader execution.

사용 사례

  • 3D game development
  • real-time data visualization
  • complex UI animations
  • high-performance graphics rendering
  • shader-based visual effects

주요 기능

  • Cross-platform GPU shader support
  • Efficient shader bundle management
  • Integration with Flutter's rendering pipeline
  • Optimized performance for 3D content
  • Tooling for shader compilation and packaging

적합한 대상

  • Developers working on 3D applications
  • Game engine creators in Flutter
  • Visual effects specialists
  • High-performance UI designers
  • Graphics-intensive app builders

고려 사항

  • Requires knowledge of GLSL or HLSL
  • Limited to GPU-accelerated rendering
  • May increase build complexity
  • Best suited for advanced users
  • Platform-specific shader behavior may vary

원본 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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.

순위