Vixen
dd8b0a81
csharp
public sealed class SmaaRenderer

SMAA 1x: the antialiasing that finds the whole edge before it blends anything.

Read the guide page for this →

Remarks

FxaaRenderer reads one pixel's neighbourhood, guesses which way the edge runs and blends along the guess — which is why it softens an albedo map's detail as readily as a silhouette. This walks the edge instead: a run of edge texels bounded by two crossing edges is a silhouette whose sub-pixel position is known, and the coverage that follows is looked up rather than estimated. The cost is three passes and two intermediate targets where FXAA is one pass and none.

Three passes, because each needs the whole of the one before it. The weight pass walks up to sixteen texels along an edge, so it cannot run until every edge in the frame has been found; the blend pass reads its neighbours' weights, so it cannot run until every weight has been written. That is the same shape BloomRenderer has and the reason both are SceneRenderers rather than PostEffectRenderers, which is one pass by construction.

⚠ The coverage table is generated, imported and uploaded once. The reference distribution ships it as a 179 KB byte array in a header; it is an analytic function, so SmaaAreaTexture computes it instead. It is imported rather than declared for TemporalAntialiasingRenderer's reason — a transient is dead at the end of the frame, and a table regenerated every frame is a table uploaded every frame — and the copy is a transfer pass of the node's own, because a copy into a texture cannot be recorded inside a render pass and everything a graph pass with attachments executes is inside one.

Every pass binds every texture, whatever its mode. A descriptor set is written whole or not at all: a set that fell one binding short refuses every draw in the pass while the draw count still reports fine. The edge pass has no weights to read and the blend pass has no table, so both bind Source in those slots — already in the sampled layout, which makes it the cheapest valid stand-in, and never the resource the pass writes, which would be a cycle in the graph.

⚠ Diagonal pattern detection is not implemented. See Smaa.rvn's header: silhouettes near 45° fall through to the orthogonal path, which is the reference's own SMAA_DISABLE_DIAG_DETECTION build rather than an approximation of one.

Fields and properties (16)

  • public required string Source

    The texture it antialiases.

  • public string Output

    The name the result is published under.

  • public PixelFormat Format

    The format of the target it declares.

  • public float EdgeThreshold

    The relative local contrast a boundary needs before it is an edge, 0 to 1.

  • public float ContrastAdaptation

    How much steeper a nearby contrast may be before this edge is discarded.

  • public float LumaFloor

    The luminance below which the frame is treated as flat, in its own units.

  • public PixelFormat MaskFormat

    The format the edge mask and the weights are kept in.

  • public EffectPipelineDescriber? Modules

    Where shader modules come from.

  • public DescriptorAllocator? Descriptors

    Where the passes' descriptor sets come from.

  • public SamplerCache? Samplers

    Where samplers come from.

  • public IGraphicsDevice? Device

    The device its pipelines, its table and its uniform blocks are created on.

  • public IReadOnlyList<FullScreenRenderer> Passes

    The three passes, in the order they run.

  • public bool Uploaded

    Whether the coverage table has been copied to the device.

  • public string EdgesName

    What the edge mask is published under.

  • public string WeightsName

    What the blending weights are published under.

  • public string AreaName

    What the coverage table is published under.

Methods (3)

  • public SmaaRenderer()

    Creates the three passes.

  • protected override void Build(GraphicsCompositor compositor, CompositorFrame frame)
  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (4)

  • HarnessVixen.Rendering.PostFx.Tests
  • PostEffectFactoryVixen.Rendering.PostFx
  • SmaaImageTestsVixen.Graphics.Golden.Tests
  • SmaaTestsVixen.Rendering.PostFx.Tests