64 lines
2.9 KiB
C#
64 lines
2.9 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
/// <summary>
|
|
/// 边缘渐晕效果,支持上下左右独立控制
|
|
/// </summary>
|
|
[Serializable, VolumeComponentMenu("Post-processing/Edge Vignette")]
|
|
public sealed class EdgeVignette : VolumeComponent, IPostProcessComponent
|
|
{
|
|
/// <summary>
|
|
/// Vignette颜色
|
|
/// </summary>
|
|
[Tooltip("Vignette color.")]
|
|
public ColorParameter color = new ColorParameter(Color.black, false, false, true);
|
|
|
|
// ===== 上方 (Top) =====
|
|
[Tooltip("Vignette intensity at the top of the screen.")]
|
|
public ClampedFloatParameter intensityTop = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Vignette offset from top (0 = screen top, 1 = screen bottom).")]
|
|
public ClampedFloatParameter offsetTop = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Smoothness of the top vignette border.")]
|
|
public ClampedFloatParameter smoothnessTop = new ClampedFloatParameter(0.2f, 0.01f, 5f);
|
|
|
|
// ===== 下方 (Bottom) =====
|
|
[Tooltip("Vignette intensity at the bottom of the screen.")]
|
|
public ClampedFloatParameter intensityBottom = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Vignette offset from bottom (0 = screen bottom, 1 = screen top).")]
|
|
public ClampedFloatParameter offsetBottom = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Smoothness of the bottom vignette border.")]
|
|
public ClampedFloatParameter smoothnessBottom = new ClampedFloatParameter(0.2f, 0.01f, 5f);
|
|
|
|
// ===== 左侧 (Left) =====
|
|
[Tooltip("Vignette intensity at the left of the screen.")]
|
|
public ClampedFloatParameter intensityLeft = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Vignette offset from left (0 = screen left, 1 = screen right).")]
|
|
public ClampedFloatParameter offsetLeft = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Smoothness of the left vignette border.")]
|
|
public ClampedFloatParameter smoothnessLeft = new ClampedFloatParameter(0.2f, 0.01f, 5f);
|
|
|
|
// ===== 右侧 (Right) =====
|
|
[Tooltip("Vignette intensity at the right of the screen.")]
|
|
public ClampedFloatParameter intensityRight = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Vignette offset from right (0 = screen right, 1 = screen left).")]
|
|
public ClampedFloatParameter offsetRight = new ClampedFloatParameter(0f, 0f, 1f);
|
|
|
|
[Tooltip("Smoothness of the right vignette border.")]
|
|
public ClampedFloatParameter smoothnessRight = new ClampedFloatParameter(0.2f, 0.01f, 5f);
|
|
|
|
public bool IsActive() => intensityTop.value > 0f || intensityBottom.value > 0f ||
|
|
intensityLeft.value > 0f || intensityRight.value > 0f;
|
|
|
|
public bool IsTileCompatible() => true;
|
|
}
|
|
|