Forge Gobo Spotlightのロゴ

Forge Gobo Spotlight

コミュニティ
Nebulavenus
forge-gobo-spotlight

SDL GPUプロジェクトに、コーン状の減衰、シャドウマップ、パターン投影に対応した投影テクスチャ(ゴボ/クッキー)スポットライトを追加します

概要

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

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

  • どのLLMでも利用可能

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

  • 指示だけで完結

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

  • オープンソース

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

インストール

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

TypingMindで使用

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

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

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

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

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

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

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

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

スキルの指示

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

Add a spotlight with inner/outer cone angles, projected gobo texture, and a single 2D shadow map. The spotlight's view-projection matrix serves triple duty — shadow mapping, gobo UV projection, and cone masking. Based on GPU Lesson 24.

When to use

  • You need a focused light source with a defined cone (not omnidirectional)
  • You want to project a pattern (window, foliage, abstract) through a light
  • You need shadows from a spotlight (simpler than point light cube maps)
  • You are building theatrical, cinematic, or stage-style lighting
  • You already have an HDR rendering pipeline and Blinn-Phong lighting

Key API calls

  • SDL_CreateGPUTexture — shadow depth map (D32_FLOAT, 2D, SAMPLER | DEPTH_STENCIL_TARGET)
  • SDL_CreateGPUTexture — gobo texture (R8G8B8A8_UNORM, 2D, SAMPLER)
  • SDL_CreateGPUSampler — NEAREST + CLAMP for shadow, LINEAR + CLAMP for gobo
  • SDL_CreateGPUGraphicsPipeline — shadow pipeline (depth-only, no color targets)
  • SDL_BeginGPURenderPass — shadow pass with depth-only attachment
  • SDL_BindGPUFragmentSamplers — bind diffuse + shadow + gobo textures in scene pass

Correct order

  1. Define spotlight parameters — position, target, inner/outer cone angles, color, intensity
  2. Compute light view-projection — mat4_look_at(pos, target, up) + mat4_perspective(2 * outer_angle, 1.0, near, far)
  3. Create shadow depth texture — D32_FLOAT, same resolution for shadow map (e.g. 1024x1024)
  4. Create shadow sampler — NEAREST filter, CLAMP_TO_EDGE
  5. Load gobo texture — grayscale PNG as UNORM (not sRGB), LINEAR sampler, CLAMP_TO_EDGE
  6. Create shadow pipeline — vertex shader transforms by light_mvp, empty fragment shader, depth-only
  7. Create scene pipeline — increase num_samplers to include shadow + gobo (e.g. 3 total)
  8. Each frame: a. Shadow pass: render shadow casters from spotlight's perspective (depth-only) b. Scene pass: bind shadow map + gobo texture, fragment shader applies cone + gobo + shadow

Key concepts

  1. Spotlight cone: smoothstep(cos_outer, cos_inner, cos_angle) — cosine decreases with angle, so outer < inner
  2. Gobo projection: light_vp transforms world pos → clip → NDC → UV for gobo texture sampling
  3. Triple-duty matrix: the same light_vp handles shadow mapping, gobo UV mapping, and cone bounds
  4. Single 2D shadow map: a spotlight's perspective frustum captures everything in one pass (unlike cube maps for point lights)
  5. UNORM gobo texture: the gobo is a linear attenuation mask, not a color — use UNORM to avoid sRGB gamma
  6. Cone masking via UV bounds: fragments projecting outside [0,1] UV get zero light via step() functions

Common mistakes

  • Using sRGB format for the gobo texture — the gobo is a light attenuation mask sampled linearly. sRGB applies an unwanted gamma curve. Use R8G8B8A8_UNORM.
  • Wrong smoothstep parameter order — cosine is decreasing, so smoothstep(cos_outer, cos_inner, ...) with outer < inner. Swapping them inverts the cone.
  • Forgetting the Y-flip in UV remapping — texture V increases downward; NDC Y increases upward. Always flip: gobo_uv.y = 1.0 - gobo_uv.y.
  • Shadow acne from insufficient bias — add a small constant bias (0.002) when comparing depths in the shadow test.
  • Including the light source model as a shadow caster — the searchlight/lamp model sits at the light position and would block its own light. Exclude it from the shadow pass.
  • FOV not matching outer cone angle — the shadow/projection FOV must be 2 * outer_angle to cover the full spotlight cone. Too narrow clips shadows; too wide wastes resolution.

Spotlight definition

c
#define SPOT_INNER_DEG  20.0f   /* full-intensity inner cone half-angle */
#define SPOT_OUTER_DEG  30.0f   /* falloff-to-zero outer cone half-angle */
#define SPOT_INTENSITY  5.0f    /* HDR brightness */
#define SPOT_NEAR       0.5f
#define SPOT_FAR        30.0f
#define SHADOW_MAP_SIZE 1024

/* Compute spotlight view-projection (static light). */
vec3 spot_pos    = vec3_create(6.0f, 5.0f, 4.0f);
vec3 spot_target = vec3_create(0.0f, 0.0f, 0.0f);
vec3 spot_up     = vec3_create(0.0f, 1.0f, 0.0f);

mat4 light_view = mat4_look_at(spot_pos, spot_target, spot_up);
float outer_rad = SPOT_OUTER_DEG * FORGE_DEG2RAD;
mat4 light_proj = mat4_perspective(2.0f * outer_rad, 1.0f, SPOT_NEAR, SPOT_FAR);
mat4 light_vp   = mat4_multiply(light_proj, light_view);
vec3 spot_dir   = vec3_normalize(vec3_sub(spot_target, spot_pos));

Shadow depth texture

c
SDL_GPUTextureCreateInfo ti;
SDL_zero(ti);
ti.type                 = SDL_GPU_TEXTURETYPE_2D;
ti.format               = SDL_GPU_TEXTUREFORMAT_D32_FLOAT;
ti.width                = SHADOW_MAP_SIZE;
ti.height               = SHADOW_MAP_SIZE;
ti.layer_count_or_depth = 1;
ti.num_levels           = 1;
ti.usage                = SDL_GPU_TEXTUREUSAGE_SAMPLER
                        | SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET;

SDL_GPUTexture *shadow_depth = SDL_CreateGPUTexture(device, &ti);

Gobo texture loading

c
/* Use UNORM (not sRGB) — the gobo is a linear attenuation mask. */
SDL_GPUTextureCreateInfo tex_info;
SDL_zero(tex_info);
tex_info.type                = SDL_GPU_TEXTURETYPE_2D;
tex_info.format              = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM;
tex_info.width               = w;
tex_info.height              = h;
tex_info.layer_count_or_depth = 1;
tex_info.num_levels          = 1;
tex_info.usage               = SDL_GPU_TEXTUREUSAGE_SAMPLER;

/* Gobo sampler — linear filtering for smooth projection, clamp to edge. */
SDL_GPUSamplerCreateInfo si;
SDL_zero(si);
si.min_filter     = SDL_GPU_FILTER_LINEAR;
si.mag_filter     = SDL_GPU_FILTER_LINEAR;
si.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE;
si.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE;
si.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE;

Fragment shader — spotlight with gobo and shadow

hlsl
/* Direction from spotlight to fragment. */
float3 to_frag = world_pos - spot_pos;
float  dist    = length(to_frag);
float3 L_frag  = to_frag / dist;

/* Cone falloff. */
float cos_angle = dot(L_frag, normalize(spot_dir));
float cone = smoothstep(cos_outer, cos_inner, cos_angle);

if (cone > 0.0)
{
    /* Transform fragment into spotlight clip space. */
    float4 light_clip = mul(light_vp, float4(world_pos, 1.0));
    float3 light_ndc  = light_clip.xyz / light_clip.w;

    /* Gobo texture projection — remap NDC to UV space. */
    float2 gobo_uv = light_ndc.xy * 0.5 + 0.5;
    gobo_uv.y = 1.0 - gobo_uv.y;

    /* Cone masking — clamp to spotlight bounds. */
    float in_bounds = step(0.0, gobo_uv.x) * step(gobo_uv.x, 1.0) *
                      step(0.0, gobo_uv.y) * step(gobo_uv.y, 1.0);

    /* Sample gobo pattern (grayscale). */
    float gobo = gobo_tex.Sample(gobo_smp, gobo_uv).r;

    /* Shadow test with PCF. */
    float shadow = sample_shadow(light_ndc, texel_size);

    /* Blinn-Phong from spotlight. */
    float3 L = normalize(spot_pos - world_pos);
    float NdotL = max(dot(N, L), 0.0);
    float3 H = normalize(L + V);
    float NdotH = max(dot(N, H), 0.0);

    /* Quadratic attenuation. */
    float atten = 1.0 / (1.0 + 0.09 * dist + 0.032 * dist * dist);

    total_light += (albedo * NdotL + spec) * cone * gobo * shadow *
                   in_bounds * atten * spot_intensity * spot_color;
}

Shadow pass — depth-only render

c
/* Shadow pipeline: no color targets, depth-only. */
SDL_GPUDepthStencilTargetInfo shadow_depth_info;
SDL_zero(shadow_depth_info);
shadow_depth_info.texture     = shadow_depth_texture;
shadow_depth_info.load_op     = SDL_GPU_LOADOP_CLEAR;
shadow_depth_info.store_op    = SDL_GPU_STOREOP_STORE;
shadow_depth_info.clear_depth = 1.0f;

SDL_GPURenderPass *shadow_pass = SDL_BeginGPURenderPass(
    cmd, NULL, 0, &shadow_depth_info);
SDL_BindGPUGraphicsPipeline(shadow_pass, shadow_pipeline);

/* Draw shadow casters (exclude the light source model). */
draw_model_shadow(shadow_pass, cmd, &truck, &truck_mat, &light_vp);
for (int i = 0; i < BOX_COUNT; i++) {
    draw_model_shadow(shadow_pass, cmd, &box, &box_mat[i], &light_vp);
}

SDL_EndGPURenderPass(shadow_pass);

Scene pass texture bindings

c
/* Bind 3 samplers: diffuse, shadow depth, gobo pattern. */
SDL_GPUTextureSamplerBinding tex_binds[3];
tex_binds[0] = (SDL_GPUTextureSamplerBinding){
    .texture = diffuse_tex, .sampler = sampler };
tex_binds[1] = (SDL_GPUTextureSamplerBinding){
    .texture = shadow_depth_texture, .sampler = shadow_sampler };
tex_binds[2] = (SDL_GPUTextureSamplerBinding){
    .texture = gobo_texture, .sampler = gobo_sampler };
SDL_BindGPUFragmentSamplers(pass, 0, tex_binds, 3);

よくある質問

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

SDL GPUプロジェクトに、コーン状の減衰、シャドウマップ、パターン投影に対応した投影テクスチャ(ゴボ/クッキー)スポットライトを追加します

TypingMindでForge Gobo Spotlightを使うメリットは何ですか?

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

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

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

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

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

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

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

AIスキル「Forge Gobo Spotlight」は無料ですか?

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

AIスキルとは何ですか?

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

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

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

すべて見る

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

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