#549:官方场景偏暗 —— 把两个手调增益改回官方语义(直射光 intensity、烘焙光强 lightRange)
问题(#549):3D 棋盘按战场显示官方场景后,整体比官方实机明显偏暗、发闷。只取棋盘区域做量化:官方截图
平均 RGB 152.4/125.8/92.3(亮度 129.0),本项目 98.8/89.4/65.0(亮度 89.7)。
原因:官方场景材质的两个增益是当初照截图手调的猜值(代码注释里自己标了 [ASSUMED]):
export const SCENE_LIGHT = Object.freeze({ range: 8.0, ambient: 0.2, direct: 0.8, indirect: 0.4 });
而官方数据是(从客户端场景包里 dump 出来的真值,见下):
scene.json light = { dir: [0.36121, 0.44604, 0.81889], color: [1.0, 0.9312, 0.87131], intensity: 1.1 }
Light「Mainlight (1)」: m_Type=1(Directional) m_Intensity=1.1 m_BounceIntensity=1.5
lightRange = 8.0
- direct 0.8 ⇒ 直射光 = lin(color) × (1.1 × 0.8) = 0.88,比官方的 1.1 暗 20%;
- indirect 0.4 ⇒ 烘焙间接光被乘成 lightRange × 0.4 = 3.2,而 lightmap 的语义是"贴图 1.0 = lightRange 的线性光"
(scenes.py:`L = 5^2.2 · A^2.2 · RGB`,PNG 存 (L / lightRange)^(1/2.2)),所以 indirect 必须为 1 才等于官方烘焙值,
0.4 等于把间接光压掉 60%。片元里的 `pow(lm.rgb, 2.2) * uLmScale` 与 `uLightColor * N·L * shade` 正是这两项。
改动:`SCENE_LIGHT` 的 direct / indirect 改回 1(= 场景自己的值,与那段注释原本的描述一致),并把注释改成
说明它们为什么必须是 1、以及低于 1 会相对官方渲染变暗(#549)。
实测(同一 m04 场景、同一相机,只取棋盘区域求平均):
官方截图 亮度 129.0
改前 亮度 89.7(−30%)
改后 亮度 103.3(−20%)
顺手排除的两个猜想(都量过,都不是原因):
- 雾:官方 RenderSettings 是 m_Fog = False,而 scene.js 给场景挂了 T.Fog(0x0c1114, 17, 36)。A/B 实测雾开/关
亮度 95.3 / 95.4 ⇒ 在本视角下没有影响(相机在 near 以内),本次不动它。
- 焦点暗角:官方场景材质也套了棋盘的 focusMask(框外 × uFocusDim = 0.72)。A/B 实测去掉后 103.3 → 106.6(+3%),
因为本视角的焦点框覆盖了大部分棋盘;官方场景本身没有这种衰减,但它是棋盘的既有玩法表现,留待单独确认,本次不改。
证据来源:`.cache/official-scenes/<version>/scenes/.../level_<stage>.ab` 用 UnityPy(配合 tools/local-extract/aklz4.py
注册的 LZ4AK 解码器)dump 出的 Light 与 RenderSettings;以及仓库自己的 tools/local-extract/scenes.py 里 lightmap 的
RGBM 编码定义。
测试:node --test test/render/board3d-scene.test.js test/render/board3d.test.js test/render/boardart.test.js(见 PR)。
This commit is contained in:
1 parent
cf7a940027
commit
045cc96172
1 file changed
+4
-2
@@ -349,9 +349,11 @@ export function smogMaterial(THREE, tex, focus) {
|
||||
* not reproduced: the albedo is lit by the baked indirect light of the scene's lightmap plus the scene's key light
|
||||
* masked by its baked shadow, in linear light (Unity's Shadowmask lighting mode). `range` — the linear light a lightmap
|
||||
* texel of 1.0 stands for when scene.json has no lightRange; [ASSUMED] `ambient` — the light of a mesh without a
|
||||
* lightmap page; `direct` / `indirect` — gains of the two terms (1 = the scene's own values).
|
||||
* lightmap page; `direct` / `indirect` — gains of the two terms, both 1: the scene's own values (the key light's
|
||||
* `light.intensity`, and the lightmap's baked linear light, whose texel is (L / lightRange)^(1/2.2)). Anything below 1
|
||||
* darkens the board against the official render (issue #549).
|
||||
*/
|
||||
export const SCENE_LIGHT = Object.freeze({ range: 8.0, ambient: 0.2, direct: 0.8, indirect: 0.4 });
|
||||
export const SCENE_LIGHT = Object.freeze({ range: 8.0, ambient: 0.2, direct: 1, indirect: 1 });
|
||||
|
||||
const colorOf = (info, key, fallback = [1, 1, 1, 1]) => {
|
||||
const c = info && info.colors && Array.isArray(info.colors[key]) ? info.colors[key] : fallback;
|
||||
|
||||
Reference in new issue
Block a user