Vixen
02b45cc4
csharp
public sealed class BloomRenderer

The dual-filter bloom chain: a downsample pyramid, then an upsample that adds each level back.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The first multi-pass effect, and the one worth building early for that reason. A single post pass proves the node; a pyramid proves the graph — nine textures whose lifetimes overlap in a strict pattern, each written by one pass and read by exactly one other, which is precisely the shape transient aliasing exists for.

Mips rather than one wide blur. Each level halves the resolution, so a bloom spanning a quarter of the screen costs about a third more than its first level alone. A blur wide enough to do that in one pass would be hundreds of taps at full resolution.

The chain is declared, not imported. Every level lives and dies inside the frame, so the graph owns them — which means the level-4 texture can be the same memory as something else in the frame that had finished with it, and a bloom nothing reads costs no passes at all.

The children are real FullScreenRenderers, kept between frames. Each one owns a pipeline cache and a uniform buffer; rebuilding them every frame would recompile the same pipelines and reallocate the same buffers, which is most of what a post chain could get wrong. What is rebuilt per frame is only what depends on the frame's size.

Fields and properties (20)

  • public string ShaderName

    The shader to run, in its four modes.

  • public required string Source

    The name of the texture the chain reads.

  • public string Output

    The name the chain's result is published under, for whatever composites it.

  • public int Levels

    How many levels the pyramid has, the first at half resolution.

  • public PixelFormat Format

    The format every level has.

  • public float Threshold

    Luminance above which a pixel contributes.

  • public float Knee

    How soft the threshold is, which is what stops highlights popping in and out.

  • public float FilterRadius

    The upsample tent's radius in texels, which is how wide the bloom spreads.

  • public float Intensity

    How much of each level is added on the way up.

  • public bool KarisAverage

    Whether the first downsample Karis-averages its taps, which stops highlight flicker.

  • public EffectPipelineDescriber? Modules

    Where shader modules come from.

  • public DescriptorAllocator? Descriptors

    Where descriptor sets come from.

  • public SamplerCache? Samplers

    Where the sampler comes from.

  • public IGraphicsDevice? Device

    The device its pipelines and uniform buffers are created on.

  • public uint SourceBinding

    Which binding the source texture occupies.

  • public uint SamplerBinding

    Which binding the sampler occupies.

  • public uint PreviousBinding

    Which binding the larger mip occupies, for the upsample mode.

  • public uint ConstantBinding

    Where the uniform block goes.

  • public int PassCount

    How many passes the last build declared.

  • public IReadOnlyList<FullScreenRenderer> Passes

    The chain's passes, the first PassCount of which are this frame's.

Methods (3)

  • public void Apply(in PostProcessOverlay overlay)
  • protected override void Build(GraphicsCompositor compositor, CompositorFrame frame)

    Declares this node's render-graph passes.

  • public void Dispose()

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

Used by (6)

  • BloomTestsVixen.Rendering.PostFx.Tests
  • CompositorContentTestsVixen.Assets.Tests
  • CompositorImageTestsVixen.Graphics.Golden.Tests
  • HarnessVixen.Rendering.PostFx.Tests
  • PostEffectFactoryVixen.Rendering.PostFx
  • PostEffectTestsVixen.Rendering.PostFx.Tests