forge-edge-detection
Add Sobel edge detection on G-buffer data (depth + normals via MRT), stencil-based X-ray vision with depth_fail_op, and Fresnel ghost silhouettes with…
от Nebulavenus★ 51 звезда на GitHub
Установить forge-edge-detection в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Edge Detection
Add post-process edge detection, stencil X-ray vision, and Fresnel ghost
silhouettes to an SDL GPU project. Uses G-buffer MRT output (depth + normals)
for Sobel edge detection, depth_fail_op for occluded-object marking, and
additive blending for translucent ghost rendering.
Based on GPU Lesson 36.
When to use
- You want post-process outlines from depth/normal discontinuities
- You need X-ray vision to reveal occluded objects behind walls
- You want ghostly translucent silhouettes for hidden geometry
- You need an alternative to L34's stencil-expansion outlines
Pipeline overview (6 pipelines)
- Shadow pipeline — Depth-only pass for shadow mapping
- Scene pipeline (MRT) — Renders lit scene to two color targets: color (RT0) and view-space normals (RT1), plus depth-stencil
- Grid pipeline (MRT) — Same MRT layout for the floor grid
- Edge composite pipeline — Full-screen quad, samples depth + normal textures, runs Sobel filter, composites edges onto the scene
- X-ray mark pipeline — Draws occluded objects with
depth_fail_op = INCREMENT_AND_WRAP,color_write_mask = 0, writing only to stencil where fragments fail the depth test - Ghost pipeline — Draws the same objects again with stencil test
NOT_EQUALref=0 and additive blending for Fresnel ghost silhouettes
G-buffer setup (MRT)
The scene pass renders to two color targets simultaneously:
/* RT0: scene color (RGBA8) */
/* RT1: view-space normals (RGBA16_FLOAT or RGBA8_SNORM) */
SDL_GPUColorTargetInfo color_targets[2] = {
{ .texture = scene_color_tex, .load_op = SDL_GPU_LOADOP_CLEAR },
{ .texture = normal_tex, .load_op = SDL_GPU_LOADOP_CLEAR },
};
The fragment shader outputs to both targets:
struct PSOutput {
float4 color : SV_Target0;
float4 normal : SV_Target1;
};
Pipeline must declare two color target descriptions to match.
Sobel edge detection
Sample depth and normal textures in a 3x3 neighborhood. Apply Sobel operators (horizontal Gx and vertical Gy kernels) separately to depth and to each normal component. Combine magnitudes:
/* Sobel kernels */
/* Gx = [-1 0 1; -2 0 2; -1 0 1] */
/* Gy = [-1 -2 -1; 0 0 0; 1 2 1] */
float depth_edge = sqrt(gx_depth * gx_depth + gy_depth * gy_depth);
float normal_edge = sqrt(gx_nx*gx_nx + gy_nx*gy_nx
+ gx_ny*gx_ny + gy_ny*gy_ny
+ gx_nz*gx_nz + gy_nz*gy_nz);
float edge = saturate(depth_edge * depth_scale + normal_edge * normal_scale);
Threshold and composite: final_color = lerp(scene_color, edge_color, edge).
X-ray mark technique (depth_fail_op)
The key insight: depth_fail_op fires when a fragment is behind existing
geometry. By drawing the target object with this operation, we mark exactly
the pixels where it is occluded.
/* X-ray mark pipeline stencil state */
SDL_GPUStencilOpState xray_stencil = {
.fail_op = SDL_GPU_STENCILOP_KEEP,
.pass_op = SDL_GPU_STENCILOP_KEEP, /* visible parts: no mark */
.depth_fail_op = SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /* occluded: mark */
.compare_op = SDL_GPU_COMPAREOP_ALWAYS,
};
Color write mask = 0 and depth write = false. This pass is invisible — it only writes stencil values where the object is hidden behind other geometry.
Ghost silhouette technique
After the X-ray mark pass, draw the object again with:
- Stencil test:
compare_op = NOT_EQUAL, reference = 0 (draw only where marked) - Additive blending:
src_color_blendfactor = ONE,dst = ONE - Fresnel-based opacity: brighter at edges where
dot(N, V)is low
/* Fresnel ghost effect */
float fresnel = 1.0 - saturate(dot(normal, view_dir));
fresnel = pow(fresnel, fresnel_power);
return float4(ghost_color * fresnel * intensity, 0.0);
The additive blend makes the ghost glow through geometry without needing alpha sorting.
Clearing stencil
Clear stencil alongside depth at the start of the render pass:
SDL_GPUDepthStencilTargetInfo ds_target = {
.texture = depth_stencil_texture,
.load_op = SDL_GPU_LOADOP_CLEAR,
.store_op = SDL_GPU_STOREOP_STORE,
.clear_depth = 1.0f,
.clear_stencil = 0,
.stencil_load_op = SDL_GPU_LOADOP_CLEAR,
.stencil_store_op = SDL_GPU_STOREOP_STORE,
};
Key patterns
| Pattern | Value |
|---|---|
depth_fail_op |
SDL_GPU_STENCILOP_INCREMENT_AND_WRAP |
X-ray mark color_write_mask |
0 (invisible pass) |
X-ray mark depth_write |
false |
Ghost stencil compare_op |
SDL_GPU_COMPAREOP_NOT_EQUAL |
Ghost stencil reference |
0 |
| Ghost blend | Additive (SRC=ONE, DST=ONE) |
| MRT count | 2 (color + normals) |
Key API calls
SDL_BeginGPURenderPass(cmd, color_targets, 2, &ds)— MRT with 2 color targetsSDL_SetGPUStencilReference(pass, ref)— set stencil compare reference value- `SD
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл forge-edge-detection?
Add Sobel edge detection on G-buffer data (depth + normals via MRT), stencil-based X-ray vision with depth_fail_op, and Fresnel ghost silhouettes with additive blending to an SDL GPU project.
Как установить скилл forge-edge-detection?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл forge-edge-detection запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…