ThreePipe
    Preparing search index...

    Class SSAOPlugin

    Screen Space Ambient Occlusion (SSAO) Plugin for enhanced lighting and depth perception in 3D scenes.

    SSAO is a real-time ambient occlusion technique that approximates the soft shadows that occur in creases, holes, and surfaces that are close to each other. This plugin adds a pre-render pass that calculates ambient occlusion data which is then used by materials during the main render pass.

    • Real-time SSAO calculation using screen-space techniques
    • Multiple packing modes for different texture formats and optimization needs
    • Per-material control - materials can disable SSAO individually via userData
    • Configurable quality settings including sample count, radius, bias, and intensity
    • Automatic serialization of all settings with viewer configuration
    • GBuffer integration for optimized depth and normal data access

    This plugin automatically adds GBufferPlugin as a dependency for efficient depth and normal data.

    • Architectural visualization - enhances depth perception in interior scenes
    • Product visualization - adds realistic ambient shadows to showcase products
    • Game environments - provides cost-effective ambient occlusion for real-time rendering
    • CAD visualization - improves understanding of complex mechanical assemblies
    • Use lower sizeMultiplier values (0.5-0.75) for better performance on mobile devices
    • Combine with ProgressivePlugin and TemporalAAPlugin for temporal accumulation
    • Consider disabling SSAO on transparent or unlit materials to save processing
    import {ThreeViewer, SSAOPlugin} from 'threepipe'

    const viewer = new ThreeViewer({
    plugins: [new SSAOPlugin()]
    })

    // Access the plugin and configure settings
    const ssaoPlugin = viewer.getPlugin(SSAOPlugin)!
    ssaoPlugin.pass.intensity = 1.2
    ssaoPlugin.pass.radius = 0.5
    // Disable SSAO for a specific material
    material.userData.ssaoDisabled = true

    // Disable SSAO casting (material won't contribute to AO calculation)
    material.userData.ssaoCastDisabled = true
    const ssaoPlugin = new SSAOPlugin(
    UnsignedByteType, // Buffer type
    0.5, // Size multiplier for better performance
    true, // Enabled
    1 // Packing mode
    )
    viewer.addPlugin(ssaoPlugin)

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new SSAOPlugin instance.

      Parameters

      • bufferType: TextureDataType = UnsignedByteType

        Data type for the SSAO buffer (default: UnsignedByteType)

      • sizeMultiplier: number = 1

        Size multiplier for the render target (default: 1.0)

      • enabled: boolean = true

        Whether the plugin is initially enabled (default: true)

      • packing: SSAOPacking = 1

        SSAO data packing mode (default: 1)

      Returns SSAOPlugin

    Properties

    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    bufferType: TextureDataType

    Buffer data type for the SSAO render target. Cannot be changed after plugin creation.

    • UnsignedByteType - Standard 8-bit precision, good performance
    • HalfFloatType - 16-bit precision, better quality but slower
    • FloatType - 32-bit precision, highest quality but slowest
    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    dependencies: typeof GBufferPlugin[] = ...

    Plugin dependencies - automatically adds GBufferPlugin for depth and normal data

    enabled: boolean = true
    packing: SSAOPacking

    SSAO data packing mode for the render target. Cannot be changed after plugin creation.

    SSAOPacking for available packing modes

    passId: "ssao" = 'ssao'
    sizeMultiplier: number

    Render target size multiplier relative to the main canvas size. Cannot be changed after plugin creation.

    • 1.0 - Full resolution (highest quality)
    • 0.75 - 75% resolution (good balance)
    • 0.5 - Half resolution (better performance)
    • 0.25 - Quarter resolution (mobile performance)

    The render target containing SSAO data

    Debug texture preview of the SSAO buffer (read-only)

    uiConfig?: UiObjectConfig<any, string, any> = undefined
    OldPluginType: "SSAO" = 'SSAO'
    PluginType: "SSAOPlugin" = 'SSAOPlugin'

    Accessors

    Methods