Forge Pipeline Texture Compressionのロゴ

Forge Pipeline Texture Compression

コミュニティ
Nebulavenus
forge-pipeline-texture-compression

Load GPU block-compressed textures (BC7/BC5) through the asset pipeline. Covers basisu encoding, UASTC transcoding, .ftex format, D3D12 alignment, and normal map channel handling.

概要

公開者Nebulavenus
リポジトリforge-gpu
スキル名forge-pipeline-texture-compression
スター
46
フォーク
7
同梱ファイル
指示のみ
ライセンスZlib
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    NebulavenusがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Forge Pipeline Texture Compression」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-pipeline-texture-compression
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Nebulavenus/forge-gpu.git /tmp/forge-gpu
mkdir -p .claude/skills
cp -r /tmp/forge-gpu/.claude/skills/forge-pipeline-texture-compression .claude/skills/forge-pipeline-texture-compression
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでForge Pipeline Texture Compressionを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にForge Pipeline Texture Compressionを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Forge Pipeline Texture Compressionは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

forge-pipeline-texture-compression

Load GPU block-compressed textures through forge_scene.h. The asset pipeline compresses textures at build time (basisu → KTX2 → .ftex), and forge_scene_load_pipeline_texture() uploads the pre-transcoded blocks directly to the GPU — no runtime transcoding or mip generation.

Compression pipeline

bash
# Build basisu (once)
cmake --build build --target basisu

# Color textures → BC7 sRGB
basisu -uastc -ktx2 -mipmap -file basecolor.jpg
forge_texture_tool basecolor.ktx2 basecolor.ftex bc7_srgb

# Normal maps → BC5 (requires both flags)
basisu -uastc -ktx2 -mipmap -normal_map -separate_rg_to_color_alpha -file normal.jpg
forge_texture_tool normal.ktx2 normal.ftex bc5_unorm

# Linear textures (metallic-roughness, occlusion) → BC7 linear
basisu -uastc -ktx2 -mipmap -file metallic_roughness.jpg
forge_texture_tool metallic_roughness.ktx2 metallic_roughness.ftex bc7_unorm

Both tools are CPU-only — no GPU required. Works on headless servers.

Format selection

Texture typebasisu flags.ftex formatSDL GPU format
Base color(none)bc7_srgbBC7_RGBA_UNORM_SRGB
Emissive(none)bc7_srgbBC7_RGBA_UNORM_SRGB
Normal map-normal_map -separate_rg_to_color_alphabc5_unormBC5_RG_UNORM
Metallic-roughness(none)bc7_unormBC7_RGBA_UNORM
Occlusion(none)bc7_unormBC7_RGBA_UNORM

Normal map encoding — why both flags matter

-separate_rg_to_color_alpha: The Basis Universal BC5 transcoder reads channels 0 (R) and 3 (Alpha), not 0 (R) and 1 (G). This flag moves G into alpha during UASTC encoding so BC5 gets the correct data. Without it, the Y normal component is lost (all 255).

-normal_map: Treats input as linear data (not sRGB) and optimizes UASTC encoding for angular error rather than perceptual color error.

Sidecar detection

forge_scene_load_pipeline_texture() checks for a .meta.json sidecar next to each texture. If the sidecar has a compression block pointing to a .ftex file, the compressed path is used. Otherwise, it falls back to SDL_LoadSurface + GPU mipmaps.

Example .meta.json:

json
{
  "source": "basecolor.jpg",
  "output": "basecolor.jpg",
  "output_width": 2048,
  "output_height": 2048,
  "compression": {
    "codec": "uastc",
    "container": "ktx2",
    "compressed_file": "basecolor.ktx2",
    "ratio": 6.32,
    "normal_map": true
  }
}

D3D12 alignment requirement

D3D12 requires 256-byte row pitch alignment and 512-byte mip offset alignment for texture uploads. forge_scene_upload_compressed_texture() handles this by padding block rows and aligning offsets in the transfer buffer. Vulkan has no such requirement.

Small BC7/BC5 mips (≤32×32) have row pitches below 256 bytes. Without padding, SDL's D3D12 backend crashes non-deterministically.

Usage pattern

c
#define FORGE_PIPELINE_IMPLEMENTATION
#include "pipeline/forge_pipeline.h"

#define FORGE_SCENE_MODEL_SUPPORT
#define FORGE_SCENE_IMPLEMENTATION
#include "scene/forge_scene.h"

/* Load model — compressed textures are detected automatically */
ForgeSceneModel model;
forge_scene_load_model(&scene, &model,
                       "assets/Model/Model.fscene",
                       "assets/Model/Model.fmesh",
                       "assets/Model/Model.fmat",
                       "assets/Model");

/* Check compression stats */
SDL_Log("Textures: %u/%u compressed, VRAM: %.1f MB (%.1f MB uncompressed)",
        model.vram.compressed_texture_count, model.vram.total_texture_count,
        (float)model.vram.compressed_bytes / (1024.0f * 1024.0f),
        (float)model.vram.uncompressed_bytes / (1024.0f * 1024.0f));

.ftex binary format

text
Header (32 bytes):
  magic       u32    "FTEX" (0x58455446)
  version     u32    1
  format      u32    1=BC7_SRGB, 2=BC7_UNORM, 3=BC5_UNORM
  width       u32    base mip width
  height      u32    base mip height
  mip_count   u32    number of mip levels
  reserved    u32    0
  reserved    u32    0

Mip entries (16 bytes each × mip_count):
  offset      u32    byte offset from file start
  data_size   u32    compressed block data size
  width       u32    mip level width
  height      u32    mip level height

Block data:
  Contiguous compressed blocks, mip 0 first

Shader compatibility

The fragment shader reconstructs Z from RG for normal maps:

hlsl
float2 n_rg = normal_tex.Sample(normal_smp, uv).rg * 2.0 - 1.0;
float3 n = float3(n_rg, sqrt(saturate(1.0 - dot(n_rg, n_rg))));

This works for both BC5 (RG only) and RGBA8 (ignores B, recomputes Z).

Common mistakes

  • Missing -separate_rg_to_color_alpha for normal maps. BC5 transcoding reads R and Alpha channels, not R and G. Without this flag, the Y normal component is all 1.0 and lighting is completely wrong.
  • Missing -normal_map for normal maps. Without it, basisu treats the input as sRGB and optimizes for perceptual color error instead of angular error. Quality degrades.
  • Unaligned compressed texture uploads on D3D12. Small mips (≤32×32) have row pitches below 256 bytes. Pad block rows to 256-byte alignment and align mip offsets to 512 bytes, or SDL's D3D12 backend crashes.
  • Forgetting pixels_per_row after padding. If you pad the transfer buffer but don't set pixels_per_row on SDL_GPUTextureTransferInfo, SDL doesn't know the stride and reads garbage.
  • Using BC7 sRGB for linear data. Metallic-roughness and occlusion textures are linear — use bc7_unorm, not bc7_srgb.

Reference

  • GPU Lesson 42 — full lesson with debugging walkthrough
  • GPU Lesson 41 — model loading foundation
  • common/scene/forge_scene.h — forge_scene_upload_compressed_texture()
  • common/pipeline/forge_pipeline.h — forge_pipeline_load_ftex()
  • tools/texture/main.c — forge_texture_tool (KTX2 → .ftex)

よくある質問

AIスキル「Forge Pipeline Texture Compression」では何ができますか?

Load GPU block-compressed textures (BC7/BC5) through the asset pipeline. Covers basisu encoding, UASTC transcoding, .ftex format, D3D12 alignment, and normal map channel handling.

TypingMindでForge Pipeline Texture Compressionを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Forge Pipeline Texture Compressionはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにForge Pipeline Texture Compressionをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-pipeline-texture-compressionを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Forge Pipeline Texture Compressionを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Forge Pipeline Texture Compressionで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもForge Pipeline Texture Compressionを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Forge Pipeline Texture Compression」は無料ですか?

はい。NebulavenusがZlibライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇