experiments with fresnel and shadergraph
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.6 / PostProcessing / Runtime / Effects / SubpixelMorphologicalAntialiasing.cs
blob95923b3692b46f9ffb3785b1dc6b56a58a865022
1 using System;
3 namespace UnityEngine.Rendering.PostProcessing
5 /// <summary>
6 /// This class holds settings for the Subpixel Morphological Anti-aliasing (SMAA) effect.
7 /// </summary>
8 #if UNITY_2017_1_OR_NEWER
9 [UnityEngine.Scripting.Preserve]
10 #endif
11 [Serializable]
12 public sealed class SubpixelMorphologicalAntialiasing
14 enum Pass
16 EdgeDetection = 0,
17 BlendWeights = 3,
18 NeighborhoodBlending = 6
21 /// <summary>
22 /// Quality presets.
23 /// </summary>
24 public enum Quality
26 /// <summary>
27 /// Low quality.
28 /// </summary>
29 Low = 0,
31 /// <summary>
32 /// Medium quality.
33 /// </summary>
34 Medium = 1,
36 /// <summary>
37 /// High quality.
38 /// </summary>
39 High = 2
42 /// <summary>
43 /// The quality preset to use for the anti-aliasing filter.
44 /// </summary>
45 [Tooltip("Lower quality is faster at the expense of visual quality (Low = ~60%, Medium = ~80%).")]
46 public Quality quality = Quality.High;
48 /// <summary>
49 /// Checks if the effect is supported on the target platform.
50 /// </summary>
51 /// <returns><c>true</c> if the anti-aliasing filter is supported, <c>false</c> otherwise</returns>
52 public bool IsSupported()
54 return !RuntimeUtilities.isSinglePassStereoEnabled;
57 internal void Render(PostProcessRenderContext context)
59 var sheet = context.propertySheets.Get(context.resources.shaders.subpixelMorphologicalAntialiasing);
60 sheet.properties.SetTexture("_AreaTex", context.resources.smaaLuts.area);
61 sheet.properties.SetTexture("_SearchTex", context.resources.smaaLuts.search);
63 var cmd = context.command;
64 cmd.BeginSample("SubpixelMorphologicalAntialiasing");
66 cmd.GetTemporaryRT(ShaderIDs.SMAA_Flip, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear);
67 cmd.GetTemporaryRT(ShaderIDs.SMAA_Flop, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear);
69 cmd.BlitFullscreenTriangle(context.source, ShaderIDs.SMAA_Flip, sheet, (int)Pass.EdgeDetection + (int)quality, true);
70 cmd.BlitFullscreenTriangle(ShaderIDs.SMAA_Flip, ShaderIDs.SMAA_Flop, sheet, (int)Pass.BlendWeights + (int)quality);
71 cmd.SetGlobalTexture("_BlendTex", ShaderIDs.SMAA_Flop);
72 cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)Pass.NeighborhoodBlending);
74 cmd.ReleaseTemporaryRT(ShaderIDs.SMAA_Flip);
75 cmd.ReleaseTemporaryRT(ShaderIDs.SMAA_Flop);
77 cmd.EndSample("SubpixelMorphologicalAntialiasing");