/blender-developer-tools:procedural-materials-and-shadersfrom blender-developer-tools
Builds Blender materials and shader node graphs from Python: bpy.data.materials, node_tree, Principled BSDF socket names, default values, links, and node groups for EEVEE and Cycles. Handles light linking and version differences up to 5.2 LTS.
Ships in blender-developer-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill when the user:
bpy.data.materials, node_tree, ShaderNodeBsdfPrincipled, inputs[...].default_valuereceiver_collection, blocker_collection)Every Python-built material follows the same four steps:
bpy.data.materials.new(name=...).materials.new() already creates mat.node_tree with a default Principled BSDF and Material Output, and Material.use_nodes is deprecated (setting it warns; removal is planned for 6.0). On 4.5 LTS the tree is None until you set mat.use_nodes = True. Gate it: if bpy.app.version < (5, 0, 0): mat.use_nodes = True. You can keep the default nodes or wipe them.mat.node_tree.nodes and configure their inputs[...].default_value.mat.node_tree.links between sockets.import bpy
def make_principled_material(name, base_color=(0.8, 0.8, 0.8, 1.0), metallic=0.0, roughness=0.5):
"""Create a material with a single Principled BSDF wired to Material Output."""
mat = bpy.data.materials.new(name=name)
if bpy.app.version < (5, 0, 0):
mat.use_nodes = True # 4.5 LTS: no node tree until enabled; deprecated on 5.x
nodes = mat.node_tree.nodes
links = mat.node_tree.links
nodes.clear()
bsdf = nodes.new(type='ShaderNodeBsdfPrincipled')
bsdf.location = (0, 0)
bsdf.inputs['Base Color'].default_value = base_color
bsdf.inputs['Metallic'].default_value = metallic
bsdf.inputs['Roughness'].default_value = roughness
output = nodes.new(type='ShaderNodeOutputMaterial')
output.location = (300, 0)
links.new(bsdf.outputs['BSDF'], output.inputs['Surface'])
return mat
To assign the result to an object:
obj.data.materials.clear()
obj.data.materials.append(mat)
Sockets are accessed by name (string key) or by index. Names are stable in the public API and survive translation; indices are not. Use names.
bsdf.inputs['Base Color'].default_value = (0.9, 0.1, 0.1, 1.0)
bsdf.inputs['Metallic'].default_value = 0.0
bsdf.inputs['Roughness'].default_value = 0.4
bsdf.inputs['IOR'].default_value = 1.45
The default_value field accepts:
(r, g, b, a) for color sockets, even if the channel is RGB-only (alpha is ignored)float for value sockets(x, y, z) for vector socketsimport bpy
def make_metal(name, base_color=(0.8, 0.8, 0.85, 1.0), roughness=0.2):
"""Procedural metal with adjustable color and surface roughness."""
mat = bpy.data.materials.new(name=name)
if bpy.app.version < (5, 0, 0):
mat.use_nodes = True # 4.5 LTS: no node tree until enabled; deprecated on 5.x
nodes = mat.node_tree.nodes
links = mat.node_tree.links
nodes.clear()
bsdf = nodes.new(type='ShaderNodeBsdfPrincipled')
bsdf.location = (0, 0)
bsdf.inputs['Base Color'].default_value = base_color
bsdf.inputs['Metallic'].default_value = 1.0
bsdf.inputs['Roughness'].default_value = roughness
bsdf.inputs['IOR'].default_value = 2.5
output = nodes.new(type='ShaderNodeOutputMaterial')
output.location = (300, 0)
links.new(bsdf.outputs['BSDF'], output.inputs['Surface'])
return mat
for name, color in [
("Steel", (0.8, 0.8, 0.85, 1.0)),
("Gold", (1.0, 0.84, 0.4, 1.0)),
("Copper", (0.95, 0.64, 0.54, 1.0)),
]:
make_metal(name, base_color=color)
def make_emissive(name, color=(1.0, 0.4, 0.1, 1.0), strength=5.0):
mat = bpy.data.materials.new(name=name)
if bpy.app.version < (5, 0, 0):
mat.use_nodes = True # 4.5 LTS: no node tree until enabled; deprecated on 5.x
nodes = mat.node_tree.nodes
links = mat.node_tree.links
nodes.clear()
emission = nodes.new(type='ShaderNodeEmission')
emission.inputs['Color'].default_value = color
emission.inputs['Strength'].default_value = strength
emission.location = (0, 0)
output = nodes.new(type='ShaderNodeOutputMaterial')
output.location = (300, 0)
links.new(emission.outputs['Emission'], output.inputs['Surface'])
return mat
When the same subgraph appears across multiple materials, factor it into a ShaderNodeTree group. Create the group once with bpy.data.node_groups.new(name='MyGroup', type='ShaderNodeTree'), build its internal nodes and its sockets with group.interface.new_socket(...) (the same API on 4.5 LTS and 5.x; group.inputs.new was removed in 4.0), then instantiate it inside any material's tree as a ShaderNodeGroup with node.node_tree = my_group. See snippet shader-node-group.py.
Light linking restricts a light to a set of receiver objects, or stops a set of blocker objects from casting its shadows. It is the look-dev tool for "this key lights the hero, not the set". Python reaches it in one place, and that place is the trap: the settings live on the light object, not on the Light datablock.
import bpy
hero = bpy.data.collections.new("Hero")
bpy.context.scene.collection.children.link(hero)
hero.objects.link(bpy.data.objects["Cube"])
light_data = bpy.data.lights.new("Key", type="AREA")
key = bpy.data.objects.new("Key", light_data)
bpy.context.scene.collection.objects.link(key)
key.light_linking.receiver_collection = hero # lights only objects in Hero
key.light_linking.blocker_collection = None # shadow linking: casters, same shape
assert key.light_linking.receiver_collection == hero
assert not hasattr(light_data, "light_linking") # not on the datablock
obj.light_linking is an ObjectLightLinking with receiver_collection and blocker_collection. light_data.light_linking raises AttributeError on 4.5 LTS and 5.x alike, so no version branch is needed.None removes the restriction.light-link-studio measures the linked hero at 3.6x the luminance of an identical unlinked decoy in Cycles, and 3.8x with EEVEE on 4.5 (BLENDER_EEVEE_NEXT) and 5.1 (BLENDER_EEVEE). Unlinking raises the decoy by over 200% while the hero moves under 0.5%, so the restriction is surgical.view_transform = 'Standard'. AgX compresses the luminance ratios a pixel check depends on.mat.use_nodes = True on 4.5 LTS. There, a new material's mat.node_tree is None until nodes are enabled, and any node access raises AttributeError. On 5.x the tree exists from materials.new() and setting use_nodes only emits a DeprecationWarning, so gate the line on bpy.app.version < (5, 0, 0).inputs["Emission"], ["Clearcoat"], ["Subsurface"], ["Transmission"], ["Specular"] raise KeyError: 'bpy_prop_collection[key]: key "Emission" not found' on 4.5 and 5.x. Use the table in Principled BSDF socket names below.bsdf.inputs[0] is fragile. The Principled BSDF input order has shifted across Blender releases. Always use string keys.(0.5, 0.5, 0.5) raises a length error.bpy.types.LayeredTextureNode or similar; these do not exist in 5.1 stable. Stick with classic ShaderNodeTex* (ShaderNodeTexImage, ShaderNodeTexNoise, etc.) for 5.1.bpy.ops.material.new() to create a material when bpy.data.materials.new() works headlessly and is faster.node_tree. To share logic, use a shader node group.use_nodes = True) holds a Principled BSDF and an Output. If you add your own BSDF and link it to Surface, the new link replaces the old one (an input socket takes one link), so the default Principled BSDF is left orphaned in the tree, confusing anyone who reads it and anything that later looks it up by type or name. Either reuse the defaults or nodes.clear() first.Light datablock. bpy.data.lights["Key"].light_linking raises AttributeError; use the light object: bpy.data.objects["Key"].light_linking.receiver_collection = collection.| Topic | 4.5 LTS | 5.1 / 5.2 LTS | Notes |
|---|---|---|---|
| Principled BSDF | ShaderNodeBsdfPrincipled | Same | Inputs were renamed in 4.0 with the Principled v2 rewrite (full table below; 4.0 release notes: https://developer.blender.org/docs/release_notes/4.0/). Both versions use the 4.0+ names; Thin Wall is 5.2+ only. |
| Node group socket interface | group.interface.new_socket | group.interface.new_socket | Same API on every supported version. group.inputs.new / outputs.new were removed in 4.0; see snippet shader-node-group.py. |
| EEVEE engine string | 'BLENDER_EEVEE_NEXT' | 'BLENDER_EEVEE' | Legacy EEVEE was removed in 4.2. EEVEE Next used the id 'BLENDER_EEVEE_NEXT' on 4.2-4.5, then reclaimed the plain 'BLENDER_EEVEE' id in 5.0. |
| Layered Textures | Not present | Not present in 5.1 | Roadmap pushed to 2027. Do not generate code referencing it. |
EEVEE Next stabilized in Blender 5.1 with material caching and feature parity improvements; most Principled BSDF graphs render identically across EEVEE Next and Cycles.
Principled v2 (Blender 4.0) renamed or removed most of the 3.x inputs. 4.5 LTS and 5.x share the 4.0+ names, so code for supported versions uses them directly: no fallback to the old name, which only adds a branch that never runs. Code from 3.x tutorials and models fails with
KeyError: 'bpy_prop_collection[key]: key "Emission" not found'
(measured on 4.5.14 and 5.2.1).
| 3.x input | 4.0+ input (4.5 LTS, 5.x) |
|---|---|
Emission | Emission Color (with Emission Strength) |
Subsurface | Subsurface Weight |
Subsurface Color | removed: subsurface takes Base Color |
Specular | Specular IOR Level |
Specular Tint | same name, but now a color (RGBA, default white), not a float |
Clearcoat | Coat Weight |
Clearcoat Roughness | Coat Roughness |
Clearcoat Normal | Coat Normal |
Sheen | Sheen Weight |
Sheen Tint | same name, now a color (RGBA) |
Transmission | Transmission Weight |
Transmission Roughness | removed: transmission uses Roughness |
New in v2, no 3.x counterpart: Coat IOR, Coat Tint, Sheen Roughness,
Subsurface Scale, Subsurface IOR, Subsurface Anisotropy,
Diffuse Roughness, Thin Film Thickness, Thin Film IOR. 5.2 adds
Thin Wall (not on 4.5.14). Look a socket up by name only where it exists on
every version you target:
bsdf.inputs["Emission Color"].default_value = (1.0, 0.5, 0.1, 1.0)
bsdf.inputs["Emission Strength"].default_value = 3.0
bsdf.inputs["Specular IOR Level"].default_value = 0.0 # was "Specular"
if "Thin Wall" in bsdf.inputs: # 5.2+ only
bsdf.inputs["Thin Wall"].default_value = True
Almost everything you want to do with materials has a bpy.data path. The two notable exceptions:
bpy.ops.object.bake), which needs context and a render engine.bpy.ops.node.* for interactive UX. In Python, build links directly with mat.node_tree.links.new().prefer-data-over-ops-in-loops: the same principle applies when generating many materials.principled-bsdf-material.py for a minimal copy-paste.shader-node-group.py for reusable shader node groups with the cross-version interface API.Each example runs headless, asserts the contract, and exits non-zero when it breaks. Run one with blender --background --python <script> --; pass a falsifier flag to watch the check fail.
light-link-studio: One key, one hero: a light linked to a receiver collection lights only the hero, proven by two pixel renders in one pass. Falsify: --skip-link (exit 6).shader-node-group: One reusable shader group declared via tree.interface.new_socket, instanced in five materials with different Tint values — one dipped-glaze group, five stoneware mugs, five colors. Falsify: --same-tint (exit 8).sky-texture-sun-elevation: World ShaderNodeTexSky driving Background Color — the sky contract across 4.5 LTS and 5.1. Falsify: --unlink-sky (exit 7).swatch-grid: Procedural Principled materials — metal and dielectric, the emission pattern, and the cross-version set_specular shim. Falsify: --output swatch.png --engine cycles --samples 8 --width 640 --same-base (exit 6).Short standalone patterns to copy. Each one runs in CI on 5.2 and 4.5 with a check and a falsifier.
bpy.types.Material: https://docs.blender.org/api/current/bpy.types.Material.htmlbpy.types.ShaderNodeBsdfPrincipled: https://docs.blender.org/api/current/bpy.types.ShaderNodeBsdfPrincipled.htmlbpy.types.ShaderNodeTree: https://docs.blender.org/api/current/bpy.types.ShaderNodeTree.htmlbpy.types.ObjectLightLinking: https://docs.blender.org/api/current/bpy.types.ObjectLightLinking.html (4.5 LTS)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub tmhsdigital/blender-developer-tools --plugin blender-developer-tools27 skills in this plugin
/addon-scaffoldingScaffold a Blender add-on as an Extensions Platform package: blender_manifest.toml, modular file layout, register_classes_factory, symmetric register/unregister. Use when the user starts a new add-on or extension, writes or fixes blender_manifest.toml, asks which layout or registration pattern to use on Blender 4.5 LTS or 5.x, or has classes that fail to register or unregister cleanly. Targets 5.2 LTS with 4.5 LTS fallback./ai-mesh-cleanupOrdered cleanup for an imported generated or scanned mesh before it goes to an engine: scene units, apply rotation and scale, origin to base, recalculate normals, evaluated triangle count, decimate to a budget, convex collider. Use when the user has a GLB, glTF or FBX that is not engine-ready, mentions unit scale, unapplied transforms, triangle budget, LODs or a collision hull, or is about to run mesh operations on an import without checking its scale. Targets 5.2 LTS with 4.5 LTS fallback./bake-high-to-lowCage-bake high-poly surface detail onto a low-poly target as a tangent-space normal map with bpy.ops.object.bake (Cycles, selected-to-active, active Image Texture node, UV layer, save_render). Use when the user wants a normal map from a dense mesh onto a game-resolution or decimated LOD, mentions cage_extrusion or use_selected_to_active, or gets a bake that returns CANCELLED, comes out black or flat, or fails with 'No active UV layer found'. Targets 5.2 LTS with 4.5 LTS fallback.Other plugins' skills for the same job