Files
2nd/10_Wiki/Topics/Architecture/TSL_(Three_Shader_Language).md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

4.7 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-tsl-three-shader-language TSL (Three Shader Language) 10_Wiki/Topics verified self
Three.js Shading Language
TSL
Node Material
none A 0.9 applied
threejs
webgpu
shader
graphics
2026-05-10 pending
language framework
javascript threejs-r170

TSL (Three Shader Language)

매 한 줄

"매 GLSL/WGSL 의 abstract 의 JS-native shader DSL". 매 Three.js 의 node-based material system 의 evolution — 매 single source 의 WebGL2 + WebGPU 의 compile. 2026 의 r170+ 의 standard — 매 GLSL string 의 deprecated path.

매 핵심

매 왜 TSL

  • Backend agnostic: 매 동일 code 의 WebGL2 (GLSL) + WebGPU (WGSL) 의 emit.
  • JS-native: 매 IDE autocomplete, type check, debug 의 enable.
  • Composable: 매 node graph 의 reuse — 매 material 의 lego.
  • Compute shaders: 매 GPGPU 의 first-class — particles, sims.

매 핵심 concepts

  • Node: 매 shader 의 unit (uniform, attribute, op).
  • NodeMaterial: 매 MeshBasicMaterial 의 TSL 의 version.
  • Stage: vertex / fragment / compute.
  • Varying: 매 vertex → fragment 의 interpolated.

매 응용

  1. Custom PBR materials (procedural normal, AO).
  2. Post-processing (bloom, SSAO via TSL).
  3. GPGPU particles (10^6 particles compute shader).
  4. Procedural textures (noise, voronoi).

💻 패턴

Basic — vertex displacement

import * as THREE from 'three';
import { positionLocal, sin, time, vec3, MeshStandardNodeMaterial } from 'three/tsl';

const mat = new MeshStandardNodeMaterial();
mat.positionNode = positionLocal.add(
    vec3(0, sin(positionLocal.x.add(time)).mul(0.5), 0)
);
mat.colorNode = vec3(0.2, 0.6, 1.0);

Procedural fragment — checker

import { uv, floor, mod, vec3, mix, MeshBasicNodeMaterial } from 'three/tsl';

const scaled = uv().mul(8);
const checker = mod(floor(scaled.x).add(floor(scaled.y)), 2);
const mat = new MeshBasicNodeMaterial();
mat.colorNode = mix(vec3(0.1), vec3(0.9), checker);

Custom function (Fn)

import { Fn, vec3, dot, normalize } from 'three/tsl';

const lambert = Fn(([n, l]) => {
    return dot(normalize(n), normalize(l)).max(0);
});

mat.colorNode = lambert(normalLocal, vec3(1, 1, 0)).mul(albedo);

Compute shader — particle update

import { Fn, instanceIndex, storage, time, vec3, sin } from 'three/tsl';

const positions = storage(buffer, 'vec3', count);
const update = Fn(() => {
    const i = instanceIndex;
    positions.element(i).addAssign(
        vec3(sin(time.add(i)), 0.01, 0).mul(0.01)
    );
})().compute(count);

renderer.computeAsync(update);

Uniform binding

import { uniform, MeshStandardNodeMaterial } from 'three/tsl';

const intensity = uniform(1.0);
const mat = new MeshStandardNodeMaterial();
mat.emissiveNode = albedo.mul(intensity);

// later
intensity.value = 2.5;

Noise — simplex via TSL

import { mx_noise_float, positionLocal, vec3 } from 'three/tsl';

const n = mx_noise_float(positionLocal.mul(2));
mat.positionNode = positionLocal.add(normalLocal.mul(n.mul(0.1)));

WebGPU renderer setup

import { WebGPURenderer } from 'three/webgpu';

const renderer = new WebGPURenderer({ antialias: true });
await renderer.init();
document.body.appendChild(renderer.domElement);

매 결정 기준

상황 Approach
New Three.js project (2026+) TSL + WebGPURenderer
Legacy GLSL maintenance Keep ShaderMaterial
Cross-backend portability TSL
GPGPU / compute TSL compute shaders
Quick prototype Built-in materials

기본값: 매 TSL + NodeMaterial — 매 r170+ 의 future-proof.

🔗 Graph

🤖 LLM 활용

언제: shader generation, GLSL → TSL migration, procedural pattern synthesis. 언제 X: bleeding-edge TSL APIs (training cutoff lag) — 매 docs 의 verify.

안티패턴

  • String-concat GLSL in 2026: 매 deprecated path — 매 TSL 의 migrate.
  • Heavy compute on main thread: 매 compute shader 의 offload.
  • Recompile on every frame: 매 uniform.value 의 update — 매 node 의 rebuild 의 X.

🧪 검증 / 중복

  • Verified (Three.js r170+ docs, threejs.org/examples TSL category).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — TSL nodes, compute shaders, WebGPU