webgpu-threejs-tsl
Original:🇺🇸 English
Not Translated
7 scriptsChecked / no sensitive code detected
Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.
1installs
Added on
NPX Install
npx skill4agent add dbuck/webgpu-claude-skill webgpu-threejs-tslSKILL.md Content
WebGPU Three.js with TSL
TSL (Three.js Shading Language) is a node-based shader abstraction that lets you write GPU shaders in JavaScript instead of GLSL/WGSL strings.
Quick Start
javascript
import * as THREE from 'three/webgpu';
import { color, time, oscSine } from 'three/tsl';
const renderer = new THREE.WebGPURenderer();
await renderer.init();
const material = new THREE.MeshStandardNodeMaterial();
material.colorNode = color(0xff0000).mul(oscSine(time));Skill Contents
Documentation
- - Types, operators, uniforms, control flow
docs/core-concepts.md - - Node materials and all properties
docs/materials.md - - GPU compute with instanced arrays
docs/compute-shaders.md - - Built-in and custom effects
docs/post-processing.md - - Custom WGSL functions
docs/wgsl-integration.md
Examples
- - Minimal WebGPU project
examples/basic-setup.js - - Custom shader material
examples/custom-material.js - - GPU compute particles
examples/particle-system.js - - Effect pipeline
examples/post-processing.js - - Complete Earth with atmosphere
examples/earth-shader.js
Templates
- - Starter project template
templates/webgpu-project.js - - Compute shader template
templates/compute-shader.js
Reference
- - Quick reference cheatsheet
REFERENCE.md
Key Concepts
Import Pattern
javascript
// Always use the WebGPU entry point
import * as THREE from 'three/webgpu';
import { /* TSL functions */ } from 'three/tsl';Node Materials
Replace standard material properties with TSL nodes:
javascript
material.colorNode = texture(map); // instead of material.map
material.roughnessNode = float(0.5); // instead of material.roughness
material.positionNode = displaced; // vertex displacementMethod Chaining
TSL uses method chaining for operations:
javascript
// Instead of: sin(time * 2.0 + offset) * 0.5 + 0.5
time.mul(2.0).add(offset).sin().mul(0.5).add(0.5)Custom Functions
Use for reusable shader logic:
Fn()javascript
const fresnel = Fn(([power = 2.0]) => {
const nDotV = normalWorld.dot(viewDir).saturate();
return float(1.0).sub(nDotV).pow(power);
});When to Use This Skill
- Setting up Three.js with WebGPU renderer
- Creating custom shader materials with TSL
- Writing GPU compute shaders
- Building post-processing pipelines
- Migrating from GLSL to TSL
- Implementing visual effects (particles, water, terrain, etc.)
Resources
- Three.js TSL Wiki
- WebGPU Examples (files prefixed with )
webgpu_