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
.claude/rules/tsl-material-slots.mdWhat 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
positionNodeandsin(time)fromthree/tsl - Configure
MeshPhysicalNodeMaterialwithtransmissionNode,thicknessNode, andiorNode - Set up alpha cutout on a standard material using
opacityNodeandalphaTestNode
How to install tsl-material-slots
Manually: put the files in place
.claude/rules/tsl-material-slots.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/tsl-material-slots.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/tsl-material-slots.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/tsl-material-slots.mdManually: put the files in place
.clinerules/tsl-material-slots.mdStep 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