Logo Forge Gobo Spotlight

Forge Gobo Spotlight

Cộng đồng
Nebulavenus
forge-gobo-spotlight

Thêm đèn chiếu spotlight dùng kết cấu chiếu (gobo/cookie), có vùng sáng hình nón giảm dần, shadow map và chiếu họa tiết vào dự án SDL GPU

Tổng quan

Nhà phát hànhNebulavenus
Kho mãforge-gpu
Tên kỹ năngforge-gobo-spotlight
Sao
46
Bản fork
7
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépZlib
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được Nebulavenus công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Forge Gobo Spotlight trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-gobo-spotlight
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân 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
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Forge Gobo Spotlight trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Forge Gobo Spotlight ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Forge Gobo Spotlight với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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);

Câu hỏi thường gặp

Kỹ năng AI Forge Gobo Spotlight làm được gì?

Thêm đèn chiếu spotlight dùng kết cấu chiếu (gobo/cookie), có vùng sáng hình nón giảm dần, shadow map và chiếu họa tiết vào dự án SDL GPU

Vì sao nên dùng Forge Gobo Spotlight trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Forge Gobo Spotlight là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Forge Gobo Spotlight trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-gobo-spotlight. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Forge Gobo Spotlight?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Forge Gobo Spotlight với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Forge Gobo Spotlight với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Forge Gobo Spotlight có miễn phí không?

Có. Kỹ năng này được Nebulavenus phát hành trên GitHub theo giấy phép Zlib. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇