Skip to main content
rule CX Codex

tsl-material-slots — Claude Code rule: what it does, how to install

tsl-material-slots is a Claude Code rule with a reference to Three.js TSL material slots. It helps write node-based shader logic without mistyping slot names or property types.

MIT ★ 4,719 updated 2026-10-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/tsl-material-slots.md
Open on GitHub

What tsl-material-slots does

This rule acts as a slot reference for building materials in Three.js Shading Language (TSL). It outlines core shader hooks like .vertexNode and .fragmentNode. Dedicated sections detail lighting inputs, shadow parameters, and multi-render target outputs using .mrtNode.

The reference also lists sixteen slots for MeshPhysicalNodeMaterial, covering transmission and clearcoat layers. TSL enforces strict node typing. Passing a raw number instead of float() breaks shader compilation.

Code snippets illustrate time-based color pulsation and vertex displacement using functions from three/tsl.

What it helps with

  • connect vertex displacement logic into .positionNode
  • configure transparency masks and alpha cutoffs via .alphaTestNode
  • set up refraction and clearcoat properties on MeshPhysicalNodeMaterial
  • override fragment shader logic using .fragmentNode

Example prompts for the agent

  • Add vertex displacement using positionNode and sin(time) from three/tsl
  • Configure MeshPhysicalNodeMaterial with transmissionNode, thicknessNode, and iorNode
  • Set up alpha cutout on a standard material using opacityNode and alphaTestNode

How to install tsl-material-slots

Manually: put the files in place

.claude/rules/tsl-material-slots.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about tsl-material-slots

How to install tsl-material-slots in Claude Code?

Place the rule file at .claude/rules/tsl-material-slots.md in your project repository.

What does tsl-material-slots do?

It provides your AI assistant with the complete Three.js TSL material slot reference, expected node types, and integration snippets.

Which slots are specific to MeshPhysicalNodeMaterial?

It details sixteen physical material slots, such as .clearcoatNode, .transmissionNode, .iorNode, .thicknessNode, .sheenNode, and .iridescenceNode.

Source text

tsl-material-slots.md · MIT
# TSL Material Node Slots

Complete reference for all material node slots available in TSL.

## Core Slots

| Slot | Description | Type |
|------|-------------|------|
| `.fragmentNode` | Replace fragment shader logic | `vec4` |
| `.vertexNode` | Replace vertex shader logic | `vec4` |
| `.geometryNode` | Execute geometry operations | `Fn()` |

## Basic Slots

| Slot | Description | Reference | Type |
|------|-------------|-----------|------|
| `.colorNode` | Base color x map | `materialColor` | `vec4` |
| `.depthNode` | Depth output | `depth` | `float` |
| `.opacityNode` | Opacity x alphaMap | `materialOpacity` | `float` |
| `.alphaTestNode` | Alpha threshold | `materialAlphaTest` | `float` |
| `.positionNode` | Vertex position + displacement | `positionLocal` | `vec3` |

## Lighting Slots

| Slot | Type |
|------|------|
| `.emissiveNode` | `color` |
| `.normalNode` | `vec3` |
| `.lightsNode` | Lighting model |
| `.envNode` | `color` |

## Shadow Slots

| Slot | Description | Type |
|------|-------------|------|
| `.castShadowNode` | Shadow color/opacity | `vec4` |
| `.maskShadowNode` | Shadow mask | `bool` |
| `.receivedShadowNode` | Shadow reception | `Fn()` |
| `.receivedShadowPositionNode` | Shadow projection position | `vec3` |
| `.aoNode` | Ambient occlusion | `float` |

## Output Slots

| Slot | Description | Type |
|------|-------------|------|
| `.maskNode` | Fragment mask | `bool` |
| `.mrtNode` | Custom MRT config | `mrt()` |
| `.outputNode` | Final output | `vec4` |

## MeshPhysicalNodeMaterial Specific

| Slot | Type |
|------|------|
| `.clearcoatNode` | `float` |
| `.clearcoatRoughnessNode` | `float` |
| `.clearcoatNormalNode` | `vec3` |
| `.sheenNode` | `color` |
| `.iridescenceNode` | `float` |
| `.iridescenceIORNode` | `float` |
| `.iridescenceThicknessNode` | `float` |
| `.specularIntensityNode` | `float` |
| `.specularColorNode` | `color` |
| `.iorNode` | `float` |
| `.transmissionNode` | `color` |
| `.thicknessNode` | `float` |
| `.attenuationDistanceNode` | `float` |
| `.attenuationColorNode` | `color` |
| `.dispersionNode` | `float` |
| `.anisotropyNode` | `vec2` |

## Usage Examples

### Color with Time Animation

```javascript
import { color, time, sin } from 'three/tsl';

const material = new MeshStandardNodeMaterial();
material.colorNode = color(0xff0000).mul(sin(time).mul(0.5).add(0.5));
```

### Custom Normal Mapping

```javascript
import { normalMap, texture, normalLocal } from 'three/tsl';

material.normalNode = normalMap(texture(normalTexture));
```

### Vertex Displacement

```javascript
import { positionLocal, normalLocal, sin, time } from 'three/tsl';

material.positionNode = positionLocal.add(
  normalLocal.mul(sin(time.add(positionLocal.y)).mul(0.1))
);
```

### Alpha Cutout

```javascript
import { texture, float } from 'three/tsl';

material.opacityNode = texture(alphaMap).r;
material.alphaTestNode = float(0.5);
```

### PBR Properties

```javascript
import { float, color } from 'three/tsl';

const material = new MeshPhysicalNodeMaterial();
material.clearcoatNode = float(1.0);
material.clearcoatRoughnessNode = float(0.1);
material.transmissionNode = float(0.9);
material.iorNode = float(1.5);
material.thicknessNode = float(0.5);
```

© zebbern · MIT · zebbern/claude-code-guide

Similar IDE rules

All IDE rules for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set86

The whole set →
drei-use-gltf The drei-use-gltf rule guides GLTF loading through useGLTF, including caching and preloading. It fits React Three Fiber scenes that need model assets. CX Codex +1 ★ 4,719repo stars perf-zustand-selectors perf-zustand-selectors — a rule file that pushes the agent to subscribe components to individual Zustand slices instead of the whole store, so a component repaints only when the data it reads changes. CX Codex +1 ★ 4,719repo stars geometry-instanced-mesh geometry-instanced-mesh guides AI agents to use THREE.InstancedMesh instead of separate meshes for repeating 3D objects. CX Codex +1 ★ 4,719repo stars webgpu-renderer The webgpu-renderer rule guides Three.js WebGPU setup with a WebGL 2 fallback. Use it when a 3D scene needs compute work, GPU particles, or indirect rendering. CX Codex +1 ★ 4,719repo stars core-web-vitals core-web-vitals is a Claude Code rule for loading Three.js models and textures without letting heavy 3D delay first paint or degrade LCP, FID and CLS. CX Codex +1 ★ 4,719repo stars postprocessing-optimization postprocessing-optimization is a rule for Three.js and React Three Fiber that helps optimize post-processing by combining shader passes and tuning render settings. CX Codex +1 ★ 4,719repo stars timeline-builder timeline-builder is a Claude Code skill that turns JSON event data into interactive HTML timelines with vertical, horizontal, or dual-side layouts. It covers project milestones, release histories, and resumes. CX Codex +1 ★ 4,719repo stars loading-suspense loading-suspense — a rule that keeps async React Three Fiber components inside Suspense, so a model still downloading doesn't leave the canvas blank. CX Codex +1 ★ 4,719repo stars

Project sponsors

Companies that keep this analytics open