Logotipo de Forge Edge Detection

Forge Edge Detection

Comunidad
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.

Descripción general

EditorNebulavenus
Repositorioforge-gpu
Nombre de la habilidadforge-edge-detection
Estrellas
46
Forks
7
Archivos incluidos
Solo instrucciones
LicenciaZlib
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando la petición encaja con la habilidad.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Todo en las instrucciones

    Todo lo que necesita el modelo está en las instrucciones: no hay archivos adicionales que sincronizar.

  • Código abierto

    Publicada por Nebulavenus en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Forge Edge Detection en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-edge-detection
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

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
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Forge Edge Detection en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición encaja con la habilidad, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Forge Edge Detection automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Forge Edge Detection no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición que encaja con la habilidad, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

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

Preguntas frecuentes

¿Qué hace la habilidad de IA 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.

¿Por qué usar Forge Edge Detection en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Forge Edge Detection está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Forge Edge Detection en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-edge-detection. TypingMind lee el archivo SKILL.md de esa carpeta e instala su contenido como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Forge Edge Detection?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Forge Edge Detection?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Forge Edge Detection con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Forge Edge Detection?

Sí. Nebulavenus la ha publicado en GitHub bajo la licencia Zlib. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver el directorio

Crea ya tu propio espacio de trabajo con IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇