‹ 首页

webgpu-threejs-tsl

@dedekpo · 收录于 昨天 · 上游提交 1 个月前

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.

适合你,如果要在 Three.js 中使用 WebGPU 和 TSL 着色语言

/ 通过 npx 安装 校验哈希
npx oh-my-skill add dedekpo/stylized-scene/webgpu-threejs-tsl
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- dedekpo/stylized-scene/webgpu-threejs-tsl
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify dedekpo/stylized-scene/webgpu-threejs-tsl
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
88GitHub stars
~677最小装载
~26.3K含声明引用
~26.3K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 531c572 · 表述以原文为准
它做什么

安装后,Claude 能指导你使用 TSL(Three.js 着色语言)在 JavaScript 中编写 GPU 着色器,提供节点材质、计算着色器、后处理等示例代码和文档。

什么时候触发

当你询问关于 Three.js WebGPU 设置、TSL 着色器、节点材质或 GPU 计算相关问题时触发。

装好后可以这样说
提供节点材质示例代码。
给出计算着色器模板。
技能原文 SKILL.md作者撰写 · MIT · 531c572

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
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
  • docs/core-concepts.md - Types, operators, uniforms, control flow
  • docs/materials.md - Node materials and all properties
  • docs/compute-shaders.md - GPU compute with instanced arrays
  • docs/post-processing.md - Built-in and custom effects
  • docs/wgsl-integration.md - Custom WGSL functions
  • docs/device-loss.md - Handling GPU device loss and recovery
  • docs/limits-and-features.md - WebGPU device limits and optional features
Examples
  • examples/basic-setup.js - Minimal WebGPU project
  • examples/custom-material.js - Custom shader material
  • examples/particle-system.js - GPU compute particles
  • examples/post-processing.js - Effect pipeline
  • examples/earth-shader.js - Complete Earth with atmosphere
Templates
  • templates/webgpu-project.js - Starter project template
  • templates/compute-shader.js - Compute shader template
Reference
  • REFERENCE.md - Quick reference cheatsheet
Key Concepts
Import Pattern
// 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:

material.colorNode = texture(map);        // instead of material.map
material.roughnessNode = float(0.5);      // instead of material.roughness
material.positionNode = displaced;         // vertex displacement
Method Chaining

TSL uses method chaining for operations:

// 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 Fn() for reusable shader logic:

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
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。