Unity-NorthStar / data /Packages /com.unity.render-pipelines.universal /Runtime /Data /PostProcessData.cs
| using System; | |
| using System.Diagnostics.CodeAnalysis; | |
| using System.IO; | |
| using UnityEditor; | |
| using UnityEditor.ProjectWindowCallback; | |
| using System.Reflection; | |
| namespace UnityEngine.Rendering.Universal | |
| { | |
| /// <summary> | |
| /// Class containing shader and texture resources needed for Post Processing in URP. | |
| /// </summary> | |
| /// <seealso cref="Shader"/> | |
| /// <seealso cref="Texture"/> | |
| [] | |
| public class PostProcessData : ScriptableObject | |
| { | |
| [] | |
| 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; | |
| } | |
| } | |
| [] | |
| static void CreatePostProcessData() | |
| { | |
| ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreatePostProcessDataAsset>(), "CustomPostProcessData.asset", null, 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); | |
| } | |
| } | |
| /// <summary> | |
| /// Class containing shader resources used for Post Processing in URP. | |
| /// </summary> | |
| [] | |
| [] | |
| [] | |
| [] | |
| public sealed class ShaderResources : IRenderPipelineResources | |
| { | |
| /// <summary> | |
| /// The StopNan Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader stopNanPS; | |
| /// <summary> | |
| /// The <c>SubpixelMorphologicalAntiAliasing</c> SMAA Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader subpixelMorphologicalAntialiasingPS; | |
| /// <summary> | |
| /// The Gaussian Depth Of Field Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader gaussianDepthOfFieldPS; | |
| /// <summary> | |
| /// The Bokeh Depth Of Field Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader bokehDepthOfFieldPS; | |
| /// <summary> | |
| /// The Motion Blur Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader cameraMotionBlurPS; | |
| /// <summary> | |
| /// The Panini Projection Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader paniniProjectionPS; | |
| /// <summary> | |
| /// The LUT Builder LDR Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader lutBuilderLdrPS; | |
| /// <summary> | |
| /// The LUT Builder HDR Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader lutBuilderHdrPS; | |
| /// <summary> | |
| /// The Bloom Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader bloomPS; | |
| /// <summary> | |
| /// The Temporal-antialiasing Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader temporalAntialiasingPS; | |
| /// <summary> | |
| /// The Lens Flare Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader LensFlareDataDrivenPS; | |
| /// <summary> | |
| /// The Lens Flare Screen Space shader. | |
| /// </summary> | |
| [] | |
| public Shader LensFlareScreenSpacePS; | |
| /// <summary> | |
| /// The Scaling Setup Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader scalingSetupPS; | |
| /// <summary> | |
| /// The Edge Adaptive Spatial Upsampling shader. | |
| /// </summary> | |
| [] | |
| public Shader easuPS; | |
| /// <summary> | |
| /// The Uber Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader uberPostPS; | |
| /// <summary> | |
| /// The Final Post Processing shader. | |
| /// </summary> | |
| [] | |
| public Shader finalPostPassPS; | |
| /// <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); | |
| } | |
| // This name must be unique within the entire PostProcessData set, as PostProcessDataAnalytics retrieves it. | |
| [][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> | |
| [] | |
| [] | |
| [] | |
| [] | |
| public sealed class TextureResources : IRenderPipelineResources | |
| { | |
| /// <summary> | |
| /// Pre-baked Blue noise textures. | |
| /// </summary> | |
| [] | |
| public Texture2D[] blueNoise16LTex; | |
| /// <summary> | |
| /// Film Grain textures. | |
| /// </summary> | |
| [] | |
| { | |
| "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> | |
| [] public Texture2D smaaAreaTex; | |
| /// <summary> | |
| /// <c>SubpixelMorphologicalAntiAliasing</c> SMAA search texture. | |
| /// </summary> | |
| [] | |
| public Texture2D smaaSearchTex; | |
| /// <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); | |
| } | |
| // This name must be unique within the entire PostProcessData set, as PostProcessDataAnalytics retrieves it. | |
| [][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; | |
| } | |
| } |