-
Notifications
You must be signed in to change notification settings - Fork 866
Expand file tree
/
Copy pathMonitor.cs
More file actions
96 lines (83 loc) · 2.66 KB
/
Monitor.cs
File metadata and controls
96 lines (83 loc) · 2.66 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
namespace UnityEngine.Rendering.PostProcessing
{
/// <summary>
/// Debug monitor types.
/// </summary>
public enum MonitorType
{
/// <summary>
/// Light meter.
/// </summary>
LightMeter,
/// <summary>
/// Gamma histogram.
/// </summary>
Histogram,
/// <summary>
/// Waveform.
/// </summary>
Waveform,
/// <summary>
/// YUV vectorscope.
/// </summary>
Vectorscope
}
/// <summary>
/// The base class for all debug monitors.
/// </summary>
[Serializable]
public abstract class Monitor
{
/// <summary>
/// The target texture to render this monitor to.
/// </summary>
public RenderTexture output { get; protected set; }
internal bool requested = false;
/// <summary>
/// Checks if a monitor is supported and should be rendered.
/// </summary>
/// <param name="context">The current post-processing context.</param>
/// <returns><c>true</c> if supported and enabled, <c>false</c> otherwise.</returns>
public bool IsRequestedAndSupported(PostProcessRenderContext context)
{
return requested
&& SystemInfo.supportsComputeShaders
&& !RuntimeUtilities.isOpenGLES
&& !RuntimeUtilities.isWebNonWebGPU
&& ShaderResourcesAvailable(context);
}
internal abstract bool ShaderResourcesAvailable(PostProcessRenderContext context);
internal virtual bool NeedsHalfRes()
{
return false;
}
/// <summary>
/// Validates the output texture.
/// </summary>
/// <param name="width">The output width.</param>
/// <param name="height">The output height.</param>
protected void CheckOutput(int width, int height)
{
if (output == null || !output.IsCreated() || output.width != width || output.height != height)
{
RuntimeUtilities.Destroy(output);
output = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32)
{
anisoLevel = 0,
filterMode = FilterMode.Bilinear,
wrapMode = TextureWrapMode.Clamp,
useMipMap = false
};
}
}
internal virtual void OnEnable()
{
}
internal virtual void OnDisable()
{
RuntimeUtilities.Destroy(output);
}
internal abstract void Render(PostProcessRenderContext context);
}
}