59 lines
2.7 KiB
C#
59 lines
2.7 KiB
C#
using Echovoid.Runtime.Behavior.Rendering;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
namespace SLSUtilities.Rendering.PostProcessing
|
|
{
|
|
[System.Serializable, VolumeComponentMenu("SLS/Postprocessing/Anime ACES")]
|
|
public class AnimeACES : ScriptablePostProcessorVolume
|
|
{
|
|
public override CustomPostProcessInjectionPoint InjectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess;
|
|
public override int OrderInInjectionPoint => 1000;
|
|
|
|
[Header("Tone Settings")]
|
|
[Tooltip("是否开启")]
|
|
public BoolParameter enabled = new(false);
|
|
|
|
[Tooltip("曝光度。如果画面太亮,请降低此值 (0.8 - 1.2)。")]
|
|
public FloatParameter exposure = new(1.0f); // 默认降回 1.0
|
|
|
|
[Tooltip("对比度。基于中灰(0.18)调整。值越高,黑的越黑,亮的越亮。")]
|
|
public ClampedFloatParameter contrast = new(1.1f, 0f, 2f);
|
|
|
|
[Tooltip("饱和度。建议 1.1 - 1.3 以获得鲜艳色彩。")]
|
|
public ClampedFloatParameter saturation = new(1.15f, 0f, 2f);
|
|
|
|
[Tooltip("色彩保留 (Hue Preservation)。\n0 = 标准ACES (皮肤泛白/胶片感)\n1 = 完美保色 (皮肤红润/卡通感)\n二次元建议 0.3 - 0.7。")]
|
|
public ClampedFloatParameter huePreservation = new(0.5f, 0f, 1f);
|
|
|
|
[Tooltip("色彩滤镜")]
|
|
public ColorParameter colorFilter = new(Color.white, true, true, true);
|
|
|
|
[Header("ACES Curve")]
|
|
public ClampedFloatParameter coeffA = new(2.51f, 0f, 5f);
|
|
public ClampedFloatParameter coeffB = new(0.03f, 0f, 1f);
|
|
public ClampedFloatParameter coeffC = new(2.43f, 0f, 5f);
|
|
public ClampedFloatParameter coeffD = new(0.59f, 0f, 1f);
|
|
public ClampedFloatParameter coeffE = new(0.14f, 0f, 1f);
|
|
|
|
public override string GetShaderName() => "SLS/Postprocessing/AnimeACES";
|
|
|
|
public override void Render(CommandBuffer cmd, ref RenderingData renderingData, RTHandle source, RTHandle destination)
|
|
{
|
|
if (material == null) return;
|
|
|
|
// 传入 w 分量作为 Hue Preservation
|
|
material.SetVector(InternalShaderHelpers.ID._TonemapParams, new Vector4(exposure.value, contrast.value, saturation.value, huePreservation.value));
|
|
|
|
material.SetVector(InternalShaderHelpers.ID._ACESCoeffs, new Vector4(coeffA.value, coeffB.value, coeffC.value, coeffD.value));
|
|
material.SetFloat(InternalShaderHelpers.ID._ACES_E, coeffE.value);
|
|
|
|
material.SetColor(InternalShaderHelpers.ID._ColorFilter, colorFilter.value);
|
|
|
|
Blitter.BlitCameraTexture(cmd, source, destination, material, 0);
|
|
}
|
|
|
|
public override bool IsActive() => enabled.value;
|
|
}
|
|
} |