forge-textures-and-samplers
Load images, create GPU textures and samplers, draw textured geometry with index buffers. Use when someone needs to map an image onto geometry, set up texture…
от Nebulavenus★ 51 звезда на GitHub
Установить forge-textures-and-samplers в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Textures & Samplers — Image Loading, GPU Upload, and Texture Mapping
This skill teaches how to load images from disk, upload them to the GPU as
textures, create samplers, and draw textured geometry using index buffers.
It builds on the uniforms-and-motion skill (push uniforms, animation) and
the first-triangle skill (vertex buffers, pipeline).
When to use
- Loading and displaying images/textures in SDL3 GPU
- Setting up texture filtering (linear, nearest) and address modes (repeat, clamp)
- Drawing quads or other geometry with UV-mapped textures
- Using index buffers to avoid duplicate vertices
- Getting correct sRGB color handling for textures
Texture loading and upload
Step 1: Load from disk
SDL_Surface *surface = SDL_LoadSurface(path); /* handles BMP and PNG */
Step 2: Convert to RGBA8
SDL_Surface *converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ABGR8888);
SDL_DestroySurface(surface);
Pixel format mapping: SDL ABGR8888 = GPU R8G8B8A8 (SDL names bits
MSB→LSB, GPU names bytes in memory order).
Step 3: Create GPU texture
SDL_GPUTextureCreateInfo tex_info = { 0 };
tex_info.type = SDL_GPU_TEXTURETYPE_2D;
tex_info.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB;
tex_info.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER;
tex_info.width = converted->w;
tex_info.height = converted->h;
tex_info.layer_count_or_depth = 1;
tex_info.num_levels = 1;
SDL_GPUTexture *texture = SDL_CreateGPUTexture(device, &tex_info);
Use _SRGB format for textures with sRGB color data (most photographs and
hand-painted textures). The GPU auto-converts sRGB→linear when sampling.
Step 4: Upload via transfer buffer
Uint32 bytes_per_row = (Uint32)tex_w * 4;
Uint32 total_bytes = bytes_per_row * (Uint32)tex_h;
/* Create and fill transfer buffer */
SDL_GPUTransferBufferCreateInfo xfer_info = { 0 };
xfer_info.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
xfer_info.size = total_bytes;
SDL_GPUTransferBuffer *transfer = SDL_CreateGPUTransferBuffer(device, &xfer_info);
void *mapped = SDL_MapGPUTransferBuffer(device, transfer, false);
/* Copy row-by-row to handle surface pitch padding */
const Uint8 *src = (const Uint8 *)converted->pixels;
Uint8 *dst = (Uint8 *)mapped;
for (int y = 0; y < tex_h; y++) {
SDL_memcpy(dst + y * bytes_per_row, src + y * converted->pitch, bytes_per_row);
}
SDL_UnmapGPUTransferBuffer(device, transfer);
/* Issue GPU upload command */
SDL_GPUCommandBuffer *cmd = SDL_AcquireGPUCommandBuffer(device);
SDL_GPUCopyPass *copy = SDL_BeginGPUCopyPass(cmd);
SDL_GPUTextureTransferInfo tex_src = { 0 };
tex_src.transfer_buffer = transfer;
tex_src.pixels_per_row = tex_w;
tex_src.rows_per_layer = tex_h;
SDL_GPUTextureRegion tex_dst = { 0 };
tex_dst.texture = texture;
tex_dst.w = tex_w;
tex_dst.h = tex_h;
tex_dst.d = 1;
SDL_UploadToGPUTexture(copy, &tex_src, &tex_dst, false);
SDL_EndGPUCopyPass(copy);
SDL_SubmitGPUCommandBuffer(cmd);
SDL_ReleaseGPUTransferBuffer(device, transfer);
SDL_DestroySurface(converted);
Sampler creation
SDL_GPUSamplerCreateInfo sampler_info = { 0 };
sampler_info.min_filter = SDL_GPU_FILTER_LINEAR; /* smooth scaling down */
sampler_info.mag_filter = SDL_GPU_FILTER_LINEAR; /* smooth scaling up */
sampler_info.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR;
sampler_info.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_REPEAT; /* tile U */
sampler_info.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_REPEAT; /* tile V */
sampler_info.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_REPEAT;
SDL_GPUSampler *sampler = SDL_CreateGPUSampler(device, &sampler_info);
Filter options: LINEAR (smooth) or NEAREST (pixelated/pixel-art).
Address modes: REPEAT (tile), CLAMP_TO_EDGE, MIRRORED_REPEAT.
Vertex format with UVs
typedef struct Vertex {
vec2 position; /* NDC position — TEXCOORD0 */
vec2 uv; /* texture coord — TEXCOORD1 */
} Vertex;
UV origin is at top-left: (0,0) = top-left, (1,1) = bottom-right.
Index buffer
/* Create index buffer */
SDL_GPUBufferCreateInfo ibuf_info = { 0 };
ibuf_info.usage = SDL_GPU_BUFFERUSAGE_INDEX;
ibuf_info.size = sizeof(indices);
SDL_GPUBuffer *index_buffer = SDL_CreateGPUBuffer(device, &ibuf_info);
/* Upload (same transfer pattern as vertex buffer) */
/* Bind during render */
SDL_GPUBufferBinding index_binding = { 0 };
index_binding.buffer = index_buffer;
SDL_BindGPUIndexBuffer(pass, &index_binding, SDL_GPU_INDEXELEMENTSIZE_16BIT);
/* Draw */
SDL_DrawGPUIndexedPrimitives(pass, index_count, 1, 0, 0, 0);
Use SDL_GPU_INDEXELEMENTSIZE_16BIT for Uint16 indices (up to 65535 vertices)
or SDL_GPU_INDEXELEMENTSIZE_32BIT for Uint32 indices.
HLSL fragment shader
Texture2D tex : register(t0, space2); /* fragment texture slot 0 */
SamplerState smp : register(s0, space2); /* fragment sampl
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл forge-textures-and-samplers?
Load images, create GPU textures and samplers, draw textured geometry with index buffers. Use when someone needs to map an image onto geometry, set up texture filtering, or use index buffers in SDL3 GPU.
Как установить скилл forge-textures-and-samplers?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл forge-textures-and-samplers запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…