docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
---
|
||||
id: wiki-2026-0508-tsl-three-shader-language
|
||||
title: TSL (Three Shader Language)
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Three.js Shading Language, TSL, Node Material]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [threejs, webgpu, shader, graphics]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: javascript
|
||||
framework: 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
|
||||
```javascript
|
||||
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
|
||||
```javascript
|
||||
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)
|
||||
```javascript
|
||||
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
|
||||
```javascript
|
||||
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
|
||||
```javascript
|
||||
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
|
||||
```javascript
|
||||
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
|
||||
```javascript
|
||||
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
|
||||
- 부모: [[Three.js]] · [[WebGPU]]
|
||||
- 변형: [[GLSL]] · [[WGSL]]
|
||||
- 응용: [[PBR]] · [[Post-processing]]
|
||||
- Adjacent: [[Node Material]] · [[Compute_Shaders|Compute Shaders]]
|
||||
|
||||
## 🤖 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 |
|
||||
Reference in New Issue
Block a user