Преглед на файлове

【新增】支持镜内贴图 mip 与镜内细节精简

新增第 3 组配置,用于在瞄准时进一步降低镜内渲染开销。

- 镜内贴图 mip:自定义时覆盖镜内相机的 StreamingController.streamingMipmapBias,
  在镜内相机创建时一次写入(全仓仅 Init 写该值)。
- 镜内细节:自定义时关闭镜内泛光、终极泛光、色散与鱼眼;这些组件不会被每帧覆盖,
  故按瞄具在 CopyComponentFromOptic 的 postfix 中一次性覆盖,并按瞄具 id 缓存原始值以便还原。
- 刻意不做体积光与散射:OpticComponentUpdater.LateUpdate 每帧从主相机覆盖它们,
  要做就得每帧强写,收益与风险不匹配。
- 服务重命名为 OpticQualityService;新增 ScopeSettingMode、ScopeMipMath 及单元测试。
- 文档同步:docs/configuration.md、docs/principle.md、docs/compatibility.md。
PJ568 преди 1 месец
родител
ревизия
86c7349865

+ 4 - 2
docs/compatibility.md

@@ -4,6 +4,7 @@
 
 - **PiP-Disabler**(`com.fiodor.pipdisabler`):它是对 `SetResolution` 的 **postfix 门控**(不改写入参、不改字段),与本插件共存;被它抑制的镜内渲染不会触发本插件的冲突重试。
 - **Fontaine's FOV Fix / Amands's Graphics**:patch 的是 `OpticComponentUpdater` 等与本插件不重叠的目标,无直接冲突。
+- **`OpticComponentUpdater.CopyComponentFromOptic`**:本插件新增的 patch 目标是 `OpticComponentUpdater.CopyComponentFromOptic`(postfix);它与 Amands's Graphics(patch `OpticComponentUpdater.Awake`)、Fontaine's FOV Fix(patch `OpticComponentUpdater.LateUpdate`)**目标不同、不重叠**;本插件不 patch `LateUpdate`,因此不会与 FOV Fix 争抢每帧覆盖。
 - **DERP(Dynamic External Resolution Patch)**:DERP 只对**主相机**操作——patch `OpticSight.OnEnable` / `OpticSight.OnDisable` / `Player.FirearmController.ChangeAimingMode`,并在 `EFT.CameraControl.CameraManager` 上调用 `SSAAImpl.Switch` / `SetAntiAliasing` / `SetFSR2` / `SetFSR3`。它既不 patch `OpticCameraManager.SetResolution`,也不改 `OpticFinalResolution`,与本插件**没有重叠的 patch 目标或共享状态**,可以同时使用;效果叠加:镜外由 DERP 降,镜内由本插件降。注意两点:① DERP 自身在 DLSS/FSR 下进镜会黑屏闪烁(官方建议用 TAA + Sampling Downgrade 规避);② 两者同时降低分辨率时,镜片区域会被“双重降质”,通常比单独用任一都更糊。
 - **DLSS / FSR**:本插件**不切换超分档**;但开启超分时改变镜内 RT 尺寸可能产生一帧闪烁,可关闭“瞄准中立即应用”规避。SPT 官方亦记录过“DLSS/FSR 下进镜切换档位会黑屏闪烁”。
 
@@ -11,7 +12,7 @@
 
 - **无法独立设置镜内超分档**:全游戏只有一套挂在主相机上的 `SSAA`/`SSAAImpl`,镜内画面是其一部分;独立的镜内 FSR/DLSS 需要另挂一套组件,本插件不做。
 - **瞄准中改分辨率可能有一帧闪烁**:因为会销毁并重建 RenderTexture;可将“瞄准中立即应用”关闭以规避。
-- **镜内低分辨率下纹理锯齿会更明显**:镜内相机的 mipmap bias 只在 `Init()` 时设置一次,插件不做补偿。
+- **镜内低分辨率下纹理锯齿会更明显**:镜内相机的 mipmap bias 只在 `Init()` 时设置一次,默认随画质档变化;可将「镜内贴图 mip 模式」设为「自定义」并用「Mip 偏差」覆盖它来调节。
 - **与其它改 `SetResolution` 的模组可能冲突**:若第三方 prefix 改写同一入参,插件检测到目标未生效后会暂停重试直至你更改目标值,避免反复重建 RenderTexture。
 - **版本敏感**:依赖具体类型与方法,EFT 更新后可能失效。
 - **CI 限制**:客户端插件必须引用专有程序集,公共 runner 无法构建,故仓库只保留 `test.yml`(跑纯逻辑单测);发行包用 `scripts/release.sh` 本地一键发布。
@@ -28,6 +29,7 @@
 
 - **PiP-Disabler** (`com.fiodor.pipdisabler`): it is a **postfix gate** on `SetResolution` (it neither rewrites the argument nor the field), so it coexists with this plugin; suppressed scoped rendering does not trigger this plugin's conflict retry.
 - **Fontaine's FOV Fix / Amands's Graphics**: they patch targets (`OpticComponentUpdater`, etc.) that do not overlap this plugin, so there is no direct conflict.
+- **`OpticComponentUpdater.CopyComponentFromOptic`**: this plugin's new patch target is `OpticComponentUpdater.CopyComponentFromOptic` (postfix); it is **different from and does not overlap** Amands's Graphics (which patches `OpticComponentUpdater.Awake`) or Fontaine's FOV Fix (which patches `OpticComponentUpdater.LateUpdate`); this plugin does not patch `LateUpdate`, so it does not contend with FOV Fix for the per-frame override.
 - **DERP (Dynamic External Resolution Patch)**: DERP acts on the **main camera** only — it patches `OpticSight.OnEnable` / `OpticSight.OnDisable` / `Player.FirearmController.ChangeAimingMode` and calls `SSAAImpl.Switch` / `SetAntiAliasing` / `SetFSR2` / `SetFSR3` on `EFT.CameraControl.CameraManager`. It neither patches `OpticCameraManager.SetResolution` nor touches `OpticFinalResolution`, so it shares no patch target or state with this plugin and the two can run together; their effects stack: the exterior is lowered by DERP and the in-scope image by this plugin. Two caveats: (1) DERP itself black-flickers on scope transition under DLSS/FSR (the official advice is TAA + Sampling Downgrade); (2) when both lower resolution, the lens area is degraded twice and usually looks softer than with either alone.
 - **DLSS / FSR**: this plugin **does not switch upscaler modes**; however, changing the scoped RT size while an upscaler is active may cause a one-frame flicker — turn off "瞄准中立即应用" to avoid it. SPT officially documents a black flicker when switching modes under DLSS/FSR.
 
@@ -35,7 +37,7 @@
 
 - **No independent in-scope upscaler setting**: the game has a single `SSAA`/`SSAAImpl` on the main camera and the scoped image is part of it; a truly independent in-scope FSR/DLSS would require attaching a second component, which this plugin does not do.
 - **Changing resolution while scoped may flash for one frame** because the RenderTexture is destroyed and recreated; turn off "瞄准中立即应用" to avoid it.
-- **Texture aliasing becomes more visible at low in-scope resolutions**: the scope camera's mipmap bias is only set once in `Init()`, and the plugin does not compensate.
+- **Texture aliasing becomes more visible at low in-scope resolutions**: the scope camera's mipmap bias is only set once in `Init()` and defaults to a quality-dependent value; set "镜内贴图 mip 模式 | Scope Mip Mode" to "自定义" (custom) and override it with "Mip 偏差 | Mip Bias" to adjust.
 - **Possible conflict with other mods that patch `SetResolution`**: if a third-party prefix rewrites the same argument, the plugin detects the target not taking effect and pauses retries until you change the target, avoiding repeated RenderTexture rebuilds.
 - **Version sensitive**: it depends on specific types and methods and may break after an EFT update.
 - **CI limitation**: a client plugin must reference proprietary assemblies, which public runners cannot build, so the repository keeps only `test.yml` (pure-logic unit tests); release packages are produced locally with `scripts/release.sh`.

+ 60 - 0
docs/configuration.md

@@ -15,6 +15,9 @@
 | 2. 镜内分辨率 · Scope Resolution | 屏幕高度比例 \| Screen Height Ratio | `0.5` | 镜内边长 = round(屏幕高度 × 该值)。 |
 | 2. 镜内分辨率 · Scope Resolution | 绝对像素 \| Absolute Pixels | `1024` | 镜内方形 RenderTexture 的边长。 |
 | 2. 镜内分辨率 · Scope Resolution | 瞄准中立即应用 \| Apply While Scoped | `true` | 关闭时,瞄准期间的改动推迟到退出镜内后应用。 |
+| 3. 镜内贴图与细节 · Scope Textures & Details | 镜内贴图 mip 模式 \| Scope Mip Mode | `游戏默认` | 游戏默认 / 自定义。自定义时覆盖镜内相机的贴图 mip 偏差。 |
+| 3. 镜内贴图与细节 · Scope Textures & Details | Mip 偏差 \| Mip Bias | `3` | `-2`…`8`;绝对值覆盖镜内 `streamingMipmapBias`,越大纹理越糊、越省带宽。 |
+| 3. 镜内贴图与细节 · Scope Textures & Details | 镜内细节模式 \| Scope Detail Mode | `游戏默认` | 游戏默认 / 自定义。自定义时关闭镜内泛光、终极泛光、色散与鱼眼。 |
 
 ## 三种取值方式
 
@@ -28,6 +31,33 @@
 
 默认开启。开启时,你在瞄准期间改动目标值会立即重建镜内 RenderTexture;关闭时,瞄准期间的改动会推迟到退出镜内后才应用。因为重建会销毁并重新创建 RenderTexture,瞄准中改值可能产生一帧闪烁,关闭此项可规避。
 
+## 镜内贴图 mip
+
+覆盖对象是镜内相机自己的 `UnityEngine.StreamingController.streamingMipmapBias`。游戏在 `EFT.CameraControl.OpticCameraManager.Init()` 中把它设为 `GraphicsSettingsGroup.TextureQualityToMipBias(TextureQuality)`,即 `Clamp(2 − 贴图品质, 0, 2)`(`TextureQuality` 取 0–2,因此游戏默认值落在 0–2 之间);全仓库只有这一处写镜内相机的该值,且不会每帧刷新。
+
+「镜内贴图 mip 模式」设为「自定义」时,插件按「Mip 偏差」的**绝对值**覆盖它,值越大纹理越糊、越省带宽。覆盖只在镜内相机创建时执行一次即可持久,无需每帧。
+
+> 注意:`streamingMipmapBias` 是绝对值覆盖,而非在游戏默认值上叠加偏移;想保持游戏行为就选「游戏默认」。
+
+## 镜内细节
+
+覆盖对象是镜内相机上由 `EFT.CameraControl.OpticComponentUpdater.CopyComponentFromOptic(OpticSight)` 按每瞄具 `ScopeEffectsData` 设置的组件开关;游戏**不会**每帧重写这些开关,因此插件在该方法的 postfix 里覆盖一次即可持久。
+
+「镜内细节模式」设为「自定义」时,插件关闭镜内相机的以下四个组件:
+
+| 组件 | 含义 |
+| --- | --- |
+| `chromaticAberration` | 色散 |
+| `bloomOptimized` | 泛光 |
+| `ultimateBloom` | 终极泛光 |
+| `fisheye` | 鱼眼 |
+
+应用时机:每次换镜(`CopyComponentFromOptic` 因瞄具实例变化而执行)时在其 postfix 覆盖,配置变更时也重新应用一次。刻意不暴露 `tonemapping`,因为关掉它会破坏镜内色彩与曝光。
+
+### 为什么不提供体积光与散射
+
+`OpticComponentUpdater.LateUpdate()` **每帧**把主相机的 `volumetricLightRenderer.enabled` / `.Resolution`、`undithering.enabled`、`tod_Scattering`、`mboit_Scattering` 覆盖到镜内相机;要修改它们必须在每帧强制覆盖。本插件选择不做,因此只提供第一类的三项配置。
+
 ## 注意
 
 > `屏幕高度比例` 在 4K(2160p)下取 `0.7` 会得到 1512,**高于**游戏默认 1024,反而增加负载。降低镜内分辨率才有助于提升帧数。
@@ -51,6 +81,9 @@ The plugin ships no custom UI or hotkeys. Install [BepInEx ConfigurationManager]
 | 2. 镜内分辨率 · Scope Resolution | 屏幕高度比例 \| Screen Height Ratio | `0.5` | Scope edge = round(screen height × value). |
 | 2. 镜内分辨率 · Scope Resolution | 绝对像素 \| Absolute Pixels | `1024` | Edge length of the square scope RenderTexture. |
 | 2. 镜内分辨率 · Scope Resolution | 瞄准中立即应用 \| Apply While Scoped | `true` | When off, changes made while scoped are deferred until you unscope. |
+| 3. 镜内贴图与细节 · Scope Textures & Details | 镜内贴图 mip 模式 \| Scope Mip Mode | `游戏默认` | Game default / custom. Custom overrides the scope camera's texture mip bias. |
+| 3. 镜内贴图与细节 · Scope Textures & Details | Mip 偏差 \| Mip Bias | `3` | `-2`…`8`; an absolute override of the scope `streamingMipmapBias`; higher = blurrier textures and less bandwidth. |
+| 3. 镜内贴图与细节 · Scope Textures & Details | 镜内细节模式 \| Scope Detail Mode | `游戏默认` | Game default / custom. Custom disables in-scope bloom, ultimate bloom, chromatic aberration and fisheye. |
 
 ## The Three Resolution Modes
 
@@ -64,6 +97,33 @@ In any mode, an invalid value (for example one that cannot be parsed) falls back
 
 On by default. When on, changing the target value while scoped rebuilds the scope RenderTexture immediately; when off, changes made while scoped are deferred until you unscope. Because a rebuild destroys and recreates the RenderTexture, changing the value while scoped may cause a one-frame flicker — turn this off to avoid it.
 
+## Scope Mip
+
+What is overridden is the scope camera's own `UnityEngine.StreamingController.streamingMipmapBias`. In `EFT.CameraControl.OpticCameraManager.Init()` the game sets it to `GraphicsSettingsGroup.TextureQualityToMipBias(TextureQuality)`, i.e. `Clamp(2 − texture quality, 0, 2)` (`TextureQuality` is 0–2, so the game default lands in the 0–2 range); this is the only place in the whole codebase that writes that value on the scope camera, and it is not refreshed every frame.
+
+When "镜内贴图 mip 模式 | Scope Mip Mode" is set to "自定义" (custom), the plugin overrides it with the **absolute value** of "Mip 偏差 | Mip Bias"; a higher value means blurrier textures and less bandwidth. The override is applied once when the scope camera is created and persists, so no per-frame work is needed.
+
+> Note: `streamingMipmapBias` is an absolute override, not an offset added on top of the game default; pick "游戏默认" (game default) to keep the game behavior.
+
+## Scope Detail
+
+What is overridden are the component toggles that `EFT.CameraControl.OpticComponentUpdater.CopyComponentFromOptic(OpticSight)` sets on the scope camera according to each optic's `ScopeEffectsData`; the game does **not** rewrite these toggles every frame, so the plugin overrides them once in that method's postfix and the result persists.
+
+When "镜内细节模式 | Scope Detail Mode" is set to "自定义" (custom), the plugin disables the following four components on the scope camera:
+
+| Component | Meaning |
+| --- | --- |
+| `chromaticAberration` | chromatic aberration |
+| `bloomOptimized` | bloom |
+| `ultimateBloom` | ultimate bloom |
+| `fisheye` | fisheye |
+
+When it applies: once per optic change (when `CopyComponentFromOptic` runs because the optic instance changed) in its postfix, and again on a config change. `tonemapping` is deliberately not exposed, because disabling it would break the in-scope color and exposure.
+
+### Why Volumetric Light and Scattering Are Not Offered
+
+`OpticComponentUpdater.LateUpdate()` copies the main camera's `volumetricLightRenderer.enabled` / `.Resolution`, `undithering.enabled`, `tod_Scattering` and `mboit_Scattering` onto the scope camera **every frame**; changing them would require forcing an override every frame. This plugin chooses not to do so, and therefore offers only the three configs of the first kind.
+
 ## Note
 
 > With `屏幕高度比例`, `0.7` on a 4K (2160p) display yields 1512, which is **higher** than the game default 1024 and therefore costs more. Only lowering the scope resolution helps frame rate.

+ 50 - 0
docs/principle.md

@@ -72,6 +72,31 @@
 
 订阅按 `OpticCameraManager` 实例幂等:战局切换导致管理器重建时,prefix 会把新实例交给服务并退订旧实例。
 
+## 镜内贴图 mip 与细节的可覆盖点
+
+覆盖镜内贴图 mip 与镜内细节的写入点共两处,本插件只介入 `CopyComponentFromOptic`,刻意不碰 `LateUpdate`。
+
+### 镜内贴图 mip
+
+`EFT.CameraControl.OpticCameraManager.Init()` 会把镜内相机自己的 `UnityEngine.StreamingController.streamingMipmapBias` 设为 `GraphicsSettingsGroup.TextureQualityToMipBias(TextureQuality)`,映射为 `Clamp(2 − 画质, 0, 2)`(`TextureQuality` 取 0–2)。全仓库只有这一处写镜内相机的该值。因此插件在镜内相机创建时覆盖一次即可持久,**不需要每帧**。
+
+### 镜内细节
+
+`EFT.CameraControl.OpticComponentUpdater.CopyComponentFromOptic(OpticSight)` 会按每瞄具的 `ScopeEffectsData` 设置镜内相机上的组件开关(`chromaticAberration`、`bloomOptimized`、`ultimateBloom`、`fisheye`、`cc_FastVignette`、`tonemapping` 等)。**这些不会被每帧覆盖**,所以插件用该方法的 postfix 覆盖一次即可持久。
+
+### 刻意不做体积光与散射
+
+`OpticComponentUpdater.LateUpdate()` **每帧**把主相机的 `volumetricLightRenderer.enabled` / `.Resolution`、`undithering.enabled`、`tod_Scattering`、`mboit_Scattering` 覆盖到镜内相机,要改它们必须每帧强制覆盖;本插件选择不做,只提供第一类的三项(外加不暴露 `tonemapping`,因为关掉它会破坏镜内色彩与曝光)。
+
+新增的 Harmony 目标是 `OpticComponentUpdater.CopyComponentFromOptic`(postfix);**不 patch** `LateUpdate` 或 `Awake`。
+
+### 两条写入路径
+
+| 路径 | 时机 | 覆盖的组件 |
+| --- | --- | --- |
+| `CopyComponentFromOptic` | 换镜/进镜时一次(瞄具实例变化时执行) | 色散、泛光、终极泛光、鱼眼、暗角、色调映射、NV/热成像等 |
+| `LateUpdate` | 每帧(仅镜内相机激活时) | undithering、体积光(含 Resolution)、TOD/MBOIT 散射、postProcessLayer/TAA |
+
 ## 尺寸消费方自动重建
 
 镜内尺寸变化不需要插件干预。以下子系统会在后续帧自检并重建:
@@ -167,6 +192,31 @@ The plugin does no per-frame polling; it only acts on three triggers:
 
 Subscriptions are idempotent per `OpticCameraManager` instance: when a raid change rebuilds the manager, the prefix hands the new instance to the service and unsubscribes the old one.
 
+## Overridable Points for In-Scope Mip and Detail
+
+There are two write points for the in-scope texture mip and the in-scope details; this plugin only touches `CopyComponentFromOptic` and deliberately leaves `LateUpdate` alone.
+
+### Scope texture mip
+
+`EFT.CameraControl.OpticCameraManager.Init()` sets the scope camera's own `UnityEngine.StreamingController.streamingMipmapBias` to `GraphicsSettingsGroup.TextureQualityToMipBias(TextureQuality)`, which maps to `Clamp(2 − texture quality, 0, 2)` (`TextureQuality` is 0–2). This is the only place in the whole codebase that writes that value on the scope camera. The plugin therefore overrides it once when the scope camera is created, and it persists — **no per-frame work is needed**.
+
+### In-scope details
+
+`EFT.CameraControl.OpticComponentUpdater.CopyComponentFromOptic(OpticSight)` sets the component toggles on the scope camera according to each optic's `ScopeEffectsData` (`chromaticAberration`, `bloomOptimized`, `ultimateBloom`, `fisheye`, `cc_FastVignette`, `tonemapping`, etc.). **These are not overwritten every frame**, so the plugin overrides them once in that method's postfix and the result persists.
+
+### Volumetric light and scattering deliberately excluded
+
+`OpticComponentUpdater.LateUpdate()` copies the main camera's `volumetricLightRenderer.enabled` / `.Resolution`, `undithering.enabled`, `tod_Scattering` and `mboit_Scattering` onto the scope camera **every frame**; changing them would require forcing an override every frame. This plugin chooses not to do so and offers only the three of the first kind (and it does not expose `tonemapping`, because disabling it would break the in-scope color and exposure).
+
+The new Harmony target is `OpticComponentUpdater.CopyComponentFromOptic` (postfix); it does **not** patch `LateUpdate` or `Awake`.
+
+### The Two Write Paths
+
+| Path | Timing | Components overridden |
+| --- | --- | --- |
+| `CopyComponentFromOptic` | once per optic change / scope entry (runs when the optic instance changes) | chromatic aberration, bloom, ultimate bloom, fisheye, vignette, tonemapping, NV/thermal, etc. |
+| `LateUpdate` | every frame (only while the scope camera is active) | undithering, volumetric light (including Resolution), TOD/MBOIT scattering, postProcessLayer/TAA |
+
 ## Size Consumers Rebuild Automatically
 
 An in-scope size change needs no plugin intervention. The following subsystems detect it on a later frame and rebuild:

+ 58 - 0
src/PerformanceScope.Core/ScopeMipMath.cs

@@ -0,0 +1,58 @@
+using System;
+
+namespace PerformanceScope.Core
+{
+    /// <summary>
+    /// 镜内贴图 mip 偏差的换算:纯函数,无游戏依赖,便于单元测试。
+    /// Pure helpers for the in-scope texture mip bias; no game dependency, so it is unit-testable.
+    /// </summary>
+    public static class ScopeMipMath
+    {
+        /// <summary>允许的最小偏差。</summary>
+        /// <summary>Smallest allowed bias.</summary>
+        public const float MinBias = -2f;
+
+        /// <summary>允许的最大偏差。</summary>
+        /// <summary>Largest allowed bias.</summary>
+        public const float MaxBias = 8f;
+
+        /// <summary>自定义模式的默认偏差。</summary>
+        /// <summary>Default bias for custom mode.</summary>
+        public const float DefaultCustomBias = 3f;
+
+        /// <summary>把偏差夹取到 [MinBias, MaxBias];非法值回退到 DefaultCustomBias。</summary>
+        /// <summary>Clamp a bias to [MinBias, MaxBias]; invalid values fall back to DefaultCustomBias.</summary>
+        public static float ClampBias(float bias)
+        {
+            if (float.IsNaN(bias) || float.IsInfinity(bias))
+            {
+                return DefaultCustomBias;
+            }
+
+            if (bias < MinBias)
+            {
+                return MinBias;
+            }
+
+            return bias > MaxBias ? MaxBias : bias;
+        }
+
+        /// <summary>
+        /// 解析要写入镜内相机的偏差。仅自定义模式返回 true;
+        /// 游戏默认模式返回 false,表示「不要覆盖游戏的既有值」。
+        /// Resolve the bias to write to the optic camera. Returns true only in custom mode;
+        /// game-default mode returns false, meaning "do not override the game's existing value".
+        /// </summary>
+        public static bool TryResolve(ScopeSettingMode mode, float customBias, out float bias)
+        {
+            if (mode == ScopeSettingMode.Custom)
+            {
+                bias = ClampBias(customBias);
+                return true;
+            }
+
+            bias = 0f;
+            return false;
+        }
+    }
+}

+ 21 - 0
src/PerformanceScope.Core/ScopeSettingMode.cs

@@ -0,0 +1,21 @@
+namespace PerformanceScope.Core
+{
+    /// <summary>
+    /// 配置项的取值方式:沿用游戏默认,或使用插件自定义值。
+    /// How a setting is resolved: keep the game default, or use the plugin's custom value.
+    /// </summary>
+    public enum ScopeSettingMode
+    {
+        /// <summary>
+        /// 保持游戏默认,不做覆盖。
+        /// Keep the game default and do not override it.
+        /// </summary>
+        GameDefault = 0,
+
+        /// <summary>
+        /// 使用插件自定义值。
+        /// Use the plugin's custom value.
+        /// </summary>
+        Custom = 1
+    }
+}

+ 25 - 0
src/PerformanceScope.Plugin/CopyComponentFromOpticPatch.cs

@@ -0,0 +1,25 @@
+using EFT.CameraControl;
+using HarmonyLib;
+
+namespace PerformanceScope
+{
+    /// <summary>
+    /// 游戏按瞄具写完镜内相机组件后,交给服务应用「镜内细节」覆盖。
+    /// 该方法在每次进入镜内时都会被调用(游戏内部再用 cachedOpticId 守卫实际写入)。
+    /// After the game has configured the optic-camera components for the current optic, hand control to the
+    /// service so it can apply the in-scope detail overrides. This runs on every scope entry (the game itself
+    /// guards the actual writes with cachedOpticId).
+    /// </summary>
+    [HarmonyPatch(typeof(OpticComponentUpdater), nameof(OpticComponentUpdater.CopyComponentFromOptic))]
+    internal static class CopyComponentFromOpticPatch
+    {
+        // HarmonyWrapSafe:postfix 抛异常时包裹并跳过,不中断游戏进镜流程。
+        // HarmonyWrapSafe: if the postfix throws, wrap it instead of aborting the game's scope-enter flow.
+        [HarmonyWrapSafe]
+        [HarmonyPostfix]
+        private static void Postfix(OpticComponentUpdater __instance)
+        {
+            OpticQualityService.Instance?.OnOpticComponentsCopied(__instance);
+        }
+    }
+}

+ 355 - 0
src/PerformanceScope.Plugin/OpticQualityService.cs

@@ -0,0 +1,355 @@
+using System;
+using System.Reflection;
+using EFT.CameraControl;
+using HarmonyLib;
+using PerformanceScope.Core;
+using UnityEngine;
+
+namespace PerformanceScope
+{
+    /// <summary>
+    /// 镜内画质的决策与应用,完全事件驱动,不做任何每帧轮询:
+    /// 分辨率与贴图 mip 在 SetResolution 的 prefix(战局初始化)中定位,
+    /// 镜内细节在 CopyComponentFromOptic 的 postfix 中按瞄具重设,
+    /// 配置变更由插件防抖后调用 <see cref="TryApply"/>。
+    /// Decision and application of in-scope quality, fully event-driven with no per-frame polling:
+    /// resolution and texture mip are reached from the SetResolution prefix at raid init, in-scope
+    /// detail is re-applied per optic in the CopyComponentFromOptic postfix, and config changes are
+    /// debounced by the plugin, which then calls <see cref="TryApply"/>.
+    /// </summary>
+    internal sealed class OpticQualityService
+    {
+        /// <summary>镜内相机上要按自定义模式关闭的组件对应的私有字段名。</summary>
+        /// <summary>Private field names of the optic-camera components disabled in custom detail mode.</summary>
+        private static readonly string[] DetailFieldNames =
+        {
+            "bloomOptimized",
+            "ultimateBloom",
+            "chromaticAberration",
+            "fisheye"
+        };
+
+        private readonly FieldInfo[] _detailFields = new FieldInfo[DetailFieldNames.Length];
+
+        private readonly bool[] _detailOriginal = new bool[DetailFieldNames.Length];
+
+        private FieldInfo _cachedOpticIdField;
+
+        private OpticCameraManager _hookedManager;
+
+        private int _failedTarget = int.MinValue;
+
+        private int _detailOpticId = int.MinValue;
+
+        private bool _detailOverridden;
+
+        /// <summary>
+        /// 当前服务实例;插件未加载时为 null,补丁据此透传原值。
+        /// Current service instance; null when the plugin is not loaded, in which case patches pass the original value through.
+        /// </summary>
+        public static OpticQualityService Instance { get; set; }
+
+        /// <summary>
+        /// 计算当前配置对应的目标边长。模组关闭时返回游戏默认值,从而让游戏恢复其原生 1024。
+        /// Compute the target edge length for the current config. Returns the game default when the mod is off,
+        /// so the game falls back to its native 1024.
+        /// </summary>
+        public int ComputeTarget()
+        {
+            if (PluginConfig.EnableMod?.Value != true)
+            {
+                return ResolutionMath.GameDefaultResolution;
+            }
+
+            return ResolutionMath.Resolve(
+                PluginConfig.Mode.Value,
+                Screen.height,
+                PluginConfig.ScreenHeightRatio.Value,
+                PluginConfig.AbsolutePixels.Value);
+        }
+
+        /// <summary>
+        /// 取消镜内管理器的订阅。
+        /// Remove the optic camera manager subscription.
+        /// </summary>
+        public void Unhook()
+        {
+            if (_hookedManager == null)
+            {
+                return;
+            }
+
+            try
+            {
+                _hookedManager.OnOpticDisabled -= OnOpticDisabled;
+            }
+            catch (Exception e)
+            {
+                Log.Error("解除镜内事件订阅失败 | Failed to unsubscribe optic events: " + e);
+            }
+
+            _hookedManager = null;
+        }
+
+        /// <summary>
+        /// 由 SetResolution 的 prefix 在游戏创建镜内管理器时调用:按实例幂等地订阅退出事件,并应用贴图 mip 覆盖。
+        /// Called by the SetResolution prefix when the game creates the optic camera manager: subscribes
+        /// (idempotently per instance) to its scope-exit event and applies the texture mip override.
+        /// </summary>
+        public void OnOpticCameraManagerReady(OpticCameraManager manager)
+        {
+            if (manager == null)
+            {
+                return;
+            }
+
+            if (!ReferenceEquals(_hookedManager, manager))
+            {
+                if (_hookedManager != null)
+                {
+                    _hookedManager.OnOpticDisabled -= OnOpticDisabled;
+                }
+
+                _hookedManager = manager;
+                _hookedManager.OnOpticDisabled += OnOpticDisabled;
+            }
+
+            ApplyMip(manager);
+        }
+
+        /// <summary>
+        /// 由 CopyComponentFromOptic 的 postfix 调用:按瞄具缓存游戏的原始值,再应用细节覆盖。
+        /// Called by the CopyComponentFromOptic postfix: cache the game's original values per optic, then apply detail overrides.
+        /// </summary>
+        public void OnOpticComponentsCopied(OpticComponentUpdater updater)
+        {
+            if (updater == null)
+            {
+                return;
+            }
+
+            int opticId = ReadOpticId(updater);
+            if (opticId != _detailOpticId)
+            {
+                // 游戏内部有 cachedOpticId 守卫:同一瞄具重复进镜时不会重写这些组件。
+                // 若此时重新缓存,会把我们关掉的值当成原始值,因此只在瞄具变化时缓存。
+                // The game guards this with cachedOpticId: re-entering with the same optic skips the writes.
+                // Re-caching here would record our disabled values as the originals, so cache only on change.
+                _detailOpticId = opticId;
+                CaptureDetailOriginals(updater);
+            }
+
+            ApplyDetails(updater);
+        }
+
+        /// <summary>
+        /// 在安全时机同步分辨率、贴图 mip 与镜内细节;不满足条件时留给后续事件处理。
+        /// Sync resolution, texture mip and in-scope detail at a safe moment; otherwise leave it to later events.
+        /// </summary>
+        public void TryApply()
+        {
+            OpticCameraManager manager = GetOpticCameraManager();
+            if (manager == null || manager.Camera == null)
+            {
+                // 未进入战局:战局开始时 Init() 的 prefix 会按目标分辨率建 RT 并应用 mip。
+                // Not in a raid yet: the prefix on Init() will build the RT at the target size and apply the mip override.
+                Log.Verbose("镜内相机尚未就绪,交由战局初始化处理。 | Optic camera not ready; deferring to raid init.");
+                return;
+            }
+
+            ApplyMip(manager);
+            ApplyDetails(manager._updater);
+
+            int target = ComputeTarget();
+            if (target == _failedTarget)
+            {
+                return;
+            }
+
+            OpticApplyAction action = OpticResolutionDecision.Decide(
+                manager.OpticFinalResolution,
+                target,
+                manager.IsAnyOpticCameraRendering,
+                PluginConfig.ApplyWhileScoped?.Value == true);
+
+            if (action != OpticApplyAction.Apply)
+            {
+                // Defer:瞄准中且配置禁止立即应用,等 OnOpticDisabled;None:无需动作。
+                // Defer: scoped and immediate apply is disabled, wait for OnOpticDisabled. None: nothing to do.
+                return;
+            }
+
+            Apply(manager, target);
+        }
+
+        private void OnOpticDisabled()
+        {
+            TryApply();
+        }
+
+        /// <summary>
+        /// 自定义模式下覆盖镜内相机的贴图 mip 偏差。
+        /// In custom mode, override the optic camera's texture mip bias.
+        /// </summary>
+        private void ApplyMip(OpticCameraManager manager)
+        {
+            ScopeSettingMode mode = PluginConfig.MipMode?.Value ?? ScopeSettingMode.GameDefault;
+            float custom = PluginConfig.MipBias?.Value ?? ScopeMipMath.DefaultCustomBias;
+            if (!ScopeMipMath.TryResolve(mode, custom, out float bias))
+            {
+                return;
+            }
+
+            if (manager._streamingController == null)
+            {
+                return;
+            }
+
+            if (Math.Abs(manager._streamingController.streamingMipmapBias - bias) < 0.0001f)
+            {
+                return;
+            }
+
+            manager._streamingController.streamingMipmapBias = bias;
+            Log.Info($"镜内 mip 偏差 → {bias} | Scope mip bias → {bias}");
+        }
+
+        /// <summary>
+        /// 记录游戏刚写入的细节开关原始值。
+        /// Record the original values of the detail toggles as just written by the game.
+        /// </summary>
+        private void CaptureDetailOriginals(OpticComponentUpdater updater)
+        {
+            for (int i = 0; i < _detailFields.Length; i++)
+            {
+                Behaviour behaviour = GetDetailBehaviour(updater, i);
+                _detailOriginal[i] = behaviour != null && behaviour.enabled;
+            }
+        }
+
+        /// <summary>
+        /// 自定义模式下关闭镜内细节;否则把此前关掉的组件还原为游戏原始值。
+        /// In custom mode, disable the in-scope detail components; otherwise restore whatever we disabled.
+        /// </summary>
+        private void ApplyDetails(OpticComponentUpdater updater)
+        {
+            if (updater == null)
+            {
+                return;
+            }
+
+            if (PluginConfig.DetailMode?.Value != ScopeSettingMode.Custom)
+            {
+                RestoreDetails(updater);
+                return;
+            }
+
+            for (int i = 0; i < _detailFields.Length; i++)
+            {
+                Behaviour behaviour = GetDetailBehaviour(updater, i);
+                if (behaviour != null)
+                {
+                    behaviour.enabled = false;
+                }
+            }
+
+            if (!_detailOverridden)
+            {
+                _detailOverridden = true;
+                Log.Info("镜内细节已精简:关闭泛光、终极泛光、色散与鱼眼 | In-scope detail reduced: bloom, ultimate bloom, chromatic aberration and fisheye disabled");
+            }
+        }
+
+        /// <summary>
+        /// 仅还原「我们关掉过」的组件,避免在从未覆盖时误写游戏的默认值。
+        /// Restore only components we actually disabled, so a never-overridden state never writes the game's defaults.
+        /// </summary>
+        private void RestoreDetails(OpticComponentUpdater updater)
+        {
+            if (!_detailOverridden)
+            {
+                return;
+            }
+
+            for (int i = 0; i < _detailFields.Length; i++)
+            {
+                Behaviour behaviour = GetDetailBehaviour(updater, i);
+                if (behaviour != null)
+                {
+                    behaviour.enabled = _detailOriginal[i];
+                }
+            }
+
+            _detailOverridden = false;
+            Log.Info("镜内细节已还原为游戏默认 | In-scope detail restored to game default");
+        }
+
+        private Behaviour GetDetailBehaviour(OpticComponentUpdater updater, int index)
+        {
+            FieldInfo field = _detailFields[index]
+                ?? (_detailFields[index] = AccessTools.Field(typeof(OpticComponentUpdater), DetailFieldNames[index]));
+            return field == null ? null : field.GetValue(updater) as Behaviour;
+        }
+
+        private int ReadOpticId(OpticComponentUpdater updater)
+        {
+            if (_cachedOpticIdField == null)
+            {
+                _cachedOpticIdField = AccessTools.Field(typeof(OpticComponentUpdater), "cachedOpticId");
+            }
+
+            if (_cachedOpticIdField == null)
+            {
+                return 0;
+            }
+
+            object value = _cachedOpticIdField.GetValue(updater);
+            return value is int id ? id : 0;
+        }
+
+        /// <summary>
+        /// 安全地调用游戏接口重建镜内 RenderTexture。
+        /// Rebuild the in-scope RenderTexture through the game API, safely.
+        /// </summary>
+        private void Apply(OpticCameraManager manager, int target)
+        {
+            int old = manager.OpticFinalResolution;
+            if (old == target)
+            {
+                _failedTarget = int.MinValue;
+                return;
+            }
+
+            try
+            {
+                manager.SetResolution(target);
+            }
+            catch (Exception e)
+            {
+                Log.Error($"设置镜内分辨率失败({old} → {target}):{e} | Failed to set scope resolution ({old} → {target}): {e}");
+                return;
+            }
+
+            Log.Info($"镜内分辨率 {old} → {target} | Scope resolution {old} → {target}");
+
+            if (manager.OpticFinalResolution != target)
+            {
+                // 第三方 prefix/postfix 可能改写了结果;锁定目标以避免反复重建 RenderTexture。
+                // A third-party prefix/postfix may have rewritten the result; lock the target to avoid repeated rebuilds.
+                _failedTarget = target;
+                Log.Warn($"镜内分辨率未生效(仍为 {manager.OpticFinalResolution}),可能存在冲突模组;已暂停重试直至目标变化。 | Scope resolution did not stick (still {manager.OpticFinalResolution}); possible mod conflict, retries paused until the target changes.");
+                return;
+            }
+
+            _failedTarget = int.MinValue;
+        }
+
+        private static OpticCameraManager GetOpticCameraManager()
+        {
+            // 读取静态字段而非 Instance 属性:避免触发 CameraManager 的懒创建。
+            // Read the static field rather than the Instance property to avoid forcing lazy creation.
+            CameraManager manager = CameraManager.instance;
+            return manager == null ? null : manager.OpticCameraManager;
+        }
+    }
+}

+ 0 - 178
src/PerformanceScope.Plugin/OpticResolutionService.cs

@@ -1,178 +0,0 @@
-using System;
-using EFT.CameraControl;
-using PerformanceScope.Core;
-using UnityEngine;
-
-namespace PerformanceScope
-{
-    /// <summary>
-    /// 镜内 PiP 分辨率的决策与应用,完全事件驱动,不做任何每帧轮询:
-    /// 配置变更由插件防抖后调用 <see cref="TryApply"/>,瞄具退出来自 OpticCameraManager.OnOpticDisabled,
-    /// 战局开始则由 SetResolution 的 prefix 直接覆盖(无需运行时补偿)。
-    /// Decision and application of the in-scope PiP resolution, fully event-driven with no per-frame polling:
-    /// config changes are debounced by the plugin which then calls <see cref="TryApply"/>, scope exit comes from
-    /// OpticCameraManager.OnOpticDisabled, and raid start is covered directly by the SetResolution prefix.
-    /// </summary>
-    internal sealed class OpticResolutionService
-    {
-        private OpticCameraManager _hookedManager;
-
-        private int _failedTarget = int.MinValue;
-
-        /// <summary>
-        /// 当前服务实例;插件未加载时为 null,补丁据此透传原值。
-        /// Current service instance; null when the plugin is not loaded, in which case the patch passes the original value through.
-        /// </summary>
-        public static OpticResolutionService Instance { get; set; }
-
-        /// <summary>
-        /// 计算当前配置对应的目标边长。模组关闭时返回游戏默认值,
-        /// 从而让游戏恢复其原生 1024。
-        /// Compute the target edge length for the current config. Returns the game default when the mod is off,
-        /// so the game falls back to its native 1024.
-        /// </summary>
-        public int ComputeTarget()
-        {
-            if (PluginConfig.EnableMod?.Value != true)
-            {
-                return ResolutionMath.GameDefaultResolution;
-            }
-
-            return ResolutionMath.Resolve(
-                PluginConfig.Mode.Value,
-                Screen.height,
-                PluginConfig.ScreenHeightRatio.Value,
-                PluginConfig.AbsolutePixels.Value);
-        }
-
-        /// <summary>
-        /// 取消镜内管理器的订阅。
-        /// Remove the optic camera manager subscription.
-        /// </summary>
-        public void Unhook()
-        {
-            if (_hookedManager != null)
-            {
-                try
-                {
-                    _hookedManager.OnOpticDisabled -= OnOpticDisabled;
-                }
-                catch (Exception e)
-                {
-                    Log.Error("解除镜内事件订阅失败:" + e + " | Failed to unsubscribe optic events: " + e);
-                }
-
-                _hookedManager = null;
-            }
-        }
-
-        /// <summary>
-        /// 由 SetResolution 的 prefix 在游戏创建镜内管理器时调用,按实例幂等地订阅其退出事件。
-        /// Called by the SetResolution prefix when the game creates the optic camera manager; subscribes
-        /// (idempotently per instance) to its scope-exit event.
-        /// </summary>
-        public void OnOpticCameraManagerReady(OpticCameraManager manager)
-        {
-            if (manager == null || ReferenceEquals(_hookedManager, manager))
-            {
-                return;
-            }
-
-            if (_hookedManager != null)
-            {
-                _hookedManager.OnOpticDisabled -= OnOpticDisabled;
-                _hookedManager = null;
-            }
-
-            _hookedManager = manager;
-            _hookedManager.OnOpticDisabled += OnOpticDisabled;
-        }
-
-        /// <summary>
-        /// 在安全时机把配置分辨率同步给游戏;不满足条件时留给后续事件处理。
-        /// Sync the configured resolution to the game at a safe moment; otherwise leave it to later events.
-        /// </summary>
-        public void TryApply()
-        {
-            OpticCameraManager manager = GetOpticCameraManager();
-            if (manager == null || manager.Camera == null)
-            {
-                // 未进入战局:战局开始时 Init() 的 prefix 会直接按目标分辨率建 RT。
-                // Not in a raid yet: the prefix on Init() will create the RT at the target size.
-                Log.Verbose("镜内相机尚未就绪,交由战局初始化处理。 | Optic camera not ready; deferring to raid init.");
-                return;
-            }
-
-            int target = ComputeTarget();
-            if (target == _failedTarget)
-            {
-                return;
-            }
-
-            OpticApplyAction action = OpticResolutionDecision.Decide(
-                manager.OpticFinalResolution,
-                target,
-                manager.IsAnyOpticCameraRendering,
-                PluginConfig.ApplyWhileScoped?.Value == true);
-
-            if (action != OpticApplyAction.Apply)
-            {
-                // Defer:瞄准中且配置禁止立即应用,等 OnOpticDisabled;None:无需动作。
-                // Defer: scoped and immediate apply is disabled, wait for OnOpticDisabled. None: nothing to do.
-                return;
-            }
-
-            Apply(manager, target);
-        }
-
-        private void OnOpticDisabled()
-        {
-            TryApply();
-        }
-
-        /// <summary>
-        /// 安全地调用游戏接口重建镜内 RenderTexture。
-        /// Rebuild the in-scope RenderTexture through the game API, safely.
-        /// </summary>
-        private void Apply(OpticCameraManager manager, int target)
-        {
-            int old = manager.OpticFinalResolution;
-            if (old == target)
-            {
-                _failedTarget = int.MinValue;
-                return;
-            }
-
-            try
-            {
-                manager.SetResolution(target);
-            }
-            catch (Exception e)
-            {
-                Log.Error($"设置镜内分辨率失败({old} → {target}):{e} | Failed to set scope resolution ({old} → {target}): {e}");
-                return;
-            }
-
-            Log.Info($"镜内分辨率 {old} → {target} | Scope resolution {old} → {target}");
-
-            if (manager.OpticFinalResolution != target)
-            {
-                // 第三方 prefix/postfix 可能改写了结果;锁定目标以避免反复重建 RenderTexture。
-                // A third-party prefix/postfix may have rewritten the result; lock the target to avoid repeated rebuilds.
-                _failedTarget = target;
-                Log.Warn($"镜内分辨率未生效(仍为 {manager.OpticFinalResolution}),可能存在冲突模组;已暂停重试直至目标变化。 | Scope resolution did not stick (still {manager.OpticFinalResolution}); possible mod conflict, retries paused until the target changes.");
-                return;
-            }
-
-            _failedTarget = int.MinValue;
-        }
-
-        private static OpticCameraManager GetOpticCameraManager()
-        {
-            // 读取静态字段而非 Instance 属性:避免触发 CameraManager 的懒创建。
-            // Read the static field rather than the Instance property to avoid forcing lazy creation.
-            CameraManager manager = CameraManager.instance;
-            return manager == null ? null : manager.OpticCameraManager;
-        }
-    }
-}

+ 4 - 0
src/PerformanceScope.Plugin/PerformanceScope.Plugin.csproj

@@ -38,6 +38,10 @@
       <HintPath>$(SPT_MANAGED)/UnityEngine.CoreModule.dll</HintPath>
       <Private>false</Private>
     </Reference>
+    <Reference Include="UnityEngine.StreamingModule">
+      <HintPath>$(SPT_MANAGED)/UnityEngine.StreamingModule.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
   </ItemGroup>
 
   <!-- 本地 Release 构建后自动部署到游戏插件目录(可用 -p:DeployToGame=false 关闭) -->

+ 4 - 4
src/PerformanceScope.Plugin/Plugin.cs

@@ -41,8 +41,8 @@ namespace PerformanceScope
             PluginConfig.Init(Config);
             ApplyHarmonyPatches();
 
-            OpticResolutionService service = new OpticResolutionService();
-            OpticResolutionService.Instance = service;
+            OpticQualityService service = new OpticQualityService();
+            OpticQualityService.Instance = service;
 
             // 事件驱动:订阅配置变更(防抖后应用),不做任何每帧轮询。
             // Event-driven: subscribe to config changes (applied after a debounce); no per-frame polling.
@@ -67,7 +67,7 @@ namespace PerformanceScope
                 _pendingApply = null;
             }
 
-            OpticResolutionService.Instance?.Unhook();
+            OpticQualityService.Instance?.Unhook();
 
             if (_harmony == null)
             {
@@ -103,7 +103,7 @@ namespace PerformanceScope
         {
             yield return _debounceDelay;
             _pendingApply = null;
-            OpticResolutionService.Instance?.TryApply();
+            OpticQualityService.Instance?.TryApply();
         }
 
         private void ApplyHarmonyPatches()

+ 35 - 0
src/PerformanceScope.Plugin/PluginConfig.cs

@@ -15,6 +15,8 @@ namespace PerformanceScope
         private const string SectionGeneral = "1. 通用 · General";
         private const string SectionResolution = "2. 镜内分辨率 · Scope Resolution";
 
+        private const string SectionDetails = "3. 镜内贴图与细节 · Scope Textures & Details";
+
         /// <summary>
         /// 底层配置文件,供插件订阅 <c>SettingChanged</c> 事件。
         /// The underlying config file, used by the plugin to subscribe to <c>SettingChanged</c>.
@@ -35,6 +37,12 @@ namespace PerformanceScope
 
         public static ConfigEntry<bool> ApplyWhileScoped { get; private set; }
 
+        public static ConfigEntry<ScopeSettingMode> MipMode { get; private set; }
+
+        public static ConfigEntry<float> MipBias { get; private set; }
+
+        public static ConfigEntry<ScopeSettingMode> DetailMode { get; private set; }
+
         /// <summary>
         /// 绑定全部配置项并立即落盘,生成带注释的初始配置文件。
         /// Binds all config entries and saves immediately, generating the initial annotated config file.
@@ -111,6 +119,33 @@ namespace PerformanceScope
                     null,
                     new ConfigurationManagerAttributes { Order = 4 }));
 
+            MipMode = config.Bind(
+                SectionDetails,
+                "镜内贴图 mip 模式 | Scope Mip Mode",
+                ScopeSettingMode.GameDefault,
+                new ConfigDescription(
+                    "游戏默认 / 自定义。自定义时覆盖镜内相机的贴图 mip 偏差。\nGame default / custom. When custom, overrides the optic camera's texture mip bias.",
+                    null,
+                    new ConfigurationManagerAttributes { Order = 1 }));
+
+            MipBias = config.Bind(
+                SectionDetails,
+                "Mip 偏差 | Mip Bias",
+                ScopeMipMath.DefaultCustomBias,
+                new ConfigDescription(
+                    "绝对值覆盖镜内相机的 streamingMipmapBias:越大纹理越糊、越省带宽;游戏默认值取决于贴图品质,范围为 0 到 2。\nAbsolute override for the optic camera's streamingMipmapBias: higher is blurrier and cheaper. The game default depends on texture quality and ranges from 0 to 2.",
+                    new AcceptableValueRange<float>(ScopeMipMath.MinBias, ScopeMipMath.MaxBias),
+                    new ConfigurationManagerAttributes { Order = 2 }));
+
+            DetailMode = config.Bind(
+                SectionDetails,
+                "镜内细节模式 | Scope Detail Mode",
+                ScopeSettingMode.GameDefault,
+                new ConfigDescription(
+                    "游戏默认 / 自定义。自定义时关闭镜内泛光、终极泛光、色散与鱼眼(一次性覆盖,不动体积光与散射)。\nGame default / custom. When custom, disables in-scope bloom, ultimate bloom, chromatic aberration and fisheye (a one-shot override; volumetric light and scattering are left alone).",
+                    null,
+                    new ConfigurationManagerAttributes { Order = 3 }));
+
             config.Save();
         }
     }

+ 1 - 1
src/PerformanceScope.Plugin/SetResolutionPatch.cs

@@ -21,7 +21,7 @@ namespace PerformanceScope
         [HarmonyPrefix]
         private static void Prefix(OpticCameraManager __instance, ref int resolution)
         {
-            OpticResolutionService service = OpticResolutionService.Instance;
+            OpticQualityService service = OpticQualityService.Instance;
             if (service == null)
             {
                 // 插件尚未初始化完成,保持游戏原值透传。

+ 49 - 0
tests/PerformanceScope.Tests/ScopeMipMathTests.cs

@@ -0,0 +1,49 @@
+using PerformanceScope.Core;
+using Xunit;
+
+namespace PerformanceScope.Tests
+{
+    public class ScopeMipMathTests
+    {
+        [Fact]
+        public void 游戏默认模式_不覆盖()
+        {
+            Assert.False(ScopeMipMath.TryResolve(ScopeSettingMode.GameDefault, 5f, out float bias));
+            Assert.Equal(0f, bias);
+        }
+
+        [Theory]
+        [InlineData(0f, 0f)]
+        [InlineData(3f, 3f)]
+        [InlineData(-1.5f, -1.5f)]
+        public void 自定义模式_返回夹取后的值(float input, float expected)
+        {
+            Assert.True(ScopeMipMath.TryResolve(ScopeSettingMode.Custom, input, out float bias));
+            Assert.Equal(expected, bias, 3);
+        }
+
+        [Theory]
+        [InlineData(99f, ScopeMipMath.MaxBias)]
+        [InlineData(-99f, ScopeMipMath.MinBias)]
+        public void 自定义模式_越界被夹取(float input, float expected)
+        {
+            Assert.True(ScopeMipMath.TryResolve(ScopeSettingMode.Custom, input, out float bias));
+            Assert.Equal(expected, bias, 3);
+        }
+
+        [Theory]
+        [InlineData(float.NaN)]
+        [InlineData(float.PositiveInfinity)]
+        [InlineData(float.NegativeInfinity)]
+        public void 非法值_回退默认偏差(float input)
+        {
+            Assert.Equal(ScopeMipMath.DefaultCustomBias, ScopeMipMath.ClampBias(input), 3);
+        }
+
+        [Fact]
+        public void 默认自定义偏差在合法区间内()
+        {
+            Assert.InRange(ScopeMipMath.DefaultCustomBias, ScopeMipMath.MinBias, ScopeMipMath.MaxBias);
+        }
+    }
+}