forge-gobo-spotlight
Add a projected-texture (gobo/cookie) spotlight with cone falloff, shadow map, and pattern projection to an SDL GPU project
от Nebulavenus★ 51 звезда на GitHub
Установить forge-gobo-spotlight в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
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 goboSDL_CreateGPUGraphicsPipeline— shadow pipeline (depth-only, no color targets)SDL_BeginGPURenderPass— shadow pass with depth-only attachmentSDL_BindGPUFragmentSamplers— bind diffuse + shadow + gobo textures in scene pass
Correct order
- Define spotlight parameters — position, target, inner/outer cone angles, color, intensity
- Compute light view-projection —
mat4_look_at(pos, target, up)+mat4_perspective(2 * outer_angle, 1.0, near, far) - Create shadow depth texture — D32_FLOAT, same resolution for shadow map (e.g. 1024x1024)
- Create shadow sampler — NEAREST filter, CLAMP_TO_EDGE
- Load gobo texture — grayscale PNG as UNORM (not sRGB), LINEAR sampler, CLAMP_TO_EDGE
- Create shadow pipeline — vertex shader transforms by light_mvp, empty fragment shader, depth-only
- Create scene pipeline — increase
num_samplersto include shadow + gobo (e.g. 3 total) - 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
- Spotlight cone:
smoothstep(cos_outer, cos_inner, cos_angle)— cosine decreases with angle, so outer < inner - Gobo projection: light_vp transforms world pos → clip → NDC → UV for gobo texture sampling
- Triple-duty matrix: the same light_vp handles shadow mapping, gobo UV mapping, and cone bounds
- Single 2D shadow map: a spotlight's perspective frustum captures everything in one pass (unlike cube maps for point lights)
- UNORM gobo texture: the gobo is a linear attenuation mask, not a color — use UNORM to avoid sRGB gamma
- 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_angleto cover the full spotlight cone. Too narrow clips shadows; too wide wastes resolution.
Spotlight definition
#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
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;
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл forge-gobo-spotlight?
Add a projected-texture (gobo/cookie) spotlight with cone falloff, shadow map, and pattern projection to an SDL GPU project
Как установить скилл forge-gobo-spotlight?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл forge-gobo-spotlight запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…