Forge Shader Noiseのロゴ

Forge Shader Noise

コミュニティ
Nebulavenus
forge-shader-noise

SDL GPUプロジェクトにGPUノイズ関数(hash、value、Perlin、fBm、domain warping)を追加します

概要

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

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

  • どのLLMでも利用可能

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

  • 指示だけで完結

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

  • オープンソース

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

インストール

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

TypingMindで使用

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

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

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

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

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

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

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

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

スキルの指示

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

Shader Noise

Add procedural noise functions to an SDL GPU fragment shader. Implements GPU-friendly hash functions, value noise, Perlin gradient noise, fBm (fractal Brownian motion), and domain warping — all running per-pixel on the GPU with no texture assets.

When to use

  • Procedural textures (marble, wood, clouds, terrain)
  • Terrain height and coloring without texture assets
  • Dissolve and erosion effects
  • Adding organic variation to materials or lighting
  • Any situation requiring randomness in a fragment shader

HLSL noise library

Add these functions to your fragment shader. They are self-contained and require no external textures or buffers.

Hash functions

GPU shaders lack rand(). Use deterministic integer hashes instead — same input always produces the same output.

hlsl
/* Thomas Wang 32-bit integer hash — good avalanche properties */
uint wang_hash(uint seed)
{
    seed = (seed ^ 61u) ^ (seed >> 16u);
    seed *= 9u;
    seed = seed ^ (seed >> 4u);
    seed *= 0x27d4eb2du;
    seed = seed ^ (seed >> 15u);
    return seed;
}

/* Map hash to float in [0, 1) */
float hash_to_float(uint h)
{
    return float(h) / 4294967296.0;
}

/* Combine two hash values (Boost hash_combine pattern) */
uint hash_combine(uint seed, uint value)
{
    return seed ^ (value + 0x9e3779b9u + (seed << 6u) + (seed >> 2u));
}

/* Hash 2D integer coordinates to uint */
uint hash2d_uint(int2 p)
{
    uint h = wang_hash(uint(p.x));
    h = hash_combine(h, uint(p.y));
    return wang_hash(h);
}

/* Hash 2D integer coordinates to float in [0, 1) */
float hash2d(int2 p)
{
    return hash_to_float(hash2d_uint(p));
}

White noise

Random value per integer cell. Useful for TV static, sparkle effects.

hlsl
float white_noise(float2 p, float time_seed)
{
    int2 ip = int2(floor(p));
    uint seed = hash_combine(hash2d_uint(ip), uint(time_seed * 60.0));
    return hash_to_float(seed);
}

Value noise

Smoothly interpolated random values at lattice points.

hlsl
float value_noise(float2 p)
{
    int2 i = int2(floor(p));
    float2 f = frac(p);
    float2 u = f * f * (3.0 - 2.0 * f);  /* Hermite smoothstep */

    float a = hash2d(i);
    float b = hash2d(i + int2(1, 0));
    float c = hash2d(i + int2(0, 1));
    float d = hash2d(i + int2(1, 1));

    return lerp(lerp(a, b, u.x), lerp(c, d, u.x), u.y);
}

Gradient noise (Perlin 2D)

Smoother than value noise with C2 continuity.

hlsl
float grad2d(uint hash, float2 d)
{
    uint h = hash & 3u;
    float u = ((h & 1u) != 0u) ? -d.x : d.x;
    float v = ((h & 2u) != 0u) ? -d.y : d.y;
    return u + v;
}

float2 quintic(float2 t)
{
    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
}

float perlin2d(float2 p)
{
    int2 i = int2(floor(p));
    float2 f = frac(p);
    float2 u = quintic(f);

    float a = grad2d(hash2d_uint(i),              f);
    float b = grad2d(hash2d_uint(i + int2(1, 0)), f - float2(1.0, 0.0));
    float c = grad2d(hash2d_uint(i + int2(0, 1)), f - float2(0.0, 1.0));
    float d = grad2d(hash2d_uint(i + int2(1, 1)), f - float2(1.0, 1.0));

    return lerp(lerp(a, b, u.x), lerp(c, d, u.x), u.y);
}

fBm (fractal Brownian motion)

Stack multiple octaves of Perlin noise for natural fractal detail.

hlsl
float fbm(float2 p)
{
    float value     = 0.0;
    float amplitude = 0.5;
    float frequency = 1.0;

    for (int oct = 0; oct < 6; oct++)
    {
        value     += amplitude * perlin2d(p * frequency);
        frequency *= 2.0;   /* lacunarity  */
        amplitude *= 0.5;   /* persistence */
    }

    return value;
}

Domain warping

Compose fBm with itself for organic, marble-like patterns.

hlsl
float domain_warp(float2 p)
{
    float2 q = float2(
        fbm(p + float2(0.0, 0.0)),
        fbm(p + float2(5.2, 1.3))
    );

    float2 r = float2(
        fbm(p + 4.0 * q + float2(1.7, 9.2)),
        fbm(p + 4.0 * q + float2(8.3, 2.8))
    );

    return fbm(p + 4.0 * r);
}

Dithering (Interleaved Gradient Noise)

Break up 8-bit color banding with blue-noise-like dithering.

hlsl
float ign(float2 screen_pos)
{
    float3 ign_coeffs = float3(0.06711056, 0.00583715, 52.9829189);
    return frac(ign_coeffs.z * frac(dot(screen_pos, ign_coeffs.xy)));
}

/* Apply after computing final color: */
color += (ign(screen_pos) - 0.5) / 255.0;

Integration pattern

Using noise in an existing scene shader

Add the noise functions to your fragment shader and use them to modify materials, lighting, or geometry:

hlsl
/* Procedural terrain coloring */
float height = fbm(world_pos.xz * 0.1);
float3 base_color = terrain_color(height);

/* Add organic variation to a material */
float variation = perlin2d(world_pos.xz * 2.0 + time * 0.1);
diffuse_color *= 0.9 + 0.1 * variation;

/* Dissolve effect */
float noise = fbm(world_pos * 3.0);
clip(noise - dissolve_threshold);  /* discard if below threshold */

Fullscreen noise visualization

For standalone noise visualization, use the SV_VertexID fullscreen quad pattern from Lesson 21 — HDR & Tone Mapping (no vertex buffer, pipeline with no vertex input state).

Fragment uniforms (register b0, space3 for SDL GPU):

hlsl
cbuffer NoiseParams : register(b0, space3)
{
    float  time;
    int    mode;
    int    dither_enabled;
    float  scale;
    float2 resolution;
    float2 _pad;
};

C-side uniform struct

c
typedef struct NoiseUniforms {
    float time;
    int   mode;
    int   dither_enabled;
    float scale;
    vec2  resolution;
    float _pad[2];
} NoiseUniforms;

Common patterns

Aspect-correct noise coordinates

hlsl
float aspect = resolution.x / resolution.y;
float2 p = uv * scale;
p.x *= aspect;  /* prevent stretching */

Remapping noise range

Perlin/fBm output is approximately [-1, 1]. Remap to [0, 1] for display or color mapping:

hlsl
float n = fbm(p);
n = n * 0.5 + 0.5;  /* remap to [0, 1] */

Terrain color mapping

Map noise height to biome colors with smooth transitions:

hlsl
float3 color = deep_water;
color = lerp(color, grass,  smoothstep(0.38, 0.50, height));
color = lerp(color, rock,   smoothstep(0.62, 0.75, height));
color = lerp(color, snow,   smoothstep(0.75, 0.85, height));

Common mistakes

  • Forgetting aspect ratio correction — multiply uv.x *= aspect before sampling noise, otherwise noise cells appear stretched on non-square windows
  • Not remapping Perlin/fBm output — perlin2d() returns approximately [-1, 1]; use n * 0.5 + 0.5 to remap to [0, 1] for display or color mapping
  • cbuffer alignment — the uniform struct must be padded to a multiple of 16 bytes; misaligned fields silently read wrong values on some backends
  • Using int casts on negative coordinates — int2(floor(p)) is correct; int2(p) truncates toward zero, causing a seam at the origin where two adjacent cells map to the same integer
  • Animating white noise with frac(time) — produces periodic patterns; use hash_combine with an integer time seed instead for true per-frame randomness

Reference

よくある質問

AIスキル「Forge Shader Noise」では何ができますか?

SDL GPUプロジェクトにGPUノイズ関数(hash、value、Perlin、fBm、domain warping)を追加します

TypingMindでForge Shader Noiseを使うメリットは何ですか?

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

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

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

Forge Shader Noiseを使えるAIモデルはどれですか?

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

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

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

AIスキル「Forge Shader Noise」は無料ですか?

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

AIスキルとは何ですか?

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

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

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

すべて見る

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

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