forge-depth-and-3d
Set up depth buffer, 3D MVP pipeline, back-face culling, and window resize handling. Use when someone needs to render 3D geometry with correct depth ordering…
от Nebulavenus★ 51 звезда на GitHub
Установить forge-depth-and-3d в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
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)
SDL_CreateGPUTexture— create depth texture withDEPTH_STENCIL_TARGETusageSDL_CreateGPUGraphicsPipeline— with depth stencil state and back-face cullingmat4_look_at/mat4_perspective/mat4_multiply— build MVP matrix per frameSDL_PushGPUVertexUniformData— push MVP matrix to vertex shaderSDL_BeginGPURenderPass— with both color target AND depth targetSDL_DrawGPUIndexedPrimitives— draw 3D geometry
Code template
Depth texture creation
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
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
#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
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
/* 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, (Uint3
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл forge-depth-and-3d?
Set up depth buffer, 3D MVP pipeline, back-face culling, and window resize handling. Use when someone needs to render 3D geometry with correct depth ordering, perspective projection, or a view camera in SDL3 GPU.
Как установить скилл forge-depth-and-3d?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл forge-depth-and-3d запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
AnthropicThe scan that the plugin's GitHub Action runs.
azure-static-web-apps
GitHubHelps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
ai-ready
GitHubMake any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
aws-cdk-python-setup
GitHubSetup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…