Logo vun Forge Edge Detection

Forge Edge Detection

Communautéit
Nebulavenus
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.

Iwwersiicht

EditeurNebulavenus
Repositoryforge-gpu
Skill-Nummforge-edge-detection
Stären
46
Forks
7
Matgeliwwert Fichieren
Nëmmen Instruktiounen
LizenzZlib
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum Nebulavenus op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Forge Edge Detection an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-edge-detection
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

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-edge-detection .claude/skills/forge-edge-detection
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Forge Edge Detection an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Forge Edge Detection automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Forge Edge Detection net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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)

  1. Shadow pipeline — Depth-only pass for shadow mapping
  2. Scene pipeline (MRT) — Renders lit scene to two color targets: color (RT0) and view-space normals (RT1), plus depth-stencil
  3. Grid pipeline (MRT) — Same MRT layout for the floor grid
  4. Edge composite pipeline — Full-screen quad, samples depth + normal textures, runs Sobel filter, composites edges onto the scene
  5. 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
  6. Ghost pipeline — Draws the same objects again with stencil test NOT_EQUAL ref=0 and additive blending for Fresnel ghost silhouettes

G-buffer setup (MRT)

The scene pass renders to two color targets simultaneously:

c
/* 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:

hlsl
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:

hlsl
/* 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.

c
/* 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
hlsl
/* 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:

c
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

PatternValue
depth_fail_opSDL_GPU_STENCILOP_INCREMENT_AND_WRAP
X-ray mark color_write_mask0 (invisible pass)
X-ray mark depth_writefalse
Ghost stencil compare_opSDL_GPU_COMPAREOP_NOT_EQUAL
Ghost stencil reference0
Ghost blendAdditive (SRC=ONE, DST=ONE)
MRT count2 (color + normals)

Key API calls

  • SDL_BeginGPURenderPass(cmd, color_targets, 2, &ds) — MRT with 2 color targets
  • SDL_SetGPUStencilReference(pass, ref) — set stencil compare reference value
  • SDL_DrawGPUPrimitives(pass, 3, 1, 0, 0) — fullscreen triangle (no vertex buffer)
  • SDL_GPU_STENCILOP_INCREMENT_AND_WRAP — depth_fail_op for X-ray marking
  • SDL_GPU_COMPAREOP_NOT_EQUAL — stencil test for ghost pass (ref=0, pass where >0)
  • SDL_GPU_BLENDFACTOR_ONE (src + dst) — additive blending for ghost glow
  • SDL_GPUTextureSupportsFormat — negotiate D24S8 with SAMPLER usage

Common mistakes

  • Forgetting MRT pipeline color target count — The pipeline must declare the same number of color target descriptions as render pass color targets. Mismatched counts cause validation errors or undefined behavior.
  • Wrong depth_fail_op direction — depth_fail_op fires when the fragment is behind existing depth. Make sure the scene depth is already established before the X-ray mark pass.
  • Not disabling depth writes for X-ray mark — If the mark pass writes depth, it corrupts the depth buffer and prevents the ghost pass from rendering correctly.
  • Missing stencil clear — Stale stencil values from the previous frame cause ghost artifacts everywhere. Always clear stencil at pass start.
  • Sobel on linear depth vs hyperbolic depth — Raw depth buffer values are hyperbolic (non-linear). For better edge detection, linearize depth first or adjust the depth scale threshold.

Cross-references

Heefeg gestallte Froen

Wat mécht de KI-Skill 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.

Firwat Forge Edge Detection op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Forge Edge Detection besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Forge Edge Detection an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-edge-detection an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Forge Edge Detection benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Forge Edge Detection benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Forge Edge Detection domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Forge Edge Detection gratis?

Jo. De Skill gëtt vum Nebulavenus ënner der Lizenz Zlib op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇