GPU优化
This commit is contained in:
@@ -8,9 +8,8 @@ namespace SLSUtilities.Rendering.PostProcessing
|
||||
[System.Serializable, VolumeComponentMenu("SLS/Postprocessing/Anime Bloom")]
|
||||
public class AnimeBloom : ScriptablePostProcessorVolume
|
||||
{
|
||||
// 放在 ToneMapping 之前效果最强,但放在 AfterPostProcess 最安全(不易过曝)
|
||||
// 这里建议 AfterPostProcess,配合 HDR 使用
|
||||
public override CustomPostProcessInjectionPoint InjectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess;
|
||||
// 【核心修改】:放在 ToneMapping 之前执行(BeforePostProcess),配合 ACES 才能彻底解决“高光泛白”问题
|
||||
public override CustomPostProcessInjectionPoint InjectionPoint => CustomPostProcessInjectionPoint.BeforePostProcess;
|
||||
public override int OrderInInjectionPoint => 5; // 放在 Vignette 之前
|
||||
|
||||
[Header("Glow Settings")]
|
||||
@@ -27,11 +26,11 @@ namespace SLSUtilities.Rendering.PostProcessing
|
||||
public MinFloatParameter clamp = new(65472f, 1f); // 默认很大,基本不限制
|
||||
|
||||
[Header("Anime Style")]
|
||||
[Tooltip("扩散半径。值越大,光晕越松散、范围越大(二次元感核心)。")]
|
||||
public ClampedFloatParameter scatter = new(0.7f, 0f, 5f); // 推荐 0.5 - 1.0
|
||||
[Tooltip("扩散半径。稍微增加扩展范围来弥补低迭代带来的发光不足。")]
|
||||
public ClampedFloatParameter scatter = new(0.85f, 0f, 5f); // 推荐增量以适应低迭代
|
||||
|
||||
[Tooltip("迭代次数。次数越多,光晕越平滑、范围越大,但性能开销越高。")]
|
||||
public ClampedIntParameter diffusion = new(6, 1, 8); // 6次通常足够高品质
|
||||
[Tooltip("迭代次数。针对移动端带宽优化,建议控制在 2~3 次。")]
|
||||
public ClampedIntParameter diffusion = new(3, 1, 4); // 移动端性能优化,最高4次
|
||||
|
||||
[Tooltip("泛光染色。可以做粉色霓虹、蓝色科技光等效果。")]
|
||||
public ColorParameter tint = new(Color.white, true, true, true);
|
||||
@@ -39,7 +38,7 @@ namespace SLSUtilities.Rendering.PostProcessing
|
||||
// 内部使用的 RT 数组
|
||||
private RTHandle[] _bloomPyramidUp;
|
||||
private RTHandle[] _bloomPyramidDown;
|
||||
private const int k_MaxPyramidSize = 16;
|
||||
private const int k_MaxPyramidSize = 6; // 减少不必要的最大数组长度
|
||||
|
||||
public override string GetShaderName() => "SLS/Postprocessing/AnimeBloom";
|
||||
|
||||
@@ -104,13 +103,9 @@ namespace SLSUtilities.Rendering.PostProcessing
|
||||
// 设置上一级 Up 为输入
|
||||
// Upsample Pass 会混合:Up[i+1] (Blur) + Down[i] (High Res Detail)
|
||||
// 这里我们稍微简化逻辑:直接把 Up[i+1] 升采样并叠加到 Up[i] 上
|
||||
// 为了保留细节,Dual Kawase 通常是将 Up[i+1] 叠加回 Down[i] 存入 Up[i]
|
||||
|
||||
// 第一步:先把 Down[i] 拷进 Up[i] 作为底图
|
||||
Blitter.BlitCameraTexture(cmd, _bloomPyramidDown[i], _bloomPyramidUp[i]);
|
||||
|
||||
// 第二步:把 Up[i+1] 升采样并 Additive 混合进 Up[i]
|
||||
// Shader Pass 2 开启了 Blend One One
|
||||
// 第二步:把 Up[i+1] (LowRes) 和 Down[i] (HighRes) 一起传给 Shader
|
||||
// 在 Shader 内部执行 Lerp 能量守恒融合,彻底替代会导致死白的 Additive 叠加模式
|
||||
material.SetTexture("_BloomMipDown", _bloomPyramidDown[i]);
|
||||
Blitter.BlitCameraTexture(cmd, _bloomPyramidUp[i + 1], _bloomPyramidUp[i], material, 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user