Логотип Forge Depth And 3d

Forge Depth And 3d

Спільнота
Nebulavenus
forge-depth-and-3d

Налаштуйте буфер глибини, 3D-конвеєр MVP, відсікання зворотних граней і обробку зміни розміру вікна. Використовуйте, коли потрібно рендерити 3D-геометрію з правильним порядком за глибиною, перспективною проєкцією або камерою огляду в SDL3 GPU.

Огляд

ВидавецьNebulavenus
Репозиторійforge-gpu
Назва навичкиforge-depth-and-3d
Зірки
46
Форки
7
Файли в пакеті
Лише інструкції
ЛіцензіяZlib
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Усе необхідне — в інструкціях

    Усе потрібне моделі міститься в інструкціях — жодних додаткових файлів для синхронізації.

  • Відкритий вихідний код

    Видавець на GitHub: Nebulavenus. Перед установленням перегляньте вихідні файли навички.

Встановлення

Установіть навичку ШІ Forge Depth And 3d у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки на GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до розділу «Плагіни» → «Навички».
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-depth-and-3d
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Додати навичку → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

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-depth-and-3d .claude/skills/forge-depth-and-3d
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Forge Depth And 3d в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Forge Depth And 3d, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для певного постачальника, тому навичка Forge Depth And 3d не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож поки навичка не потрібна, токени на її інструкції не витрачаються.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

Depth Buffer & 3D Transforms — MVP Pipeline, Depth Testing, and Culling

This skill teaches how to render 3D geometry with the full Model-View-Projection pipeline, depth testing, back-face culling, and window resize handling. It builds on the uniforms-and-motion skill (push uniforms) and first-triangle skill (vertex buffers, pipelines).

When to use

  • Rendering 3D geometry (cubes, meshes, scenes)
  • Setting up perspective projection with a camera
  • Enabling depth testing so closer surfaces draw over farther ones
  • Adding back-face culling for closed meshes
  • Handling window resize for depth textures
  • Transitioning from 2D (float2) to 3D (float3) vertex positions

Key API calls (ordered)

  1. SDL_CreateGPUTexture — create depth texture with DEPTH_STENCIL_TARGET usage
  2. SDL_CreateGPUGraphicsPipeline — with depth stencil state and back-face culling
  3. mat4_look_at / mat4_perspective / mat4_multiply — build MVP matrix per frame
  4. SDL_PushGPUVertexUniformData — push MVP matrix to vertex shader
  5. SDL_BeginGPURenderPass — with both color target AND depth target
  6. SDL_DrawGPUIndexedPrimitives — draw 3D geometry

Code template

Depth texture creation

c
static SDL_GPUTexture *create_depth_texture(SDL_GPUDevice *device,
                                             Uint32 w, Uint32 h)
{
    SDL_GPUTextureCreateInfo info;
    SDL_zero(info);
    info.type                 = SDL_GPU_TEXTURETYPE_2D;
    info.format               = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
    info.usage                = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET;
    info.width                = w;
    info.height               = h;
    info.layer_count_or_depth = 1;
    info.num_levels           = 1;

    SDL_GPUTexture *texture = SDL_CreateGPUTexture(device, &info);
    if (!texture) {
        SDL_Log("Failed to create depth texture: %s", SDL_GetError());
    }
    return texture;
}

Pipeline setup with depth and culling

c
SDL_GPUGraphicsPipelineCreateInfo pipeline_info;
SDL_zero(pipeline_info);

/* ... vertex input, shaders, etc. ... */

/* Back-face culling — skip faces pointing away from camera */
pipeline_info.rasterizer_state.cull_mode  = SDL_GPU_CULLMODE_BACK;
pipeline_info.rasterizer_state.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE;

/* Depth testing — closer fragments win */
pipeline_info.depth_stencil_state.enable_depth_test  = true;
pipeline_info.depth_stencil_state.enable_depth_write = true;
pipeline_info.depth_stencil_state.compare_op         = SDL_GPU_COMPAREOP_LESS_OR_EQUAL;

/* Color target */
SDL_GPUColorTargetDescription color_desc;
SDL_zero(color_desc);
color_desc.format = SDL_GetGPUSwapchainTextureFormat(device, window);
pipeline_info.target_info.color_target_descriptions = &color_desc;
pipeline_info.target_info.num_color_targets         = 1;

/* Depth target — MUST declare format in pipeline */
pipeline_info.target_info.has_depth_stencil_target = true;
pipeline_info.target_info.depth_stencil_format     = SDL_GPU_TEXTUREFORMAT_D16_UNORM;

MVP matrix computation

c
#include "math/forge_math.h"

/* Model: position and orient the object */
mat4 model = mat4_multiply(
    mat4_translate(vec3_create(0.0f, 0.0f, 0.0f)),
    mat4_multiply(mat4_rotate_y(angle_y), mat4_rotate_x(angle_x))
);

/* View: position and orient the camera */
mat4 view = mat4_look_at(
    vec3_create(0.0f, 1.5f, 3.0f),  /* eye position    */
    vec3_create(0.0f, 0.0f, 0.0f),  /* look-at target  */
    vec3_create(0.0f, 1.0f, 0.0f)   /* world up        */
);

/* Projection: perspective with correct aspect ratio */
float fov    = 60.0f * FORGE_DEG2RAD;
float aspect = (float)window_w / (float)window_h;
mat4 proj    = mat4_perspective(fov, aspect, 0.1f, 100.0f);

/* Compose: MVP = Projection * View * Model */
mat4 mvp = mat4_multiply(mat4_multiply(proj, view), model);

Render pass with depth target

c
SDL_GPUColorTargetInfo color_target;
SDL_zero(color_target);
color_target.texture     = swapchain;
color_target.load_op     = SDL_GPU_LOADOP_CLEAR;
color_target.store_op    = SDL_GPU_STOREOP_STORE;
color_target.clear_color = (SDL_FColor){ 0.02f, 0.02f, 0.04f, 1.0f };

SDL_GPUDepthStencilTargetInfo depth_target;
SDL_zero(depth_target);
depth_target.texture          = depth_texture;
depth_target.load_op          = SDL_GPU_LOADOP_CLEAR;
depth_target.store_op         = SDL_GPU_STOREOP_DONT_CARE;
depth_target.stencil_load_op  = SDL_GPU_LOADOP_DONT_CARE;
depth_target.stencil_store_op = SDL_GPU_STOREOP_DONT_CARE;
depth_target.clear_depth      = 1.0f;  /* far plane */

SDL_GPURenderPass *pass = SDL_BeginGPURenderPass(
    cmd, &color_target, 1, &depth_target);

Window resize handling

c
/* Check each frame — recreate depth texture if window size changed */
int w, h;
SDL_GetWindowSizeInPixels(window, &w, &h);

if ((Uint32)w != depth_width || (Uint32)h != depth_height) {
    SDL_ReleaseGPUTexture(device, depth_texture);
    depth_texture = create_depth_texture(device, (Uint32)w, (Uint32)h);
    depth_width   = (Uint32)w;
    depth_height  = (Uint32)h;
}

Vertex shader (HLSL)

hlsl
cbuffer Uniforms : register(b0, space1)
{
    column_major float4x4 mvp;
};

struct VSInput
{
    float3 position : TEXCOORD0;
    float3 color    : TEXCOORD1;
};

struct VSOutput
{
    float4 position : SV_Position;
    float4 color    : TEXCOORD0;
};

VSOutput main(VSInput input)
{
    VSOutput output;
    output.position = mul(mvp, float4(input.position, 1.0));
    output.color    = float4(input.color, 1.0);
    return output;
}

Vertex format for 3D

c
typedef struct Vertex {
    vec3 position;   /* 3D model-space position (FLOAT3) */
    vec3 color;      /* RGB per-vertex color    (FLOAT3) */
} Vertex;

/* Vertex attributes */
attrs[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;  /* position */
attrs[0].offset = offsetof(Vertex, position);
attrs[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;  /* color */
attrs[1].offset = offsetof(Vertex, color);

Uniform struct

c
typedef struct Uniforms {
    mat4 mvp;   /* 64 bytes — naturally 16-byte aligned */
} Uniforms;

A single mat4 is exactly 64 bytes and naturally 16-byte aligned, so no padding is needed (unlike the time + aspect + pad structs from earlier lessons).

HLSL column-major compatibility

forge_math.h stores matrices column-major. HLSL defaults to column_major for float4x4. Use mul(mvp, float4(pos, 1.0)) — no transpose needed.

If you accidentally see an inside-out or mirrored cube, check:

  1. Matrix storage order matches shader declaration
  2. mul(matrix, vector) not mul(vector, matrix)
  3. Winding order matches front_face setting

Depth format choices

FormatBitsPrecisionUse case
D16_UNORM16LowSimple scenes, universally supported
D24_UNORM24MediumMost 3D games
D32_FLOAT32HighLarge worlds, reverse-Z

For learning and simple scenes, D16_UNORM is sufficient and universally supported.

Common mistakes

MistakeFix
Cube looks inside-outEnable depth testing (enable_depth_test = true)
No depth target in pipelineSet has_depth_stencil_target = true and depth_stencil_format
Crash on window resizeRecreate depth texture when window size changes
Cube appears mirroredCheck mul(mvp, vertex) order matches column-major storage
Back faces visibleSet cull_mode = CULLMODE_BACK with correct front_face
Depth buffer not clearingSet load_op = LOADOP_CLEAR and clear_depth = 1.0f
Missing perspectiveUse mat4_perspective not mat4_orthographic

Cleanup

c
SDL_ReleaseGPUTexture(device, depth_texture);
SDL_ReleaseGPUBuffer(device, index_buffer);
SDL_ReleaseGPUBuffer(device, vertex_buffer);
SDL_ReleaseGPUGraphicsPipeline(device, pipeline);

Reference

Поширені запитання

Що робить навичка ШІ Forge Depth And 3d?

Налаштуйте буфер глибини, 3D-конвеєр MVP, відсікання зворотних граней і обробку зміни розміру вікна. Використовуйте, коли потрібно рендерити 3D-геометрію з правильним порядком за глибиною, перспективною проєкцією або камерою огляду в SDL3 GPU.

Навіщо використовувати Forge Depth And 3d у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Forge Depth And 3d — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Forge Depth And 3d у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-depth-and-3d. TypingMind прочитає файл SKILL.md і встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Forge Depth And 3d?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Forge Depth And 3d?

Зі скількома забажаєте. У TypingMind ви можете використовувати Forge Depth And 3d із будь-якою моделлю, яка підтримує навички, зокрема з GPT, Claude, Gemini, Grok, DeepSeek, Mistral чи Llama. Для цього ви використовуєте власні ключі API.

Чи безкоштовна навичка ШІ Forge Depth And 3d?

Так. На GitHub цю навичку публікує Nebulavenus за ліцензією Zlib. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це набір інструкцій для повторного використання, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти, які вона може викликати, — код, який десь виконується й повертає результат. Натомість навичка ШІ дає моделі знання й пояснює порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний робочий простір зі ШІ вже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇