跳到主要内容
shader-overflow-debugger · 代码
查看代码目录
性能、采样与移动端质量 · source map

Shader 溢出:画面“白了”不一定是曝光:代码定位

这里显示课程实际引用的代码片段。先看每段在说人话,再回到实验验证它对画面的影响。

← 回到对应自由实验状态
精度诊断

深度/浮点范围为什么会产生可见误差。

src/lib/lab/graphics-debugger/debugger-source.ts · section precision

当前起点查看这段精确实现
const depthRatio = log(far / near) / log(1000000.0);
const precisionError = precision === "f16" ? depthRatio * (worldScale / 24.0) : depthRatio * 0.04;
const reversedZ = 1.0 - depth / far; // put precision where the camera needs it
阶段与资源错误

先确认错误来自阶段契约还是数值。

src/lib/lab/graphics-debugger/debugger-source.ts · section stages

按需展开查看这段精确实现
// Graphics Debugger Suite — executable teaching model
type Space = "tangent" | "object" | "world" | "view";
const normal = normalize(TBN * decodeNormalMap(rgb));
const correctedNormal = normalize(inverseTranspose(model) * vec4(normal, 0.0)).xyz;
const stage = { vertex, varying, fragment };
shaderError = !normalDecode || (worldScale !== 1.0 && !inverseTranspose);
可复现 Debug 报告

保留参数和风险,让异常可以复盘。

src/lib/lab/graphics-debugger/debugger-source.ts · section debug

按需展开查看这段精确实现
reportId = `${scene}-${debugMode}-${hash(config)}`;
risk = max(shaderError, precisionError, cpuMs > targetMs, gpuMs > targetMs);