-
Notifications
You must be signed in to change notification settings - Fork 678
/
Copy pathRapidOldTVVignette.cs
59 lines (45 loc) · 2.05 KB
/
RapidOldTVVignette.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
namespace XPostProcessing
{
[Serializable]
[PostProcess(typeof(RapidOldTVVignetteRenderer), PostProcessEvent.AfterStack, "X-PostProcessing/Vignette/RapidOldTVVignette")]
public class RapidOldTVVignette : PostProcessEffectSettings
{
public VignetteTypeParameter vignetteType = new VignetteTypeParameter { value = VignetteType.ClassicMode };
[Range(0.0f, 5.0f)]
public FloatParameter vignetteIndensity = new FloatParameter { value = 1f };
public Vector2Parameter vignetteCenter = new Vector2Parameter { value = new Vector2(0.5f, 0.5f) };
[ColorUsageAttribute(true, true, 0f, 20f, 0.125f, 3f)]
public ColorParameter vignetteColor = new ColorParameter { value = new Color(0.1f, 0.8f, 1.0f) };
}
public sealed class RapidOldTVVignetteRenderer : PostProcessEffectRenderer<RapidOldTVVignette>
{
private Shader shader;
private const string PROFILER_TAG = "X-RapidOldTVVignette";
public override void Init()
{
shader = Shader.Find("Hidden/X-PostProcessing/RapidOldTVVignette");
}
public override void Release()
{
base.Release();
}
public override void Render(PostProcessRenderContext context)
{
CommandBuffer cmd = context.command;
PropertySheet sheet = context.propertySheets.Get(shader);
cmd.BeginSample(PROFILER_TAG);
sheet.properties.SetFloat("_VignetteIndensity", settings.vignetteIndensity);
sheet.properties.SetVector("_VignetteCenter", settings.vignetteCenter);
if (settings.vignetteType.value == VignetteType.ColorMode)
{
sheet.properties.SetVector("_VignetteColor", settings.vignetteColor);
}
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)settings.vignetteType.value);
cmd.EndSample(PROFILER_TAG);
}
}
}