blender-core-gpu

Migrate Blender Python GPU drawing from bgl to the gpu module.

30|4|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package --skill blender-core-gpu-impertio-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: blender-core-gpu
Source: https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package/tree/main/skills/blender/core/blender-core-gpu
Command: npx skills add https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package --skill blender-core-gpu-impertio-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents common, production-breaking GPU drawing mistakes in Blender Python—especially the deprecated bgl API and Blender-version-specific shader pitfalls—so your viewport overlays and offscreen renders work reliably.

Core Features & Use Cases

  • Correct GPU drawing API: Enforces using Blender’s gpu module (not bgl, removed in Blender 5.0) for shaders, batches, GPU state, and textures.
  • Viewport draw-handler safety: Provides patterns for registering and removing SpaceView3D draw handlers to avoid leaked “ghost” overlays and crashes.
  • Version-safe shader + uniform handling: Covers Blender 3.x vs 4.x/5.x shader name changes and the required uniforms for POLYLINE_* shaders (including viewportSize and lineWidth).
  • Deterministic anti-pattern avoidance: Includes migration checklists and explicit anti-patterns for state restoration, main-thread GPU usage, and freeing GPUOffScreen.
  • Use cases: Custom 2D/3D viewport overlays (lines, filled shapes, textured quads), dashed line visuals, depth-tested debug drawings, and offscreen rendering pipelines.

Quick Start

Ask Claude to generate a Blender Python draw handler that draws a 3D viewport wire overlay using only the gpu module (not bgl), with correct POLYLINE_UNIFORM_COLOR uniforms and guaranteed cleanup in unregister().

Frequently Asked Questions about blender-core-gpu

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Blender viewport overlays from bgl to the gpu module?

To migrate viewport overlays from bgl to the gpu module, replace deprecated bgl calls with gpu module APIs for shaders, batches, and state management. This ensures compatibility across Blender 3.x through 5.x and prevents overlay rendering failures.

Why do my custom POLYLINE shaders fail to render in Blender 4.x?

Custom POLYLINE shaders fail in Blender 4.x when mandatory uniforms like viewportSize and lineWidth are missing. You must provide these required shader uniforms and use version-correct built-in shader names to ensure lines render properly.

What is the correct way to remove SpaceView3D draw handlers in Blender?

The correct way to remove SpaceView3D draw handlers is to strictly manage the draw-handler lifecycle by removing them during unregister. This prevents leaked ghost overlays and crashes caused by dangling GPU state references.

How do I prevent crashes during GPUOffScreen rendering in Blender Python?

To prevent crashes during GPUOffScreen rendering, execute GPU operations on the main thread and explicitly free the GPUOffScreen object after use. Restoring GPU state after rendering also avoids production-breaking failures.

Does Blender 5.0 still support the bgl module for custom viewport overlays?

Blender 5.0 does not support the bgl module for custom viewport overlays. The bgl module has been fully removed, requiring developers to use the gpu module for shaders, batches, and textures to maintain drawing functionality.

How do I draw depth-tested debug lines in the Blender viewport?

To draw depth-tested debug lines in the Blender viewport, use the gpu module to create line batches with custom shaders. Apply proper GPU state management to ensure depth testing works correctly without leaking state.