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