Files
workinf_Blender_Wasm/tools/web/README-render-tools.md
mes123456 63db6caf1f
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
feat(web): studio worlds, camera-view/offscreen environment parity, material and undo coverage
Environment lighting:
- ship all eight desktop studiolights/world datasets (WBENV1 float32) and a
  shared loader used by both the main viewport and the offscreen worker
- add the N-panel "studio 环境" selector
- rotate the world background together with the environment
  (backgroundRotation/backgroundIntensity), so camera view and offscreen
  renders match the desktop Mapping-node behaviour

Verification (Chromium, OPFS, NOT_CLAIMED):
- environment lighting + 8 world pixel identity
- camera-view rotation correspondence (camera matrices, 207 samples)
- offscreen vs on-screen background parity after hiding geometry (1305 samples)
- metals case extended with material-field OPFS roundtrip
- material Principled edits and rename undo/redo
- eight studio worlds: pairwise frame differences + luminance rank correlation
- undo history depth capped at 64 steps and undo across OPFS save/reopen

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 09:27:47 +08:00

72 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 渲染与界面证据工具
这些是从「Web Blender 渲染入门」教程的实走与排查中沉淀下来的通用工具。它们不依赖教程本身:
换任意 `.blend`、任意页面入口都能用。
共用前置:Playwright 从 `web/node_modules` 解析;有头采集需要 `DISPLAY=:1`;
服务端原生渲染需要开发服务器带 `BLENDER_BIN`。
## 工具一览
| 工具 | 作用 | 典型用法 |
| --- | --- | --- |
| `inspect-image.mjs` | 判定图片里到底有没有画面:尺寸、alpha 覆盖率、最亮通道、verdict。空帧退出码 2 | `node tools/web/inspect-image.mjs <目录或文件...> [--json] [--allow-blank]` |
| `probe-web-engine.mjs` | 有头打开真实界面,逐引擎渲染一帧,下载产物,判像素并收集控制台报错(含 warm-up 阶段打印的着色器编译错误) | `node tools/web/probe-web-engine.mjs --port 5186 [--path server] [--engines ...] [--console]` |
| `probe-ui-paint.mjs` | 回答「这个元素是真的没渲染,还是被别的元素盖住了」:外框、上下层元素、滚动容器。可先 `--blend` 载入工程、`--workspace` 切工作区、`--click` 依次点击进入待测状态 | `node tools/web/probe-ui-paint.mjs --port 5186 --url "/?ui=web" --workspace Rendering --selector '<css>'` |
| `capture-render-basics.mjs` | 教程截图/成片的完整采集(四条通路 + 原生三引擎 + 页内 WASM) | `DISPLAY=:1 node tools/web/capture-render-basics.mjs --port 5186 --gpu hardware` |
| `check-render-basics.mjs` | 上述产物的门禁:报告 PASS、截图哈希、相邻图不重复、页面无内联脚本/远程资源、缺口仍被记录 | `node tools/web/check-render-basics.mjs` |
| `lib/image-stats.mjs` | 共用库:PNG 解码(含行过滤器还原)、RGBA 归一化、JPEG 尺寸、像素统计、SHA-256 | `import {imageStats} from "./lib/image-stats.mjs"` |
浏览器启动、`waitScene`、截图等通用动作复用 `course/lib/lesson-recorder.mjs`,不另起一套。
## 判定口径
`inspect-image.mjs` 与 `probe-web-engine.mjs` 使用同一套 verdict:
| verdict | 含义 |
| --- | --- |
| `picture` | 正常画面:不透明像素占比 ≥ 2%,且最亮通道 > 2 |
| `transparent` | 几乎全透明:什么也没画出来(典型:状态 SUCCEEDED、文件 220 KB) |
| `noise-only` | 不透明但所有通道 ≤ 2:只是清屏值加抖动 |
| `opaque-jpeg` | JPEG 只读尺寸,不做像素统计 |
| `error` | 读不出来(格式不支持、文件损坏、路径不存在) |
两个容易踩的坑,已写进库注释:
- PNG 每行有一个过滤器字节,不还原的话每个值都是相对前一个像素的增量,空帧也会"统计出"少量不透明像素。
- 空帧不一定 alpha 全 0:EEVEE 的失败帧 alpha 全 0 但 RGB 有抖动值(最大 1),所以只看 alpha 会误判,必须同时看最亮通道。
## 典型流程
```bash
# 1. 起服务(服务端原生通路需要 BLENDER_BIN)
cd web && BLENDER_BIN=/path/to/blender npm run dev -- --host 127.0.0.1 --port 5184 --strictPort
# 2. 引擎体检:哪个引擎真的画出了画面
DISPLAY=:1 node tools/web/probe-web-engine.mjs --port 5186 --path server --console
# 3. 手上有成片时,直接判
node tools/web/inspect-image.mjs web/app/public/tutorial/render-basics/evidence
# 4. 组件"看不见"时,先查是不是被盖住了
DISPLAY=:1 node tools/web/probe-ui-paint.mjs --port 5186 --url "/?ui=web" \
--selector '[data-testid="render-result-view"]'
# 5. 教程产物
DISPLAY=:1 node tools/web/capture-render-basics.mjs --port 5186 --gpu hardware
node tools/web/check-render-basics.mjs
```
## 已知结论(2026-11-20)
页内 WASM 通路(默认地址 `/`)的 EEVEE 输出全透明帧。`probe-web-engine.mjs --console`
会同时给出证据链:`BLANK` 判定 + `MADefault_Surface_*` 着色器在 `#version 300 es` 下编译失败
(`cannot convert from 'const int' to 'highp uint'`、`unsupported storage buffer`)。
这是 WebGL 后端的 EEVEE 着色器移植缺口,未修复;Workbench 同路径正常。
## 已被取代的探针
`probe-wasm-engines.mjs`(逐引擎出图)与 `probe-wasm-eevee-console.mjs`(只抓控制台)
的功能已合并进 `probe-web-engine.mjs`(`--console` 即原控制台探针)。保留旧文件只因仍有历史
status 文档引用;新工作请用 `probe-web-engine.mjs`。