tree sway and shadow improvements
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.2 / PostProcessing / Runtime / Effects / SubpixelMorphologicalAntialiasing.cs
blob26e84596a76200e7a29096dd7ead78a7879dafc1
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 [Serializable]
9 public sealed class SubpixelMorphologicalAntialiasing
11 enum Pass
13 EdgeDetection = 0,
14 BlendWeights = 3,
15 NeighborhoodBlending = 6
18 /// <summary>
19 /// Quality presets.
20 /// </summary>
21 public enum Quality
23 /// <summary>
24 /// Low quality.
25 /// </summary>
26 Low = 0,
28 /// <summary>
29 /// Medium quality.
30 /// </summary>
31 Medium = 1,
33 /// <summary>
34 /// High quality.
35 /// </summary>
36 High = 2
39 /// <summary>
40 /// The quality preset to use for the anti-aliasing filter.
41 /// </summary>
42 [Tooltip("Lower quality is faster at the expense of visual quality (Low = ~60%, Medium = ~80%).")]
43 public Quality quality = Quality.High;
45 /// <summary>
46 /// Checks if the effect is supported on the target platform.
47 /// </summary>
48 /// <returns><c>true</c> if the anti-aliasing filter is supported, <c>false</c> otherwise</returns>
49 public bool IsSupported()
51 return !RuntimeUtilities.isSinglePassStereoEnabled;
54 internal void Render(PostProcessRenderContext context)
56 var sheet = context.propertySheets.Get(context.resources.shaders.subpixelMorphologicalAntialiasing);
57 sheet.properties.SetTexture("_AreaTex", context.resources.smaaLuts.area);
58 sheet.properties.SetTexture("_SearchTex", context.resources.smaaLuts.search);
60 var cmd = context.command;
61 cmd.BeginSample("SubpixelMorphologicalAntialiasing");
63 cmd.GetTemporaryRT(ShaderIDs.SMAA_Flip, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear);
64 cmd.GetTemporaryRT(ShaderIDs.SMAA_Flop, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear);
66 cmd.BlitFullscreenTriangle(context.source, ShaderIDs.SMAA_Flip, sheet, (int)Pass.EdgeDetection + (int)quality, true);
67 cmd.BlitFullscreenTriangle(ShaderIDs.SMAA_Flip, ShaderIDs.SMAA_Flop, sheet, (int)Pass.BlendWeights + (int)quality);
68 cmd.SetGlobalTexture("_BlendTex", ShaderIDs.SMAA_Flop);
69 cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)Pass.NeighborhoodBlending);
71 cmd.ReleaseTemporaryRT(ShaderIDs.SMAA_Flip);
72 cmd.ReleaseTemporaryRT(ShaderIDs.SMAA_Flop);
74 cmd.EndSample("SubpixelMorphologicalAntialiasing");