-
Notifications
You must be signed in to change notification settings - Fork 867
Expand file tree
/
Copy pathPostProcessData.cs
More file actions
320 lines (279 loc) · 12.9 KB
/
PostProcessData.cs
File metadata and controls
320 lines (279 loc) · 12.9 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
using System.Reflection;
#endif
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Class containing shader and texture resources needed for Post Processing in URP.
/// </summary>
/// <seealso cref="Shader"/>
/// <seealso cref="Texture"/>
[Serializable]
public class PostProcessData : ScriptableObject
{
#if UNITY_EDITOR
[SuppressMessage("Microsoft.Performance", "CA1812")]
internal class CreatePostProcessDataAsset : EndNameEditAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
{
var instance = CreateInstance<PostProcessData>();
AssetDatabase.CreateAsset(instance, pathName);
Selection.activeObject = instance;
}
}
[MenuItem("Assets/Create/Rendering/URP Post-process Data", priority = CoreUtils.Sections.section5 + CoreUtils.Priorities.assetsCreateRenderingMenuPriority)]
static void CreatePostProcessData()
{
var icon = EditorGUIUtility.IconContent("ScriptableObject Icon").image as Texture2D;
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreatePostProcessDataAsset>(), "CustomPostProcessData.asset", icon, null);
}
internal static PostProcessData GetDefaultPostProcessData()
{
var path = Path.Combine(UniversalRenderPipelineAsset.packagePath, "Runtime/Data/PostProcessData.asset");
return AssetDatabase.LoadAssetAtPath<PostProcessData>(path);
}
internal void Reset()
{
LoadResources(true);
}
internal void Populate()
{
LoadResources(false);
}
void LoadResources(bool reset)
{
if (GraphicsSettings.TryGetRenderPipelineSettings<ShaderResources>(out var defaultShaderResources))
{
if (shaders == null || reset)
shaders = new ShaderResources();
shaders.Populate(defaultShaderResources);
}
if (GraphicsSettings.TryGetRenderPipelineSettings<TextureResources>(out var defaultTextureResources))
{
if (textures == null || reset)
textures = new TextureResources();
textures.Populate(defaultTextureResources);
}
}
#endif
/// <summary>
/// Class containing shader resources used for Post Processing in URP.
/// </summary>
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "R: Default PostProcess Shaders", Order = 1000)]
[Categorization.ElementInfo(Order = 0), HideInInspector]
public sealed class ShaderResources : IRenderPipelineResources
{
/// <summary>
/// The StopNan Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/StopNaN.shader")]
public Shader stopNanPS;
/// <summary>
/// The <c>SubpixelMorphologicalAntiAliasing</c> SMAA Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/SubpixelMorphologicalAntialiasing.shader")]
public Shader subpixelMorphologicalAntialiasingPS;
/// <summary>
/// The Gaussian Depth Of Field Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/GaussianDepthOfField.shader")]
public Shader gaussianDepthOfFieldPS;
/// <summary>
/// The Bokeh Depth Of Field Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/BokehDepthOfField.shader")]
public Shader bokehDepthOfFieldPS;
/// <summary>
/// The Motion Blur Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/CameraMotionBlur.shader")]
public Shader cameraMotionBlurPS;
/// <summary>
/// The Panini Projection Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/PaniniProjection.shader")]
public Shader paniniProjectionPS;
/// <summary>
/// The LUT Builder LDR Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/LutBuilderLdr.shader")]
public Shader lutBuilderLdrPS;
/// <summary>
/// The LUT Builder HDR Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/LutBuilderHdr.shader")]
public Shader lutBuilderHdrPS;
/// <summary>
/// The Bloom Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/Bloom.shader")]
public Shader bloomPS;
/// <summary>
/// The Temporal-antialiasing Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/TemporalAA.shader")]
public Shader temporalAntialiasingPS;
/// <summary>
/// The Lens Flare Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/LensFlareDataDriven.shader")]
public Shader LensFlareDataDrivenPS;
/// <summary>
/// The Lens Flare Screen Space shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/LensFlareScreenSpace.shader")]
public Shader LensFlareScreenSpacePS;
/// <summary>
/// The Scaling Setup Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/ScalingSetup.shader")]
public Shader scalingSetupPS;
/// <summary>
/// The Edge Adaptive Spatial Upsampling shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/EdgeAdaptiveSpatialUpsampling.shader")]
public Shader easuPS;
/// <summary>
/// The Uber Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/UberPost.shader")]
public Shader uberPostPS;
/// <summary>
/// The Final Post Processing shader.
/// </summary>
[ResourcePath("Shaders/PostProcessing/FinalPost.shader")]
public Shader finalPostPassPS;
#if UNITY_EDITOR
/// <summary>
/// Copies all fields and resources from a source <see cref="ShaderResources"/> object into this object.
/// </summary>
/// <remarks>
/// This method is available only in the Unity Editor. It uses the <see cref="CoreUtils.Populate"/> method to copy non-null field values. Use this to synchronize resource objects during runtime in the Editor.
/// </remarks>
/// <param name="source">
/// The source <see cref="ShaderResources"/> object to copy data from. This object must not be null.
/// </param>
internal void Populate(ShaderResources source)
{
CoreUtils.PopulateNullFieldsFrom(source, this);
}
#endif
// This name must be unique within the entire PostProcessData set, as PostProcessDataAnalytics retrieves it.
[SerializeField][HideInInspector] int m_ShaderResourcesVersion = 0;
/// <summary>
/// Gets the current version of the resource container.
/// </summary>
/// <remarks>
/// This version is used exclusively for upgrading a project to ensure compatibility with resources configured in earlier Unity versions. Updating this version is an internal process during asset upgrades.
/// </remarks>
/// <value>
/// The version number of the resource container. This value is incremented when the resource container changes.
/// </value>
public int version => m_ShaderResourcesVersion;
/// <summary>
/// Indicates whether the resource is available in a player build.
/// </summary>
/// <remarks>
/// Always returns `false` because this resource is not designed to be included in player builds.
/// </remarks>
/// <value>
/// `false`, indicating that the resource is editor-only and unavailable in a player build.
/// </value>
public bool isAvailableInPlayerBuild => false;
}
/// <summary>
/// Class containing texture resources used for Post Processing in URP.
/// </summary>
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "R: Default PostProcess Textures", Order = 1000)]
[Categorization.ElementInfo(Order = 0), HideInInspector]
public sealed class TextureResources : IRenderPipelineResources
{
/// <summary>
/// Pre-baked Blue noise textures.
/// </summary>
[ResourceFormattedPaths("Textures/BlueNoise16/L/LDR_LLL1_{0}.png", 0, 32)]
public Texture2D[] blueNoise16LTex;
/// <summary>
/// Film Grain textures.
/// </summary>
[ResourcePaths(new[]
{
"Textures/FilmGrain/Thin01.png",
"Textures/FilmGrain/Thin02.png",
"Textures/FilmGrain/Medium01.png",
"Textures/FilmGrain/Medium02.png",
"Textures/FilmGrain/Medium03.png",
"Textures/FilmGrain/Medium04.png",
"Textures/FilmGrain/Medium05.png",
"Textures/FilmGrain/Medium06.png",
"Textures/FilmGrain/Large01.png",
"Textures/FilmGrain/Large02.png"
})]
public Texture2D[] filmGrainTex;
/// <summary>
/// <c>SubpixelMorphologicalAntiAliasing</c> SMAA area texture.
/// </summary>
[ResourcePath("Textures/SMAA/AreaTex.tga")] public Texture2D smaaAreaTex;
/// <summary>
/// <c>SubpixelMorphologicalAntiAliasing</c> SMAA search texture.
/// </summary>
[ResourcePath("Textures/SMAA/SearchTex.tga")]
public Texture2D smaaSearchTex;
#if UNITY_EDITOR
/// <summary>
/// Copies all fields and resources from a source <see cref="TextureResources"/> object into this object.
/// </summary>
/// <remarks>
/// This method is available only in the Unity Editor. It uses the <see cref="CoreUtils.Populate"/> method to copy non-null field values. Use this to synchronize resource objects during runtime in the Editor.
/// </remarks>
/// <param name="source">
/// The source <see cref="TextureResources"/> object to copy data from. This object must not be null.
/// </param>
internal void Populate(TextureResources source)
{
CoreUtils.PopulateNullFieldsFrom(source, this);
}
#endif
// This name must be unique within the entire PostProcessData set, as PostProcessDataAnalytics retrieves it.
[SerializeField][HideInInspector] int m_TexturesResourcesVersion = 0;
/// <summary>
/// Gets the current version of the resource container.
/// </summary>
/// <remarks>
/// This version is used exclusively for upgrading a project to ensure compatibility with resources configured in earlier Unity versions. Updating this version is an internal process during asset upgrades.
/// </remarks>
/// <value>
/// The version number of the resource container. This value is incremented when the resource container changes.
/// </value>
public int version => m_TexturesResourcesVersion;
/// <summary>
/// Indicates whether the resource is available in a player build.
/// </summary>
/// <remarks>
/// Always returns `false` because this resource is not designed to be included in player builds.
/// </remarks>
/// <value>
/// `false`, indicating that the resource is editor-only and unavailable in a player build.
/// </value>
public bool isAvailableInPlayerBuild => false;
}
/// <summary>
/// Shader resources used for Post Processing in URP.
/// </summary>
public ShaderResources shaders;
/// <summary>
/// Texture resources used for Post Processing in URP.
/// </summary>
public TextureResources textures;
}
}