WebGLRenderer → WebGPURenderer
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**当前架构**:Three.js r160 + `WebGLRenderer`(WebGL 2.0),自定义 ShaderMaterial 分布在 Engine(水面)、MaterialManager(onBeforeCompile 注入)、BatchedMaterial、RainEffect 四处。
**迁移收益**:
1. **Compute shader**(最关键):AO 计算和 FaceCulling 目前跑在 CPU Worker 线程,有序列化开销。WebGPU 的 compute shader 可以搬到 GPU 并行执行,有望删掉两个 Worker。
2. **CPU draw call 开销降低**:WebGPU 的 command buffer 预录制机制比 WebGL 隐式状态机高效。
3. **显式 buffer 管理**:可标注 buffer 用途(STORAGE/MAP_READ 等),减少不必要的 GPU↔CPU 数据传输。
**需要改动的位置**:
| 文件 | 内容 |
|------|------|
| `Engine.js` | `WebGLRenderer` → `WebGPURenderer` |
| `MaterialManager.js` | `onBeforeCompile` 注入的 GLSL → WGSL |
| `BatchedMaterial.js` | `ShaderMaterial` 继承类,GLSL → WGSL |
| `Engine.js` 水面 | vertex/fragment shader → WGSL |
| `RainEffect.js` | 雨滴 `ShaderMaterial`,GLSL → WGSL |
**不改的部分**:所有游戏逻辑、场景图、InstancedMesh 架构、World/Chunk 装配机制均不变。
**预估工作量**:2-4 周(核心风险在自定义 shader 的 WGSL 迁移,以及 Three.js WebGPURenderer 对 `onBeforeCompile` + InstancedMesh 组合的兼容性)。
**路径建议**:先在 `WebGPURenderer` 上跑通兼容性验证(不迁移 compute shader),确认 InstancedMesh + 自定义材质表现正常后,再逐步把 AO/FaceCulling 移到 compute shader。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the WebGLRenderer setup in Engine.js and the custom shader files or classes named in MaterialManager.js, BatchedMaterial.js, Engine.js, and RainEffect.js. First run the proposed renderer compatibility check without moving compute work, focusing on InstancedMesh and custom materials. Done means the renderer and listed shaders work correctly before any AO or FaceCulling compute migration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, web-dev
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100