@pixi/3d
    Preparing search index...

    Class SsaoEffect

    Screen-space ambient occlusion: darkens creases, corners and contact points

    Costs four fullscreen passes, three of them at resolution. Every property can change every frame; the resolution and sceneNormals options are fixed at construction.

    view.passes = [new SsaoEffect({ radius: 0.35, resolution: 1 })];
    

    Hierarchy (View Summary)

    Index
    enabled: boolean

    Whether this pass runs

    Flipping it rebuilds the view's render graph on the next render, which suits a settings toggle but not a change every frame; animate an effect's own properties instead. It can also recompile the view's materials; View3D#passes says when.

    const wireframe = new MeshPass({ name: 'wireframe' });
    view.passes = [wireframe];
    wireframe.enabled = false;
    inputMips: boolean = false

    Whether the effect's input has mips, for an effect that reads coarse levels with sampleColorLod, such as a blur

    Costs a mip generation every frame and about a third more memory for the input, so leave it false unless the effect samples levels above 0.

    requiredOutputs?: readonly SceneOutput[]

    [normalOutput] when sceneNormals is set, otherwise undefined

    The stage the effect runs at, set by the stage option

    defaultOptions: SsaoEffectOptions = ...

    Defaults for every new SsaoEffect; an option passed as undefined keeps its default

    maxDistance has no entry, so unless set it starts at 0.65 × the resolved radius.

    SsaoEffect.defaultOptions.resolution = 1;
    
    • get bias(): number

      Depth offset in world units that stops a surface occluding itself

      Returns number

      ssao.bias = 0.05;
      
    • set bias(value: number): void

      Sets the self-occlusion bias

      Parameters

      • value: number

        Depth offset in world units.

      Returns void

    • get blurStep(): number

      Spacing between blur taps, in texels of the occlusion buffer

      Returns number

      ssao.blurStep = 2;
      
    • set blurStep(value: number): void

      Sets the spacing between blur taps

      Parameters

      • value: number

        Spacing in texels.

      Returns void

    • get fadeDistance(): [number, number] | null

      Depths [start, end] across which the occlusion fades out, or null for none; see SsaoEffectOptions#fadeDistance

      Returns [number, number] | null

      ssao.fadeDistance = [40, 80];
      
    • set fadeDistance(value: [number, number] | null): void

      Sets the depths across which the occlusion fades out

      Parameters

      • value: [number, number] | null

        [start, end] in world units, end above start, or null for no fade.

      Returns void

    • get intensity(): number

      Strength of the darkening

      0 hides the darkening, but every pass still runs; set enabled to false to skip them.

      Returns number

      ssao.intensity = 0.5;
      
    • set intensity(value: number): void

      Sets the darkening strength

      Parameters

      • value: number

        Multiplier on the occlusion.

      Returns void

    • get maxDistance(): number

      Depth gap in world units at which an occluder stops counting; see SsaoEffectOptions#maxDistance

      Returns number

      ssao.maxDistance = ssao.radius * 0.5;
      
    • set maxDistance(value: number): void

      Sets the depth gap at which an occluder stops counting

      Parameters

      • value: number

        Depth gap in world units.

      Returns void

    • get power(): number

      Exponent on the occlusion term; higher values darken the occluded areas further

      Returns number

      ssao.power = 2;
      
    • set power(value: number): void

      Sets the exponent on the occlusion term

      Parameters

      • value: number

        Exponent applied to the occlusion term.

      Returns void

    • get radius(): number

      How far around each point the effect looks for occluders, in world units

      Returns number

      ssao.radius = 0.6;
      
    • set radius(value: number): void

      Sets how far around each point the effect looks for occluders

      Parameters

      • value: number

        Radius in world units.

      Returns void

    • get samples(): number

      Samples per pixel; the cost of the occlusion pass grows with it

      Returns number

      ssao.samples = isMobile ? 8 : 16;
      
    • set samples(value: number): void

      Sets the samples per pixel

      Parameters

      • value: number

        Samples per pixel.

      Returns void

    • Advanced

      Adds the occlusion, blur and merge passes for this slot in the chain

      Parameters

      • graph: RenderGraph

        Render graph being built.

      • io: EffectIO

        Input/output handles for this slot in the chain.

      Returns void

      const occluded = graph.createColor({ label: 'occluded' });
      ssao.build(graph, { ...io, output: occluded });
    • Releases GPU resources the pass made outside the graph; the base class has none

      The view never calls it, not on replacing view.passes nor on its own destroy, since a pass can be shared. Call it yourself once the pass is retired. Override it only for resources of your own: the render passes added in build go with the view's graph, and a plain UniformGroup needs no release.

      Returns void

      view.passes = [];
      wireframe.destroy();