3 namespace UnityEngine
.Rendering
.PostProcessing
6 /// This class holds settings for the Subpixel Morphological Anti-aliasing (SMAA) effect.
8 #if UNITY_2017_1_OR_NEWER
9 [UnityEngine
.Scripting
.Preserve
]
12 public sealed class SubpixelMorphologicalAntialiasing
18 NeighborhoodBlending
= 6
43 /// The quality preset to use for the anti-aliasing filter.
45 [Tooltip("Lower quality is faster at the expense of visual quality (Low = ~60%, Medium = ~80%).")]
46 public Quality quality
= Quality
.High
;
49 /// Checks if the effect is supported on the target platform.
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");