Forge Uniforms And Motionのロゴ

Forge Uniforms And Motion

コミュニティ
Nebulavenus
forge-uniforms-and-motion

プッシュユニフォームを使ってフレームごとのデータをシェーダーに渡します。ジオメトリのアニメーション、時間・行列・色のシェーダーへの受け渡し、SDL3 GPUでのユニフォームバッファーの設定に使用します。

概要

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

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

  • どのLLMでも利用可能

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

  • 指示だけで完結

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

  • オープンソース

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

インストール

AIスキル「Forge Uniforms And Motion」を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-uniforms-and-motion
  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-uniforms-and-motion .claude/skills/forge-uniforms-and-motion
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

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

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

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

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

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

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

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

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

スキルの指示

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

Uniforms & Motion — Push Uniforms for Per-Frame Data

This skill teaches how to pass data from the CPU to GPU shaders every frame using SDL3's push uniform API. It builds on the first-triangle skill (vertex buffers, shaders, pipeline).

When to use

  • Passing per-frame data to shaders (time, matrices, colors, parameters)
  • Animating geometry on the GPU
  • Setting up uniform buffers in a graphics pipeline
  • Any draw call that needs data beyond vertex attributes

Push uniforms vs. GPU uniform buffers

MethodWhen to use
Push uniforms (SDL_PushGPUVertexUniformData)Small data that changes frequently — time, MVP matrices, colors
GPU uniform buffer (create + upload)Large or rarely-changing data

Push uniforms are the simple path: push a pointer to a C struct, SDL copies it internally. No buffer creation, no transfer buffers, no copy passes.

Uniform data struct

Define a C struct matching your shader's cbuffer layout:

c
typedef struct Uniforms {
    float time;     /* elapsed time in seconds                     */
    float aspect;   /* window width / height — for correcting NDC  */
} Uniforms;

std140 layout rules: vec3 and vec4 fields must be 16-byte aligned. A single float or a float4 is naturally aligned. If you mix types, add padding.

HLSL shader convention

SDL GPU maps uniform buffer slots to specific HLSL registers:

StageSlot 0 registerSlot 1 register
Vertexregister(b0, space1)register(b1, space1)
Fragmentregister(b0, space3)register(b1, space3)
hlsl
/* Vertex shader — uniform slot 0 */
cbuffer Uniforms : register(b0, space1)
{
    float time;
    float aspect;
};

VSOutput main(VSInput input)
{
    /* Correct for non-square windows BEFORE rotation so the triangle
     * keeps its shape at every angle.  If done after, the squish
     * would distort the already-rotated coordinates. */
    float2 corrected = float2(input.position.x / aspect, input.position.y);

    float c = cos(time);
    float s = sin(time);

    float2 rotated;
    rotated.x = corrected.x * c - corrected.y * s;
    rotated.y = corrected.x * s + corrected.y * c;

    VSOutput output;
    output.position = float4(rotated, 0.0, 1.0);
    output.color    = float4(input.color, 1.0);
    return output;
}

Shader creation — declaring uniform count

When creating a shader, num_uniform_buffers must match the number of cbuffers your shader code declares:

c
SDL_GPUShaderCreateInfo info = { 0 };
info.stage               = SDL_GPU_SHADERSTAGE_VERTEX;
info.entrypoint          = "main";
info.num_uniform_buffers = 1;   /* ← must match shader's cbuffer count */
info.num_samplers        = 0;
info.num_storage_textures = 0;
info.num_storage_buffers = 0;
/* ... code, code_size, format ... */

SDL_GPUShader *shader = SDL_CreateGPUShader(device, &info);

Pushing uniform data — each frame

c
/* 1. Compute your per-frame data */
float elapsed = (float)(SDL_GetTicks() - start_ticks) / 1000.0f;

int w = 0, h = 0;
SDL_GetWindowSizeInPixels(window, &w, &h);

Uniforms uniforms;
uniforms.time   = elapsed;
uniforms.aspect = (h > 0) ? (float)w / (float)h : 1.0f;

/* 2. Acquire command buffer */
SDL_GPUCommandBuffer *cmd = SDL_AcquireGPUCommandBuffer(device);

/* 3. Push BEFORE the render pass */
SDL_PushGPUVertexUniformData(cmd, 0, &uniforms, sizeof(uniforms));

/* 4. Begin render pass and draw as usual */
SDL_GPURenderPass *pass = SDL_BeginGPURenderPass(cmd, &color_target, 1, NULL);
SDL_BindGPUGraphicsPipeline(pass, pipeline);
SDL_BindGPUVertexBuffers(pass, 0, &binding, 1);
SDL_DrawGPUPrimitives(pass, vertex_count, 1, 0, 0);
SDL_EndGPURenderPass(pass);

SDL_SubmitGPUCommandBuffer(cmd);

Key details:

  • Push happens on the command buffer, not the render pass
  • Push before SDL_BeginGPURenderPass — SDL latches the data at pass start
  • Data is copied internally — your struct can live on the stack
  • Slot 0 in the push call matches b0 in the HLSL register
  • Each stage (vertex/fragment) has 4 independent slots (0–3)
  • Data persists in a slot until you push new data to it

Fragment shader uniforms

Same pattern, different function and register space:

c
SDL_PushGPUFragmentUniformData(cmd, 0, &frag_uniforms, sizeof(frag_uniforms));
hlsl
cbuffer FragUniforms : register(b0, space3)    /* space3 for fragment */
{
    float brightness;
};

Tracking time

c
/* In app_state */
Uint64 start_ticks;

/* In SDL_AppInit */
state->start_ticks = SDL_GetTicks();

/* In SDL_AppIterate */
float elapsed = (float)(SDL_GetTicks() - state->start_ticks) / 1000.0f;

SDL_GetTicks() returns milliseconds since SDL_Init. Dividing by 1000 gives seconds as a float — ideal for shader math like sin(time) and cos(time).

Common mistakes

MistakeFix
num_uniform_buffers = 0 but shader has a cbufferMust match — set to 1 (or however many cbuffers your shader declares)
Pushing uniform data after SDL_BeginGPURenderPassPush before the render pass — SDL latches uniforms at pass start
Wrong register space in HLSLVertex = space1, Fragment = space3
Forgetting std140 alignment for vec3/vec4Pad structs so vec3/vec4 start at 16-byte boundaries
Using SDL_PushGPUVertexUniformData for fragment dataUse SDL_PushGPUFragmentUniformData for fragment stage
Not declaring num_uniform_buffers on the fragment shaderEach stage declares its own count independently
Rotation looks skewed on non-square windowsPass aspect ratio as uniform, divide x by it before rotation
Aspect correction applied after rotationTriangle skews at certain angles — correct before rotating so you rotate in uniform space
Triangle wobbles instead of spinning in placeCenter vertices so centroid is at origin (average of all positions = 0,0)

Cleanup

No extra cleanup needed for push uniforms — there are no GPU buffer objects to release. The only cleanup is the same as Lesson 02 (pipeline, vertex buffer, window, device).

よくある質問

AIスキル「Forge Uniforms And Motion」では何ができますか?

プッシュユニフォームを使ってフレームごとのデータをシェーダーに渡します。ジオメトリのアニメーション、時間・行列・色のシェーダーへの受け渡し、SDL3 GPUでのユニフォームバッファーの設定に使用します。

TypingMindでForge Uniforms And Motionを使うメリットは何ですか?

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

TypingMindにForge Uniforms And Motionをインストールするにはどうすればよいですか?

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

Forge Uniforms And Motionを使えるAIモデルはどれですか?

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

Forge Uniforms And Motionで使えるAIモデルの数に制限はありますか?

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

AIスキル「Forge Uniforms And Motion」は無料ですか?

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

AIスキルとは何ですか?

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

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

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

すべて見る

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

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